- int s_start, s_end;
- if (selection_start_cursor.pos() > selection_end_cursor.pos()) {
- s_start = selection_end_cursor.pos();
- s_end = selection_start_cursor.pos();
- } else {
- s_start = selection_start_cursor.pos();
- s_end = selection_end_cursor.pos();
- }
- if ((s_start > endpos) || (s_end < startpos))
- return;
-
- int esel_x;
- int ssel_x = esel_x = int(x);
- LyXFont font;
- int p = startpos;
- for(; p < endpos; ++p) {
- if (p == s_start)
- ssel_x = int(x);
- if ((p >= s_start) && (p <= s_end))
- esel_x = int(x);
- char ch = par->GetChar(p);
- font = GetDrawFont(current_view->buffer(), par, p);
- if (IsFloatChar(ch)) {
- // skip for now
- } else if (ch == LyXParagraph::META_INSET) {
- Inset const * tmpinset = par->GetInset(p);
- x += tmpinset->width(pain, font);
- } else {
- x += lyxfont::width(ch, font);
- }
- }
- if (p == s_start)
- ssel_x = int(x);
- if ((p >= s_start) && (p <= s_end))
- esel_x = int(x);
- if (ssel_x < esel_x) {
- pain.fillRectangle(int(ssel_x), baseline-rows[row].asc,
- int(esel_x - ssel_x),
- rows[row].asc + rows[row].desc,
- LColor::selection);
- }
-}
-
-
-void InsetText::drawRowText(Painter & pain, int startpos, int endpos,
- int baseline, float x) const
-{
- Assert(endpos <= par->Last());
-
- for(int p = startpos; p < endpos; ++p) {
- char ch = par->GetChar(p);
- LyXFont font = GetDrawFont(current_view->buffer(), par, p);
- if (IsFloatChar(ch)) {
- // skip for now
- } else if (par->IsNewline(p)) {
- // Draw end-of-line marker
- int wid = lyxfont::width('n', font);
- int asc = lyxfont::maxAscent(font);
- int y = baseline;
- int xp[3], yp[3];
-
- xp[0] = int(x + wid * 0.375);
- yp[0] = int(y - 0.875 * asc * 0.75);
-
- xp[1] = int(x);
- yp[1] = int(y - 0.500 * asc * 0.75);
-
- xp[2] = int(x + wid * 0.375);
- yp[2] = int(y - 0.125 * asc * 0.75);
-
- pain.lines(xp, yp, 3, LColor::eolmarker);
-
- xp[0] = int(x);
- yp[0] = int(y - 0.500 * asc * 0.75);
-
- xp[1] = int(x + wid);
- yp[1] = int(y - 0.500 * asc * 0.75);
-
- xp[2] = int(x + wid);
- yp[2] = int(y - asc * 0.75);
-
- pain.lines(xp, yp, 3, LColor::eolmarker);
- x += wid;
- } else if (ch == LyXParagraph::META_INSET) {
- Inset * tmpinset = par->GetInset(p);
- if (tmpinset)
- tmpinset->draw(pain, font, baseline, x);
- } else {
- pain.text(int(x), baseline, ch, font);
- x += lyxfont::width(ch, font);
- }
+ // this to not draw a selection when we redraw all of it!
+ if ((need_update & (INIT|FULL)) && (need_update & CURSOR))
+ TEXT(bv)->ClearSelection(bv);
+}
+
+void InsetText::UpdateLocal(BufferView * bv, int what, bool mark_dirty)
+{
+ TEXT(bv)->FullRebreak(bv);
+ SetUpdateStatus(bv, what);
+ if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) ||
+ TEXT(bv)->selection)
+ bv->updateInset(this, mark_dirty);
+ bv->owner()->showState();
+ if (old_par != cpar(bv)) {
+ bv->owner()->setLayout(cpar(bv)->GetLayout());
+ old_par = cpar(bv);