}
-void BufferView::fitCursor(LyXText * text)
+void BufferView::fitCursor()
{
- pimpl_->fitCursor(text);
+ pimpl_->fitCursor();
}
///
void redraw();
///
- void fitCursor(LyXText *);
+ void fitCursor();
///
void update();
//
}
-bool BufferView::Pimpl::fitCursor(LyXText * text)
+bool BufferView::Pimpl::fitCursor()
{
lyx::Assert(screen_.get());
bv_->theLockingInset()->fitInsetCursor(bv_);
ret = true;
} else {
- ret = screen_->fitCursor(text, bv_);
+ ret = screen_->fitCursor(bv_->text, bv_);
}
bv_->owner()->getDialogs()->updateParagraph();
bv_->text->setSelection(bv_);
screen_->toggleToggle(bv_->text, bv_);
- fitCursor(bv_->text);
+ fitCursor();
#if 0
screen_->showCursor(bv_->text, bv_);
#else
screen_->toggleSelection(bv_->text, bv_);
bv_->text->clearSelection();
bv_->text->fullRebreak(bv_);
+#if 0
screen_->update(bv_->text, bv_);
+#else
+ update();
+#endif
updateScrollbar();
// Single left click in math inset?
bv_->text->cursor.x_fix(bv_->text->cursor.x());
owner_->updateLayoutChoice();
- if (fitCursor(bv_->text)) {
+ if (fitCursor()) {
selection_possible = false;
}
// fitCursor() ensures we don't jump back
// to the start of the document on vertical
// resize
- fitCursor(bv_->text);
+ fitCursor();
// The main window size has changed, repaint most stuff
redraw();
if (screen_.get() &&
(!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()))
{
+ LyXText::text_status st = bv_->text->status();
screen_->update(bv_->text, bv_);
+ while(bv_->text->status() == LyXText::CHANGED_IN_DRAW) {
+ if (bv_->text->fullRebreak(bv_)) {
+ st = LyXText::NEED_MORE_REFRESH;
+ bv_->text->setCursor(bv_, bv_->text->cursor.par(),
+ bv_->text->cursor.pos());
+ fitCursor();
+ }
+ bv_->text->status(bv_, st);
+ screen_->update(bv_->text, bv_);
+ }
}
}
}
if ((f & FITCUR)) {
- fitCursor(text);
+ fitCursor();
}
if ((f & CHANGE)) {
}
if (!bv_->theLockingInset()) {
- screen_->cursorToggle(bv_->text, bv_);
+ screen_->cursorToggle(bv_);
} else {
bv_->theLockingInset()->toggleInsetCursor(bv_);
}
case LFUN_INDEX_CREATE:
{
InsetCommandParams p("index");
- LyXText * lt = bv_->getLyXText();
-
if (argument.empty()) {
string const idxstring(bv_->getLyXText()->getStringToIndex(bv_));
if (!idxstring.empty())
///
void redraw();
/// Return true if the cursor was fitted.
- bool fitCursor(LyXText *);
+ bool fitCursor();
///
void redoCurrentBuffer();
///
+2001-08-02 Juergen Vigna <jug@sad.it>
+
+ * BufferView_pimpl.C (update): redone this function so that we
+ update the text again if there was a CHANGE_IN_DRAW.
+
+ * screen.C (cursorToggle): removed LyXText parameter and recoded.
+ (drawFromTo): added a new internal bool which is used by draw() and
+ redraw() function.
+ (general): some cursor drawing problems fixed.
+
2001-08-01 Juergen Vigna <jug@sad.it>
* lyxfind.C (LyXFind): fixed
// error insets after we ran chktex, this must be run:
if (removedErrorInsets || res){
users->redraw();
- users->fitCursor(users->text);
+ users->fitCursor();
}
users->owner()->allowInput();
void Buffer::redraw()
{
users->redraw();
- users->fitCursor(users->text);
+ users->fitCursor();
}
}
if (need_redraw) {
bv->redraw();
- bv->fitCursor(bv->text);
+ bv->fitCursor();
}
bv->owner()->allowInput();
}
// error insets after we ran LaTeX this must be run:
if (need_redraw) {
bv->redraw();
- bv->fitCursor(bv->text);
+ bv->fitCursor();
}
}
// We need to do a redraw because the maximum
// InsetBibKey width could have changed
lv_.view()->redraw();
- lv_.view()->fitCursor(lv_.view()->getLyXText());
+ lv_.view()->fitCursor();
}
// We need to do a redraw because the maximum
// InsetBibKey width could have changed
lv_.view()->redraw();
- lv_.view()->fitCursor(lv_.view()->getLyXText());
+ lv_.view()->fitCursor();
}
+2001-08-02 Juergen Vigna <jug@sad.it>
+
+ * insettext.C (draw): clear the background with the right color if
+ needed. Update myself if x&max-width changed and return without doing
+ anything. Let the update code handle the right stuff.
+
+ * insetminipage.C (getMaxWidth): fixed returning of maxwidth when
+ inside another inset.
+
2001-08-01 Juergen Vigna <jug@sad.it>
* insetcollapsable.C (update): added an in_update bool so we avoid
void insetKeyPress(XKeyEvent *);
///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
- string const &);
+ string const &);
///
int latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
bv->text->redoParagraph(bv);
if (flag) {
bv->redraw();
- bv->fitCursor(getLyXText(bv));
+ bv->fitCursor();
} else
bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
void InsetMinipage::insetButtonRelease(BufferView * bv, int x, int y,
- int button)
+ int button)
{
if (button == 3) {
showInsetDialog(bv);
int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
const
{
- if (!width_.empty())
- return VSpace(width_).inPixels(bv);
+ if (!width_.empty()) {
+ int ww1 = VSpace(width_).inPixels(bv);
+ int ww2 = InsetCollapsable::getMaxWidth(bv, inset);
+ if (ww2 > 0 && ww2 < ww1)
+ return ww2;
+ return ww1;
+ }
// this should not happen!
return InsetCollapsable::getMaxWidth(bv, inset);
}
sstate.selendboundary = t->selection.end.boundary();
sstate.selection = t->selection.set();
sstate.mark_set = t->selection.mark();
+ sstate.refresh = t->refresh_row != 0;
}
void InsetText::restoreLyXTextState(BufferView * bv, LyXText * t) const
t->selection.cursor = t->cursor;
t->selection.set(false);
}
+ if (sstate.refresh) {
+ }
}
}
return;
Painter & pain = bv->painter();
+
+ // this is the first thing we have to ask because if the x pos
+ // changed we have to do a complete rebreak of the text as we
+ // may have few space to draw in. Well we should check on this too
+ if (top_x != int(x)) {
+ int old_x = top_x;
+ top_x = int(x);
+ int nw = getMaxWidth(bv, this);
+ if (nw > 0 && old_max_width != nw) {
+ need_update = INIT;
+ old_max_width = nw;
+ bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
+ return;
+ } else {
+ top_x = old_x;
+ }
+ // dummy calls so that the values are again right
+ (void)ascent(bv, f);
+ (void)descent(bv, f);
+ (void)width(bv, f);
+ }
+
+ // repaint the background if needed
+ if (cleared && backgroundColor() != LColor::background) {
+ clearInset(pain, baseline, cleared);
+ }
// no draw is necessary !!!
if ((drawFrame_ == LOCKED) && !locked && !par->size()) {
(last_drawn_width!=insetWidth))) {
clearInset(pain, baseline, cleared);
}
+ top_x = int(x);
if (cleared)
frame_is_visible = false;
if (!cleared && (need_update == NONE))
return;
- if (top_x != int(x)) {
- if ((getMaxWidth(bv, this) > 0) &&
- (getLyXText(bv)->width != old_max_width)) {
- resizeLyXText(bv);
- need_update |= FULL;
- old_max_width = getLyXText(bv)->width;
- bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
- }
- top_x = int(x);
- clearInset(pain, baseline, cleared);
- }
-
// lyxerr << "InsetText::draw[" << this << "](" << need_update << ":" << int(x) << ":" << top_x << ")\n";
if (cleared || (last_drawn_width != insetWidth)) {
inset_y = cy(bv) + drawTextYOffset;
}
if (!cleared && (need_update == CURSOR)
- && !getLyXText(bv)->selection.set()) {
+ && !getLyXText(bv)->selection.set())
+ {
drawFrame(pain, cleared);
x += last_width; // was width(bv, f);
need_update = NONE;
if (y_offset < 0)
y_offset = y;
lt->first = first;
- if (cleared) {
+ if (cleared || (need_update&=(INIT|FULL))) {
int yf = y_offset;
y = 0;
while ((row != 0) && (yf < ph)) {
void InsetText::drawFrame(Painter & pain, bool cleared) const
{
if (!frame_is_visible || cleared) {
- frame_x = top_x + 1;
- frame_y = top_baseline - insetAscent + 1;
- frame_w = insetWidth - 1;
- frame_h = insetAscent + insetDescent - 1;
+ frame_x = top_x; // + 1;
+ frame_y = top_baseline - insetAscent; // + 1;
+ frame_w = last_width; // - 2;
+ frame_h = insetAscent + insetDescent; // - 2;
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
frame_color);
frame_is_visible = true;
(cpar(bv)->getInset(cpos(bv)) != inset))
lt->cursorLeft(bv);
#endif
- bv->fitCursor(lt);
+ bv->fitCursor();
updateLocal(bv, CURSOR_PAR|CURSOR, true);
showInsetCursor(bv);
if (clear)
}
if (selectall)
selectAll(bv);
-#if 1
lt->toggleFree(bv, font, toggleall);
-#else
- lt->setFont(bv, font, toggleall);
-#endif
if (selectall)
lt->clearSelection();
- bv->fitCursor(lt);
+ bv->fitCursor();
if (selectall || lt->selection.set())
updateLocal(bv, FULL, true);
else
}
w -= (2 * TEXT_TO_INSET_OFFSET);
return w - top_x;
-// return w - (2*TEXT_TO_INSET_OFFSET);
}
if (!owner())
updateLocal(bv, FULL, false);
else
- need_update = FULL;
+ need_update |= FULL;
// this will scroll the screen such that the cursor becomes visible
bv->updateScrollbar();
}
h = pain.paperHeight();
if ((top_x + drawTextXOffset + w) > pain.paperWidth())
w = pain.paperWidth();
- pain.fillRectangle(top_x+drawTextXOffset, ty, w, h,
- backgroundColor());
+ pain.fillRectangle(top_x+drawTextXOffset, ty, w, h, backgroundColor());
cleared = true;
need_update = FULL;
}
///
mutable int inset_y;
///
- mutable unsigned int old_max_width;
+ mutable int old_max_width;
///
bool no_selection;
///
bool selendboundary;
bool selection;
bool mark_set;
+ bool refresh;
} sstate;
///
// this is needed globally so we know that we're using it actually and
case LFUN_REMOVEERRORS:
if (owner->view()->removeAutoInsets()) {
owner->view()->redraw();
- owner->view()->fitCursor(TEXT());
+ owner->view()->fitCursor();
}
break;
///
void hideCursor();
///
- void cursorToggle(LyXText const *, BufferView const *);
+ void cursorToggle(BufferView *) const;
///
void showManualCursor(LyXText const *, int x, int y,
int asc, int desc,
/// y1 and y2 are coordinates of the screen
void drawFromTo(LyXText *, BufferView *, int y1, int y2,
- int y_offset = 0, int x_offset = 0);
+ int y_offset = 0, int x_offset = 0, bool internal=false);
/// y is a coordinate of the text
void drawOneRow(LyXText *, BufferView *, Row * row,
/** Completes the insertion with a full rebreak.
Returns true if something was broken. */
- bool fullRebreak(BufferView *);
+ bool fullRebreak(BufferView *);
///
- Row * need_break_row;
+ mutable Row * need_break_row;
///
mutable int refresh_y;
///
void LyXScreen::redraw(LyXText * text, BufferView * bv)
{
- drawFromTo(text, bv, 0, owner.height());
+ drawFromTo(text, bv, 0, owner.height(), 0, 0, text == bv->text);
expose(0, 0, owner.workWidth(), owner.height());
if (cursor_visible) {
cursor_visible = false;
- showCursor(text, bv);
+ bv->showCursor();
}
}
void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
- int y1, int y2, int y_offset, int x_offset)
+ int y1, int y2, int y_offset, int x_offset,
+ bool internal)
{
int y_text = text->first + y1;
// y1 is now the real beginning of row on the screen
while (row != 0 && y < y2) {
- LyXText::text_status st = bv->text->status();
- do {
- bv->text->status(bv, st);
+ LyXText::text_status st = text->status();
+ text->getVisibleRow(bv, y + y_offset,
+ x_offset, row, y + text->first);
+ while(internal && text->status() == LyXText::CHANGED_IN_DRAW) {
+ if (text->fullRebreak(bv)) {
+ st = LyXText::NEED_MORE_REFRESH;
+ text->setCursor(bv, text->cursor.par(), text->cursor.pos());
+ bv->fitCursor();
+ }
+ text->status(bv, st);
text->getVisibleRow(bv, y + y_offset,
- x_offset, row, y + text->first);
- } while (bv->text->status() == LyXText::CHANGED_IN_DRAW);
- bv->text->status(bv, st);
+ x_offset, row, y + text->first);
+ }
y += row->height();
row = row->next();
}
if (((y + row->height()) > 0) &&
((y - row->height()) <= static_cast<int>(owner.height()))) {
// ok there is something visible
+#if 0
LyXText::text_status st = bv->text->status();
do {
bv->text->status(bv, st);
text->getVisibleRow(bv, y, x_offset, row,
y + text->first);
- } while (bv->text->status() == LyXText::CHANGED_IN_DRAW);
+ } while (!text->inset_owner &&
+ text->status() == LyXText::CHANGED_IN_DRAW);
bv->text->status(bv, st);
+#else
+ text->getVisibleRow(bv, y, x_offset, row, y + text->first);
+#endif
}
force_clear = false;
}
/* draws the screen, starting with textposition y. uses as much already
-* printed pixels as possible */
+ * printed pixels as possible */
void LyXScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
{
if (cursor_visible) hideCursor();
int const old_first = text->first;
+ bool internal = (text == bv->text);
text->first = y;
// is any optimiziation possible?
if ((y - old_first) < owner.height()
- && (old_first - y) < owner.height()) {
+ && (old_first - y) < owner.height())
+ {
if (text->first < old_first) {
- drawFromTo(text, bv, 0, old_first - text->first);
+ drawFromTo(text, bv, 0, old_first - text->first, 0, 0, internal);
XCopyArea (fl_get_display(),
owner.getWin(),
owner.getWin(),
old_first - text->first);
} else {
drawFromTo(text, bv,
- owner.height() + old_first - text->first,
- owner.height());
+ owner.height() + old_first - text->first,
+ owner.height(), 0, 0, internal);
XCopyArea (fl_get_display(),
owner.getWin(),
owner.getWin(),
}
} else {
// make a dumb new-draw
- drawFromTo(text, bv, 0, owner.height());
+ drawFromTo(text, bv, 0, owner.height(), 0, 0, internal);
expose(0, 0, owner.workWidth(), owner.height());
}
}
}
-void LyXScreen::cursorToggle(LyXText const * text, BufferView const * bv)
+void LyXScreen::cursorToggle(BufferView * bv) const
{
if (cursor_visible)
- hideCursor();
+ bv->hideCursor();
else
- showCursor(text, bv);
+ bv->showCursor();
}
// ok I will update the current cursor row
drawOneRow(text, bv, text->refresh_row, text->refresh_y,
y_offset, x_offset);
- text->status(bv, LyXText::UNCHANGED);
- expose(0, text->refresh_y - text->first + y_offset,
- owner.workWidth(), text->refresh_row->height());
+ // this because if we had a major update the refresh_row could
+ // have been set to 0!
+ if (text->refresh_row) {
+ text->status(bv, LyXText::UNCHANGED);
+ expose(0, text->refresh_y - text->first + y_offset,
+ owner.workWidth(), text->refresh_row->height());
+ }
}
break;
case LyXText::CHANGED_IN_DRAW: // just to remove the warning
tmpinset->update(bview, font, false);
tmpinset->draw(bview, font, offset+row->baseline(), x,
cleared);
-#ifdef SEEMS_TO_BE_NOT_NEEDED
- if (status_ == CHANGED_IN_DRAW) {
- UpdateInset(bview, tmpinset);
- status(bview, CHANGED_IN_DRAW);
+ if (!need_break_row &&
+ bview->text->status() == CHANGED_IN_DRAW)
+ {
+ if (row->previous() && row->previous()->par() == row->par())
+ breakAgainOneRow(bview, row->previous());
+ setCursor(bview, cursor.par(), cursor.pos());
+ need_break_row = const_cast<Row *>(row);
}
-#endif
}
++vpos;
// and the specified par
// This function is needed after SetLayout and SetFont etc.
void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur,
- Paragraph const * endpar) const
+ Paragraph const * endpar) const
{
Row * tmprow2;
Paragraph * tmppar = 0;
} else {
first_phys_par = tmprow->par();
while (tmprow->previous()
- && tmprow->previous()->par() == first_phys_par) {
+ && tmprow->previous()->par() == first_phys_par)
+ {
tmprow = tmprow->previous();
y -= tmprow->height();
}
status(bview, LyXText::NEED_MORE_REFRESH);
refresh_y = y;
refresh_row = tmprow->previous(); /* the real refresh row will
- be deleted, so I store
- the previous here */
+ be deleted, so I store
+ the previous here */
// remove it
if (tmprow->next())
tmppar = tmprow->next()->par();
// remove the first one
tmprow2 = tmprow; /* this is because tmprow->previous()
- can be 0 */
+ can be 0 */
tmprow = tmprow->previous();
removeRow(tmprow2);