From e06bc73c2272c18a5f52d4229449c4e0b0caf1e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 1 Jun 2001 15:10:26 +0000 Subject: [PATCH] InsetText/Tabular fixes (buglist from SF.NET) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2085 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 2 +- src/ChangeLog | 11 +++++++++++ src/insets/ChangeLog | 13 +++++++++++++ src/insets/insettabular.C | 15 ++++++++++----- src/insets/insettext.C | 40 +++++++++++++++++++++++---------------- src/insets/insettext.h | 1 + src/lyxfunc.C | 7 +++++-- 7 files changed, 65 insertions(+), 24 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 5e7eaf7616..835cef0dd4 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1835,7 +1835,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) if (!lt->selection.mark()) beforeChange(lt); update(lt, BufferView::SELECT|BufferView::FITCUR); - LyXCursor const & cur = lt->cursor; + LyXCursor const cur = lt->cursor; if (!is_rtl) lt->CursorLeft(bv_, false); if ((is_rtl || cur != lt->cursor) && // only if really moved! diff --git a/src/ChangeLog b/src/ChangeLog index 69ac991555..efe7628122 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2001-06-01 Juergen Vigna + + * lyxfunc.C (Dispatch): LFUN_PREFIX don't call the update if we're + inside a LockingInset (is the update needed at all?). + +2001-05-31 Juergen Vigna + + * BufferView_pimpl.C (Dispatch): we need a new instanze of cursor + here not the old one otherwise how should we compare it afterwards + if it's the same! + 2001-06-01 Jean-Marc Lasgouttes * lyxfont.C: diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 92977ef2f2..35e68f1721 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,16 @@ +2001-06-01 Juergen Vigna + + * insettabular.C (resetPos): small hack so that scroll is not set to + 0 when we are in the last column of a tabular. This is a problem we + have because of constats 20 offset on both directions, so this can + cause on the limit an endless loop. + + * insettext.C (SetFont): forgot that we can have locking insets ;) + +2001-05-31 Juergen Vigna + + * insettabular.C (LocalDispatch): small fix for LFUN_TAB. + 2001-05-31 Jean-Marc Lasgouttes * figinset.C: add using std:: directive for the C functions which diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 212b1a5fb1..39650ad2b6 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -577,10 +577,12 @@ bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset, if (the_locking_inset == inset) { the_locking_inset->InsetUnlock(bv); the_locking_inset = 0; +#warning fix scrolling when cellinset has requested a scroll (Jug)!!! +#if 0 if (scroll(false)) scroll(bv, 0.0F); - else - UpdateLocal(bv, CELL, false); +#endif + UpdateLocal(bv, CELL, false); ShowInsetCursor(bv, false); return true; } @@ -782,7 +784,7 @@ InsetTabular::LocalDispatch(BufferView * bv, case LFUN_SHIFT_TAB: case LFUN_TAB: { - if (GetFirstLockingInsetOfType(Inset::TABULAR_CODE)) + if (GetFirstLockingInsetOfType(Inset::TABULAR_CODE) != this) break; HideInsetCursor(bv); if (the_locking_inset) { @@ -1282,11 +1284,14 @@ void InsetTabular::resetPos(BufferView * bv) const new_x += offset; cursor.x(new_x); // cursor.x(getCellXPos(actcell) + offset); - if (scroll(false) && (tabular->GetWidthOfTabular() < bv->workWidth()-20)) { + if ((actcol < tabular->columns()-1) && scroll(false) && + (tabular->GetWidthOfTabular() < bv->workWidth()-20)) + { scroll(bv, 0.0F); UpdateLocal(bv, FULL, false); } else if (the_locking_inset && - (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) { + (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) + { int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv); if (xx > (bv->workWidth()-20)) { scroll(bv, -(xx - bv->workWidth() + 60)); diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 02ab563ae9..9367aa62ee 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -284,21 +284,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, ((need_update&(INIT|FULL)) || (top_baseline!=baseline) || (last_drawn_width!=insetWidth))) { - int w = insetWidth; - int h = insetAscent + insetDescent; - int ty = baseline - insetAscent; - - if (ty < 0) { - h += ty; - ty = 0; - } - if ((ty + h) > pain.paperHeight()) - h = pain.paperHeight(); - if ((top_x + drawTextXOffset + w) > pain.paperWidth()) - w = pain.paperWidth(); - pain.fillRectangle(top_x+drawTextXOffset, ty, w, h); - cleared = true; - need_update = FULL; + clearInset(pain, baseline, cleared); } if (cleared) frame_is_visible = false; @@ -315,7 +301,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, } top_x = int(x); #if 1 - cleared = true; + clearInset(pain, baseline, cleared); #else return; #endif @@ -1394,6 +1380,10 @@ std::vector const InsetText::getLabelList() const void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall, bool selectall) { + if (the_locking_inset) { + the_locking_inset->SetFont(bv, font, toggleall, selectall); + return; + } if (TEXT(bv)->selection.set()) { bv->text->SetUndo(bv->buffer(), Undo::EDIT, bv->text->cursor.par()->previous(), @@ -1761,6 +1751,24 @@ void InsetText::clearSelection(BufferView * bv) TEXT(bv)->ClearSelection(bv); } +void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const +{ + int w = insetWidth; + int h = insetAscent + insetDescent; + int ty = baseline - insetAscent; + + if (ty < 0) { + h += ty; + ty = 0; + } + if ((ty + h) > pain.paperHeight()) + h = pain.paperHeight(); + if ((top_x + drawTextXOffset + w) > pain.paperWidth()) + w = pain.paperWidth(); + pain.fillRectangle(top_x+drawTextXOffset, ty, w, h); + cleared = true; + need_update = FULL; +} /* Emacs: * Local variables: * tab-width: 4 diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 615078abec..faa5cef34f 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -275,6 +275,7 @@ private: void drawFrame(Painter &, bool cleared) const; void clearFrame(Painter &, bool cleared) const; /// + void clearInset(Painter &, int baseline, bool & cleared) const; /* Private structures and variables */ /// diff --git a/src/lyxfunc.C b/src/lyxfunc.C index cbb0f0ebb8..1ff937641a 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -710,7 +710,10 @@ string const LyXFunc::Dispatch(int ac, } return string(); case LFUN_DOWN: - TEXT()->CursorDown(owner->view()); + if (TEXT()->cursor.row()->next()) + TEXT()->CursorDown(owner->view()); + else + TEXT()->CursorRight(owner->view()); moveCursorUpdate(true, false); owner->showState(); return string(); @@ -794,7 +797,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_PREFIX: { - if (owner->view()->available()) { + if (owner->view()->available() && !owner->view()->theLockingInset()) { owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); } -- 2.39.2