From ff67bee1179e8f12f739213b2d0074d1938028d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Vigna?= Date: Thu, 22 Feb 2001 14:09:20 +0000 Subject: [PATCH] More InsetText/InsetTabular fixes! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1599 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView2.C | 12 +- src/BufferView_pimpl.C | 18 +- src/ChangeLog | 7 + src/insets/ChangeLog | 13 + src/insets/inset.C | 4 +- src/insets/insetcollapsable.C | 4 +- src/insets/insetcollapsable.h | 2 +- src/insets/insettabular.C | 7 +- src/insets/insettabular.h | 2 +- src/insets/insettext.C | 115 +++-- src/insets/insettext.h | 18 +- src/insets/lyxinset.h | 2 +- src/lyxfr1.C | 4 +- src/lyxfunc.C | 779 +++++++++++++++++----------------- src/lyxfunc.h | 9 +- src/lyxtext.h | 2 +- src/text.C | 4 +- src/text2.C | 28 +- 18 files changed, 523 insertions(+), 507 deletions(-) diff --git a/src/BufferView2.C b/src/BufferView2.C index ebd8774a01..010be99a79 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -558,7 +558,7 @@ void BufferView::copyEnvironment() text->copyEnvironmentType(); // clear the selection, even if mark_set toggleSelection(); - text->ClearSelection(); + text->ClearSelection(this); update(text, BufferView::SELECT|BufferView::FITCUR); owner()->getMiniBuffer()->Set(_("Paragraph environment type copied")); } @@ -581,7 +581,7 @@ void BufferView::copy() text->CopySelection(this); // clear the selection, even if mark_set toggleSelection(); - text->ClearSelection(); + text->ClearSelection(this); update(text, BufferView::SELECT|BufferView::FITCUR); owner()->getMiniBuffer()->Set(_("Copy")); } @@ -607,7 +607,7 @@ void BufferView::paste() hideCursor(); // clear the selection toggleSelection(); - text->ClearSelection(); + text->ClearSelection(this); update(text, BufferView::SELECT|BufferView::FITCUR); // paste @@ -616,7 +616,7 @@ void BufferView::paste() // clear the selection toggleSelection(); - text->ClearSelection(); + text->ClearSelection(this); update(text, BufferView::SELECT|BufferView::FITCUR); } @@ -709,7 +709,7 @@ void BufferView::endOfSpellCheck() hideCursor(); beforeChange(text); text->SelectSelectedWord(this); - text->ClearSelection(); + text->ClearSelection(this); update(text, BufferView::SELECT|BufferView::FITCUR); } @@ -973,7 +973,7 @@ void BufferView::theLockingInset(UpdatableInset * inset) LyXText * BufferView::getLyXText() const { if (theLockingInset()) { - LyXText * txt = theLockingInset()->getLyXText(this); + LyXText * txt = theLockingInset()->getLyXText(this, true); if (txt) return txt; } diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index dff6e8a53e..cb1048ff52 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -585,7 +585,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, // Clear the selection screen_->ToggleSelection(bv_->text, bv_); - bv_->text->ClearSelection(); + bv_->text->ClearSelection(bv_); bv_->text->FullRebreak(bv_); screen_->Update(bv_->text, bv_); updateScrollbar(); @@ -647,10 +647,14 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) return; if (screen_ && button == 1) { - screen_->HideCursor(); - screen_->ToggleSelection(text, bv_); - text->SelectWord(bv_); - screen_->ToggleSelection(text, bv_, false); + if (text->bv_owner) { + screen_->HideCursor(); + screen_->ToggleSelection(text, bv_); + text->SelectWord(bv_); + screen_->ToggleSelection(text, bv_, false); + } else { + text->SelectWord(bv_); + } /* This will fit the cursor on the screen * if necessary */ update(text, BufferView::SELECT|BufferView::FITCUR); @@ -1031,7 +1035,7 @@ void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f) text->FullRebreak(bv_); if (text->inset_owner) { - text->inset_owner->SetUpdateStatus(bv_, InsetText::CURSOR_PAR); +// text->inset_owner->SetUpdateStatus(bv_, InsetText::CURSOR_PAR); bv_->updateInset(text->inset_owner, true); } else update(); @@ -1146,7 +1150,7 @@ bool BufferView::Pimpl::available() const void BufferView::Pimpl::beforeChange(LyXText * text) { toggleSelection(); - text->ClearSelection(); + text->ClearSelection(bv_); } diff --git a/src/ChangeLog b/src/ChangeLog index 66153a2338..5deb135d63 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2001-02-20 Juergen Vigna + + * text2.C (ClearSelection): added BufferView param for inset_owner call + + * lyxfunc.C (TEXT): added this function and use it instead of + directly owner->view()-text of getLyXText(). + 2001-02-20 Edwin Leuven * src/layout_forms.C: out preamble diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 1eed64e426..236d75be33 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,16 @@ +2001-02-22 Juergen Vigna + + * insettext.C (getLyXText): honor the recursive parameter. + + * inset.C (getLyXText): added bool recursive parameter. + + * insettext.C (SetUpdateStatus): or the update codes. + (draw): check need_update with &. + (InsetButtonPress): set no_selection to not put a selection when + entering an inset and it is redraws in another spot. + + * insettext.h: made need_update an int. + 2001-02-20 Baruch Even * insetgraphics.h: diff --git a/src/insets/inset.C b/src/insets/inset.C index d8cd78c143..7db87b30c6 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -72,10 +72,10 @@ string const Inset::EditMessage() const } -LyXText * Inset::getLyXText(BufferView const * bv) const +LyXText * Inset::getLyXText(BufferView const * bv, bool const) const { if (owner()) - return owner()->getLyXText(bv); + return owner()->getLyXText(bv, false); else return bv->text; } diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 9b3096b7ac..dc1294b53e 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -441,9 +441,9 @@ bool InsetCollapsable::doClearArea() const } -LyXText * InsetCollapsable::getLyXText(BufferView const * bv) const +LyXText * InsetCollapsable::getLyXText(BufferView const * bv, bool recursive) const { - return inset->getLyXText(bv); + return inset->getLyXText(bv, recursive); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index f8a3b69688..24a11528c0 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -120,7 +120,7 @@ public: /// int getMaxWidth(Painter & pain, UpdatableInset const *) const; /// - LyXText * getLyXText(BufferView const *) const; + LyXText * getLyXText(BufferView const *, bool const recursive) const; /// void deleteLyXText(BufferView *, bool recursive=true) const; /// diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index e1fc2a2305..e3bbc85627 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1241,7 +1241,6 @@ void InsetTabular::resetPos(BufferView * bv) const (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) { int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv); - printf("%d\n", xx); if (xx > (bv->workWidth()-20)) scroll(bv, -(xx - bv->workWidth() + 60)); else if (xx < 20) { @@ -1828,11 +1827,11 @@ void InsetTabular::resizeLyXText(BufferView *) const } -LyXText * InsetTabular::getLyXText(BufferView const * bv) const +LyXText * InsetTabular::getLyXText(BufferView const * bv, bool const recursive) const { if (the_locking_inset) - return the_locking_inset->getLyXText(bv); - return Inset::getLyXText(bv); + return the_locking_inset->getLyXText(bv, recursive); + return Inset::getLyXText(bv, recursive); } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index d6f87f2dfb..7648b2b1e9 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -166,7 +166,7 @@ public: /// Buffer * BufferOwner() const { return const_cast(buffer); } /// - LyXText * getLyXText(BufferView const *) const; + LyXText * getLyXText(BufferView const *, bool const recursive = false) const; /// void resizeLyXText(BufferView *) const; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 38bfe81a2e..da82a432cb 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -313,7 +313,6 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, return; if (top_x != int(x)) { -// printf("InsetText::draw1 -> INIT(%d)\n",insetWidth); need_update = INIT; top_x = int(x); bv->text->status = LyXText::CHANGED_IN_DRAW; @@ -350,7 +349,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, if (y_offset < 0) y_offset = y; TEXT(bv)->first = first; - if (cleared || !locked || (need_update==FULL) || (need_update==INIT)) { + if (cleared || !locked || (need_update&FULL) || (need_update&INIT)) { int yf = y_offset; y = 0; while ((row != 0) && (yf < ph)) { @@ -360,13 +359,13 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, yf += row->height(); row = row->next(); } - } else if (need_update == SELECTION) { - bv->screen()->ToggleToggle(TEXT(bv), bv, y_offset, int(x)); } else { locked = false; - if (need_update == CURSOR) { + if (need_update & SELECTION) + bv->screen()->ToggleToggle(TEXT(bv), bv, y_offset, int(x)); + else if (need_update & CURSOR) { bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x)); - TEXT(bv)->ClearSelection(); + TEXT(bv)->ClearSelection(bv); TEXT(bv)->sel_cursor = TEXT(bv)->cursor; } bv->screen()->Update(TEXT(bv), bv, y_offset, int(x)); @@ -381,18 +380,15 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, pain.rectangle(top_x + 1, baseline - insetAscent + 1, width(bv, f) - 1, insetAscent + insetDescent - 1, frame_color); - } else if (need_update == CLEAR_FRAME) { + } else if (need_update & CLEAR_FRAME) { pain.rectangle(top_x + 1, baseline - insetAscent + 1, width(bv, f) - 1, insetAscent + insetDescent - 1, LColor::background); } x += width(bv, f) - TEXT_TO_INSET_OFFSET; - if (bv->text->status==LyXText::CHANGED_IN_DRAW) - { + if (bv->text->status==LyXText::CHANGED_IN_DRAW) { need_update = INIT; -// printf("InsetText::draw2 -> INIT(%d)\n",insetWidth); - } - else if (need_update != INIT) + } else if (need_update != INIT) need_update = NONE; } @@ -450,25 +446,20 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit) TEXT_TO_INSET_OFFSET; } -void InsetText::SetUpdateStatus(BufferView * bv, UpdateCodes what) +void InsetText::SetUpdateStatus(BufferView * bv, int what) { + need_update |= what; if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH) - need_update = FULL; - if (what > need_update) - need_update = what; + need_update |= FULL; + // 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, UpdateCodes what, bool mark_dirty) +void InsetText::UpdateLocal(BufferView * bv, int what, bool mark_dirty) { -// if (what == INIT) -// printf("InsetText::UpdateLocal -> INIT(%d)\n",insetWidth); TEXT(bv)->FullRebreak(bv); - if (need_update != INIT) { - if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH) - need_update = FULL; - else if (!the_locking_inset || (what != CURSOR)) - need_update = what; - } + SetUpdateStatus(bv, what); if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) || TEXT(bv)->selection) bv->updateInset(this, mark_dirty); @@ -528,8 +519,7 @@ void InsetText::InsetUnlock(BufferView * bv) HideInsetCursor(bv); no_selection = false; locked = false; - TEXT(bv)->selection = 0; - UpdateLocal(bv, CLEAR_FRAME, false); + UpdateLocal(bv, CLEAR_FRAME|CURSOR, false); if (owner()) bv->owner()->setLayout(owner()->getLyXText(bv) ->cursor.par()->GetLayout()); @@ -551,7 +541,13 @@ bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset) inset_pos = cpos(bv); inset_par = cpar(bv); inset_boundary = cboundary(bv); +#if 0 + TEXT(bv)->ClearSelection(bv); + TEXT(bv)->sel_cursor = TEXT(bv)->cursor; TEXT(bv)->UpdateInset(bv, the_locking_inset); +#else + UpdateLocal(bv, CURSOR, false); +#endif return true; } else if (the_locking_inset && (the_locking_inset == inset)) { if (cpar(bv) == inset_par && cpos(bv) == inset_pos) { @@ -595,7 +591,7 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset) return false; if (the_locking_inset != inset) { TEXT(bv)->UpdateInset(bv, the_locking_inset); - need_update = CURSOR_PAR; + SetUpdateStatus(bv, CURSOR_PAR); return the_locking_inset->UpdateInsetInInset(bv, inset); } // UpdateLocal(bv, FULL, false); @@ -611,7 +607,7 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset) void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) { - no_selection = false; + no_selection = true; int tmp_x = x - drawTextXOffset; int tmp_y = y + insetAscent - TEXT(bv)->first; @@ -621,6 +617,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) if (the_locking_inset) { if (the_locking_inset == inset) { the_locking_inset->InsetButtonPress(bv,x-inset_x,y-inset_y,button); + no_selection = false; return; } else if (inset) { // otherwise unlock the_locking_inset and lock the new inset @@ -630,9 +627,9 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) the_locking_inset = static_cast(inset); inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button); inset->Edit(bv, x - inset_x, y - inset_y, button); - if (the_locking_inset) { - UpdateLocal(bv, CURSOR_PAR, false); - } + if (the_locking_inset) + UpdateLocal(bv, CURSOR, false); + no_selection = false; return; } // otherwise only unlock the_locking_inset @@ -650,10 +647,9 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) the_locking_inset = uinset; uinset->InsetButtonPress(bv, x - inset_x, y - inset_y, button); uinset->Edit(bv, x - inset_x, y - inset_y, 0); -// TEXT(bv)->ClearSelection(); - if (the_locking_inset) { - UpdateLocal(bv, CURSOR_PAR, false); - } + if (the_locking_inset) + UpdateLocal(bv, CURSOR, false); + no_selection = false; return; } } @@ -680,6 +676,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) } } ShowInsetCursor(bv); + no_selection = false; } @@ -711,22 +708,21 @@ void InsetText::InsetButtonRelease(BufferView * bv, int x, int y, int button) void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int state) { + if (no_selection) + return; if (the_locking_inset) { the_locking_inset->InsetMotionNotify(bv, x - inset_x, y - inset_y,state); return; } - if (!no_selection) { - HideInsetCursor(bv); - TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset, - y+insetAscent); - TEXT(bv)->SetSelection(bv); - if (TEXT(bv)->toggle_cursor.par()!=TEXT(bv)->toggle_end_cursor.par() || - TEXT(bv)->toggle_cursor.pos()!=TEXT(bv)->toggle_end_cursor.pos()) - UpdateLocal(bv, SELECTION, false); - ShowInsetCursor(bv); - } - no_selection = false; + HideInsetCursor(bv); + TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset, + y+insetAscent); + TEXT(bv)->SetSelection(bv); + if (TEXT(bv)->toggle_cursor.par()!=TEXT(bv)->toggle_end_cursor.par() || + TEXT(bv)->toggle_cursor.pos()!=TEXT(bv)->toggle_end_cursor.pos()) + UpdateLocal(bv, SELECTION, false); + ShowInsetCursor(bv); } @@ -815,7 +811,8 @@ InsetText::LocalDispatch(BufferView * bv, TEXT(bv)->CutSelection(bv, false); } } - TEXT(bv)->ClearSelection(); + TEXT(bv)->ClearSelection(bv); + TEXT(bv)->sel_cursor = TEXT(bv)->cursor; for (string::size_type i = 0; i < arg.length(); ++i) { if (greek_kb_flag) { if (!math_insert_greek(bv, arg[i])) { @@ -841,7 +838,6 @@ InsetText::LocalDispatch(BufferView * bv, case LFUN_RIGHT: result = moveRight(bv); bv->text->FinishUndo(); - TEXT(bv)->ClearSelection(); UpdateLocal(bv, CURSOR, false); break; case LFUN_LEFTSEL: @@ -853,7 +849,6 @@ InsetText::LocalDispatch(BufferView * bv, case LFUN_LEFT: bv->text->FinishUndo(); result = moveLeft(bv); - TEXT(bv)->ClearSelection(); UpdateLocal(bv, CURSOR, false); break; case LFUN_DOWNSEL: @@ -865,8 +860,6 @@ InsetText::LocalDispatch(BufferView * bv, case LFUN_DOWN: bv->text->FinishUndo(); result = moveDown(bv); - TEXT(bv)->ClearSelection(); - TEXT(bv)->sel_cursor = TEXT(bv)->cursor; UpdateLocal(bv, CURSOR, false); break; case LFUN_UPSEL: @@ -878,21 +871,15 @@ InsetText::LocalDispatch(BufferView * bv, case LFUN_UP: bv->text->FinishUndo(); result = moveUp(bv); - TEXT(bv)->ClearSelection(); - TEXT(bv)->sel_cursor = TEXT(bv)->cursor; UpdateLocal(bv, CURSOR, false); break; case LFUN_HOME: bv->text->FinishUndo(); TEXT(bv)->CursorHome(bv); - TEXT(bv)->ClearSelection(); - TEXT(bv)->sel_cursor = TEXT(bv)->cursor; UpdateLocal(bv, CURSOR, false); break; case LFUN_END: TEXT(bv)->CursorEnd(bv); - TEXT(bv)->ClearSelection(); - TEXT(bv)->sel_cursor = TEXT(bv)->cursor; UpdateLocal(bv, CURSOR, false); break; case LFUN_BACKSPACE: @@ -1338,9 +1325,8 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset) (cpar(bv)->GetInset(cpos(bv)) != inset)) TEXT(bv)->CursorLeft(bv); #endif - TEXT(bv)->selection = 0; bv->fitCursor(TEXT(bv)); - UpdateLocal(bv, CURSOR_PAR, true); + UpdateLocal(bv, CURSOR_PAR|CURSOR, true); ShowInsetCursor(bv); return true; } @@ -1573,18 +1559,23 @@ Row * InsetText::crow(BufferView * bv) const } -LyXText * InsetText::getLyXText(BufferView const * lbv) const +LyXText * InsetText::getLyXText(BufferView const * lbv, bool const recursive) const { // Super UGLY! (Lgb) BufferView * bv = const_cast(lbv); - if ((cache.find(bv) != cache.end()) && cache[bv]) + if ((cache.find(bv) != cache.end()) && cache[bv]) { + if (recursive && the_locking_inset) + return the_locking_inset->getLyXText(bv); return cache[bv]; + } LyXText * lt = new LyXText(const_cast(this)); lt->init(bv); cache[bv] = lt; if (the_locking_inset) { lt->SetCursor(bv, inset_par, inset_pos, true, inset_boundary); + if (recursive) + return the_locking_inset->getLyXText(bv); } return lt; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index f63c4f49f4..b5c8bd4eb4 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -50,15 +50,15 @@ public: /// CLEAR_FRAME = 2, /// - DRAW_FRAME = 3, + DRAW_FRAME = 4, /// - SELECTION = 4, + SELECTION = 8, /// - CURSOR_PAR = 5, + CURSOR_PAR = 16, /// - FULL = 6, + FULL = 32, /// - INIT = 7 + INIT = 64 }; /// enum DrawFrame { @@ -99,7 +99,7 @@ public: /// void update(BufferView *, LyXFont const &, bool =false); /// - void SetUpdateStatus(BufferView *, UpdateCodes); + void SetUpdateStatus(BufferView *, int what); /// string const EditMessage() const; /// @@ -170,7 +170,7 @@ public: /// void SetFrameColor(BufferView *, LColor::color); /// - LyXText * getLyXText(BufferView const *) const; + LyXText * getLyXText(BufferView const *, bool const recursive=false) const; /// void deleteLyXText(BufferView *, bool recursive=true) const; /// @@ -178,11 +178,11 @@ public: /// LyXParagraph * par; /// - mutable UpdateCodes need_update; + mutable int need_update; protected: /// - void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty); + void UpdateLocal(BufferView *, int what, bool mark_dirty); /// mutable int drawTextXOffset; /// diff --git a/src/insets/lyxinset.h b/src/insets/lyxinset.h index 9e1136089d..ae6a873a55 100644 --- a/src/insets/lyxinset.h +++ b/src/insets/lyxinset.h @@ -227,7 +227,7 @@ public: // because we could have fake text insets and have to call this // inside them without cast!!! /// - virtual LyXText * getLyXText(BufferView const *) const; + virtual LyXText * getLyXText(BufferView const *, bool const recursive=false) const; /// virtual void deleteLyXText(BufferView *, bool = true) const {} /// diff --git a/src/lyxfr1.C b/src/lyxfr1.C index 883448250a..f6d575f742 100644 --- a/src/lyxfr1.C +++ b/src/lyxfr1.C @@ -168,7 +168,7 @@ void LyXFindReplace::SearchReplaceAllCB() bv->hideCursor(); // start at top - bv->text->ClearSelection(); + bv->text->ClearSelection(bv); bv->text->CursorTop(bv); int replace_count = 0; @@ -226,7 +226,7 @@ bool LyXFindReplace::SearchCB(bool fForward) // clear the selection (if there is any) bv->toggleSelection(); - bv->text->ClearSelection(); + bv->text->ClearSelection(bv); // set the new selection SetSelectionOverLenChars(bv, iLenSelected); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index a21c3e84d5..8449d40b65 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -114,7 +114,6 @@ extern void ShowLatexLog(); bool LyXFunc::show_sc = true; - LyXFunc::LyXFunc(LyXView * o) : owner(o) { @@ -124,6 +123,13 @@ LyXFunc::LyXFunc(LyXView * o) setupLocalKeymap(); } +inline +LyXText * LyXFunc::TEXT(bool flag=true) const +{ + if (flag) + return owner->view()->text; + return owner->view()->getLyXText(); +} // I changed this func slightly. I commented out the ...FinishUndo(), // this means that all places that used to have a moveCursorUpdate, now @@ -131,14 +137,14 @@ LyXFunc::LyXFunc(LyXView * o) // a moveCursorUpdate to some of the functions that updated the cursor, but // that did not show its new position. inline -void LyXFunc::moveCursorUpdate(LyXText * text, bool selecting) +void LyXFunc::moveCursorUpdate(bool flag, bool selecting) { - if (selecting || text->mark_set) { - text->SetSelection(owner->view()); - if (text->bv_owner) + if (selecting || TEXT(flag)->mark_set) { + TEXT(flag)->SetSelection(owner->view()); + if (TEXT(flag)->bv_owner) owner->view()->toggleToggle(); } - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); + owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR); owner->view()->showCursor(); /* ---> Everytime the cursor is moved, show the current font state. */ @@ -176,8 +182,8 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) if (tli && (keysym == XK_Escape)) { if (tli == tli->GetLockingInset()) { owner->view()->unlockInset(tli); - owner->view()->text->CursorRight(owner->view()); - moveCursorUpdate(owner->view()->text, false); + TEXT()->CursorRight(owner->view()); + moveCursorUpdate(true, false); owner->showState(); } else { tli->UnlockInsetInInset(owner->view(), @@ -449,7 +455,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const if (buf) { func_status box = LyXFunc::ToggleOff; LyXFont const & font = - owner->view()->getLyXText()->real_current_font; + TEXT(false)->real_current_font; switch (action) { case LFUN_EMPH: if (font.emph() == LyXFont::ON) @@ -520,9 +526,6 @@ string const LyXFunc::Dispatch(int ac, if (owner->view()->available()) owner->view()->hideCursor(); - // We have to do this heare because of te goto below. (Lgb) - LyXText * text = owner->view()->getLyXText(); - // We cannot use this function here if (getStatus(ac) & Disabled) goto exit_with_message; @@ -593,11 +596,11 @@ string const LyXFunc::Dispatch(int ac, inset->GetCursorPos(owner->view(), slx, sly); owner->view()->unlockInset(inset); owner->view()->menuUndo(); - if (owner->view()->text->cursor.par()-> - IsInset(owner->view()->text->cursor.pos())) { + if (TEXT()->cursor.par()-> + IsInset(TEXT()->cursor.pos())) { inset = static_cast( - owner->view()->text->cursor.par()-> - GetInset(owner->view()->text-> + TEXT()->cursor.par()-> + GetInset(TEXT()-> cursor.pos())); } else { inset = 0; @@ -614,8 +617,8 @@ string const LyXFunc::Dispatch(int ac, owner->view()->unlockInset(inset); owner->view()->menuRedo(); inset = static_cast( - owner->view()->text->cursor.par()-> - GetInset(owner->view()->text-> + TEXT()->cursor.par()-> + GetInset(TEXT()-> cursor.pos())); if (inset) inset->Edit(owner->view(),slx,sly,0); @@ -632,27 +635,27 @@ string const LyXFunc::Dispatch(int ac, case LFUN_UNKNOWN_ACTION: case LFUN_BREAKPARAGRAPH: case LFUN_BREAKLINE: - owner->view()->text->CursorRight(owner->view()); + TEXT()->CursorRight(owner->view()); owner->view()->setState(); owner->showState(); break; case LFUN_RIGHT: - if (!owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { - owner->view()->text->CursorRight(owner->view()); - moveCursorUpdate(owner->view()->text, false); + if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { + TEXT()->CursorRight(owner->view()); + moveCursorUpdate(true, false); owner->showState(); } return string(); case LFUN_LEFT: - if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { - owner->view()->text->CursorRight(owner->view()); - moveCursorUpdate(owner->view()->text, false); + if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { + TEXT()->CursorRight(owner->view()); + moveCursorUpdate(true, false); owner->showState(); } return string(); case LFUN_DOWN: - owner->view()->text->CursorDown(owner->view()); - moveCursorUpdate(owner->view()->text, false); + TEXT()->CursorDown(owner->view()); + moveCursorUpdate(true, false); owner->showState(); return string(); default: @@ -676,26 +679,24 @@ string const LyXFunc::Dispatch(int ac, searched_string = last_search; } - LyXText * ltCur = owner->view()->text ; - if (!searched_string.empty() && ((action == LFUN_WORDFINDBACKWARD) ? - ltCur->SearchBackward(owner->view(), searched_string) : - ltCur->SearchForward(owner->view(), searched_string))) { + TEXT()->SearchBackward(owner->view(), searched_string) : + TEXT()->SearchForward(owner->view(), searched_string))) { // ??? What is that ??? - owner->view()->update(ltCur, BufferView::SELECT|BufferView::FITCUR); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); // ??? Needed ??? // clear the selection (if there is any) owner->view()->toggleSelection(); - owner->view()->text->ClearSelection(); + TEXT()->ClearSelection(owner->view()); // Move cursor so that successive C-s 's will not stand in place. if (action == LFUN_WORDFINDFORWARD ) - owner->view()->text->CursorRightOneWord(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + TEXT()->CursorRightOneWord(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); // ??? Needed ??? // set the new selection @@ -711,7 +712,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_PREFIX: { if (owner->view()->available()) { - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); } string buf; @@ -758,8 +759,8 @@ string const LyXFunc::Dispatch(int ac, case LFUN_APPENDIX: if (owner->view()->available()) { - text->toggleAppendix(owner->view()); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + TEXT(false)->toggleAppendix(owner->view()); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } break; @@ -966,7 +967,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_REMOVEERRORS: if (owner->view()->removeAutoInsets()) { owner->view()->redraw(); - owner->view()->fitCursor(owner->view()->text); + owner->view()->fitCursor(TEXT()); } break; @@ -1010,15 +1011,15 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_DEPTH: - changeDepth(owner->view(), text, 0); + changeDepth(owner->view(), TEXT(false), 0); break; case LFUN_DEPTH_MIN: - changeDepth(owner->view(), text, -1); + changeDepth(owner->view(), TEXT(false), -1); break; case LFUN_DEPTH_PLUS: - changeDepth(owner->view(), text, 1); + changeDepth(owner->view(), TEXT(false), 1); break; case LFUN_FREE: @@ -1043,11 +1044,11 @@ string const LyXFunc::Dispatch(int ac, #ifndef NEW_INSETS case LFUN_FOOTMELT: if (owner->view()->available() - && !owner->view()->text->selection - && owner->view()->text->cursor.par()->footnoteflag + && !TEXT()->selection + && TEXT()->cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) { // only melt footnotes with FOOTMELT, not margins etc - if (owner->view()->text->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE) + if (TEXT()->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE) Melt(owner->view()); } else @@ -1057,11 +1058,11 @@ string const LyXFunc::Dispatch(int ac, case LFUN_MARGINMELT: if (owner->view()->available() - && !owner->view()->text->selection - && owner->view()->text->cursor.par()->footnoteflag + && !TEXT()->selection + && TEXT()->cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) { // only melt margins - if (owner->view()->text->cursor.par()->footnotekind == LyXParagraph::MARGIN) + if (TEXT()->cursor.par()->footnotekind == LyXParagraph::MARGIN) Melt(owner->view()); } else Margin(owner->view()); @@ -1256,12 +1257,12 @@ string const LyXFunc::Dispatch(int ac, if (current_layout != layout.second) { owner->view()->hideCursor(); current_layout = layout.second; - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text-> + TEXT()-> SetLayout(owner->view(), layout.second); owner->setLayout(layout.second); - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); owner->view()->setState(); } @@ -1367,28 +1368,28 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_UPCASE_WORD: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->ChangeWordCase(owner->view(), LyXText::text_uppercase); - if (text->inset_owner) - owner->view()->updateInset(text->inset_owner, true); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->ChangeWordCase(owner->view(), LyXText::text_uppercase); + if (TEXT(false)->inset_owner) + owner->view()->updateInset(TEXT(false)->inset_owner, true); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); break; case LFUN_LOWCASE_WORD: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->ChangeWordCase(owner->view(), LyXText::text_lowercase); - if (text->inset_owner) - owner->view()->updateInset(text->inset_owner, true); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->ChangeWordCase(owner->view(), LyXText::text_lowercase); + if (TEXT(false)->inset_owner) + owner->view()->updateInset(TEXT(false)->inset_owner, true); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); break; case LFUN_CAPITALIZE_WORD: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->ChangeWordCase(owner->view(), + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->ChangeWordCase(owner->view(), LyXText::text_capitalization); - if (text->inset_owner) - owner->view()->updateInset(text->inset_owner, true); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + if (TEXT(false)->inset_owner) + owner->view()->updateInset(TEXT(false)->inset_owner, true); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); break; case LFUN_INSERT_LABEL: @@ -1453,35 +1454,34 @@ string const LyXFunc::Dispatch(int ac, // --- Cursor Movements ----------------------------- case LFUN_RIGHT: { - LyXText * tmptext = owner->view()->text; - bool is_rtl = tmptext->cursor.par()->isRightToLeftPar(owner->buffer()->params); - if (!tmptext->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, BufferView::SELECT|BufferView::FITCUR); + bool is_rtl = TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params); + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); if (is_rtl) - tmptext->CursorLeft(owner->view(), false); - if (tmptext->cursor.pos() < tmptext->cursor.par()->Last() - && tmptext->cursor.par()->GetChar(tmptext->cursor.pos()) + TEXT()->CursorLeft(owner->view(), false); + if (TEXT()->cursor.pos() < TEXT()->cursor.par()->Last() + && TEXT()->cursor.par()->GetChar(TEXT()->cursor.pos()) == LyXParagraph::META_INSET - && tmptext->cursor.par()->GetInset(tmptext->cursor.pos()) - && tmptext->cursor.par()->GetInset(tmptext->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE){ - Inset * tmpinset = tmptext->cursor.par()->GetInset(tmptext->cursor.pos()); + && TEXT()->cursor.par()->GetInset(TEXT()->cursor.pos()) + && TEXT()->cursor.par()->GetInset(TEXT()->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE){ + Inset * tmpinset = TEXT()->cursor.par()->GetInset(TEXT()->cursor.pos()); setMessage(tmpinset->EditMessage()); int y = 0; if (is_rtl) { LyXFont font = - tmptext->GetFont(owner->view()->buffer(), - tmptext->cursor.par(), - tmptext->cursor.pos()); + TEXT()->GetFont(owner->view()->buffer(), + TEXT()->cursor.par(), + TEXT()->cursor.pos()); y = tmpinset->descent(owner->view(),font); } tmpinset->Edit(owner->view(), 0, y, 0); break; } if (!is_rtl) - tmptext->CursorRight(owner->view(), false); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + TEXT()->CursorRight(owner->view(), false); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); } break; @@ -1490,27 +1490,26 @@ string const LyXFunc::Dispatch(int ac, { // This is soooo ugly. Isn`t it possible to make // it simpler? (Lgb) - LyXText * txt = owner->view()->text; - bool is_rtl = txt->cursor.par()->isRightToLeftPar(owner->buffer()->params); - if (!txt->mark_set) - owner->view()->beforeChange(txt); - owner->view()->update(owner->view()->text, BufferView::SELECT|BufferView::FITCUR); - LyXCursor cur = txt->cursor; + bool is_rtl = TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params); + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); + LyXCursor cur = TEXT()->cursor; if (!is_rtl) - txt->CursorLeft(owner->view(), false); - if ((is_rtl || cur != txt->cursor) && // only if really moved! - txt->cursor.pos() < txt->cursor.par()->Last() && - (txt->cursor.par()->GetChar(txt->cursor.pos()) == + TEXT()->CursorLeft(owner->view(), false); + if ((is_rtl || cur != TEXT()->cursor) && // only if really moved! + TEXT()->cursor.pos() < TEXT()->cursor.par()->Last() && + (TEXT()->cursor.par()->GetChar(TEXT()->cursor.pos()) == LyXParagraph::META_INSET) && - txt->cursor.par()->GetInset(txt->cursor.pos()) && - (txt->cursor.par()->GetInset(txt->cursor.pos())->Editable() + TEXT()->cursor.par()->GetInset(TEXT()->cursor.pos()) && + (TEXT()->cursor.par()->GetInset(TEXT()->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE)) { - Inset * tmpinset = txt->cursor.par()->GetInset(txt->cursor.pos()); + Inset * tmpinset = TEXT()->cursor.par()->GetInset(TEXT()->cursor.pos()); setMessage(tmpinset->EditMessage()); - LyXFont font = txt->GetFont(owner->view()->buffer(), - txt->cursor.par(), - txt->cursor.pos()); + LyXFont font = TEXT()->GetFont(owner->view()->buffer(), + TEXT()->cursor.par(), + TEXT()->cursor.pos()); int y = is_rtl ? 0 : tmpinset->descent(owner->view(),font); tmpinset->Edit(owner->view(), @@ -1520,337 +1519,337 @@ string const LyXFunc::Dispatch(int ac, break; } if (is_rtl) - txt->CursorRight(owner->view(), false); + TEXT()->CursorRight(owner->view(), false); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); } break; case LFUN_UP: - if (!owner->view()->text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, BufferView::UPDATE); - owner->view()->text->CursorUp(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::UPDATE); + TEXT()->CursorUp(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); break; case LFUN_DOWN: - if (!owner->view()->text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, BufferView::UPDATE); - owner->view()->text->CursorDown(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::UPDATE); + TEXT()->CursorDown(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); break; case LFUN_UP_PARAGRAPH: - if (!owner->view()->text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, BufferView::UPDATE); - owner->view()->text->CursorUpParagraph(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::UPDATE); + TEXT()->CursorUpParagraph(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); break; case LFUN_DOWN_PARAGRAPH: - if (!owner->view()->text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, BufferView::UPDATE); - owner->view()->text->CursorDownParagraph(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::UPDATE); + TEXT()->CursorDownParagraph(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); break; case LFUN_PRIOR: - if (!text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, BufferView::UPDATE); - owner->view()->cursorPrevious(text); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, false); + if (!TEXT(false)->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::UPDATE); + owner->view()->cursorPrevious(TEXT(false)); + TEXT()->FinishUndo(); + moveCursorUpdate(false, false); owner->showState(); break; case LFUN_NEXT: - if (!text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, BufferView::UPDATE); - owner->view()->cursorNext(text); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, false); + if (!TEXT(false)->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::UPDATE); + owner->view()->cursorNext(TEXT(false)); + TEXT()->FinishUndo(); + moveCursorUpdate(false, false); owner->showState(); break; case LFUN_HOME: - if (!owner->view()->text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorHome(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); + TEXT()->CursorHome(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); break; case LFUN_END: - if (!owner->view()->text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorEnd(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + TEXT()->CursorEnd(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); break; case LFUN_SHIFT_TAB: case LFUN_TAB: - if (!owner->view()->text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorTab(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + TEXT()->CursorTab(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); break; case LFUN_WORDRIGHT: - if (!text->mark_set) - owner->view()->beforeChange(text); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - if (text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) - text->CursorLeftOneWord(owner->view()); + if (!TEXT(false)->mark_set) + owner->view()->beforeChange(TEXT(false)); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + if (TEXT(false)->cursor.par()->isRightToLeftPar(owner->buffer()->params)) + TEXT(false)->CursorLeftOneWord(owner->view()); else - text->CursorRightOneWord(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, false); + TEXT(false)->CursorRightOneWord(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(false, false); owner->showState(); break; case LFUN_WORDLEFT: - if (!text->mark_set) - owner->view()->beforeChange(text); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - if (text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) - text->CursorRightOneWord(owner->view()); + if (!TEXT(false)->mark_set) + owner->view()->beforeChange(TEXT(false)); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + if (TEXT(false)->cursor.par()->isRightToLeftPar(owner->buffer()->params)) + TEXT(false)->CursorRightOneWord(owner->view()); else - text->CursorLeftOneWord(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, false); + TEXT(false)->CursorLeftOneWord(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(false, false); owner->showState(); break; case LFUN_BEGINNINGBUF: - if (!owner->view()->text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorTop(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + TEXT()->CursorTop(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); break; case LFUN_ENDBUF: - if (!owner->view()->text->mark_set) - owner->view()->beforeChange(owner->view()->text); - owner->view()->update(owner->view()->text, + if (!TEXT()->mark_set) + owner->view()->beforeChange(TEXT()); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorBottom(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + TEXT()->CursorBottom(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); owner->showState(); break; /* cursor selection ---------------------------- */ case LFUN_RIGHTSEL: - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) - owner->view()->text->CursorLeft(owner->view()); + if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) + TEXT()->CursorLeft(owner->view()); else - owner->view()->text->CursorRight(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, true); + TEXT()->CursorRight(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, true); owner->showState(); break; case LFUN_LEFTSEL: - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) - owner->view()->text->CursorRight(owner->view()); + if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) + TEXT()->CursorRight(owner->view()); else - owner->view()->text->CursorLeft(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, true); + TEXT()->CursorLeft(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, true); owner->showState(); break; case LFUN_UPSEL: - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorUp(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, true); + TEXT()->CursorUp(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, true); owner->showState(); break; case LFUN_DOWNSEL: - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorDown(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, true); + TEXT()->CursorDown(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, true); owner->showState(); break; case LFUN_UP_PARAGRAPHSEL: - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorUpParagraph(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, true); + TEXT()->CursorUpParagraph(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, true); owner->showState(); break; case LFUN_DOWN_PARAGRAPHSEL: - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorDownParagraph(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, true); + TEXT()->CursorDownParagraph(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, true); owner->showState(); break; case LFUN_PRIORSEL: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - owner->view()->cursorPrevious(text); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, true); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + owner->view()->cursorPrevious(TEXT(false)); + TEXT()->FinishUndo(); + moveCursorUpdate(false, true); owner->showState(); break; case LFUN_NEXTSEL: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - owner->view()->cursorNext(text); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, true); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + owner->view()->cursorNext(TEXT(false)); + TEXT()->FinishUndo(); + moveCursorUpdate(false, true); owner->showState(); break; case LFUN_HOMESEL: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->CursorHome(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, true); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->CursorHome(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(false, true); owner->showState(); break; case LFUN_ENDSEL: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->CursorEnd(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, true); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->CursorEnd(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(false, true); owner->showState(); break; case LFUN_WORDRIGHTSEL: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - if (text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) - text->CursorLeftOneWord(owner->view()); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + if (TEXT(false)->cursor.par()->isRightToLeftPar(owner->buffer()->params)) + TEXT(false)->CursorLeftOneWord(owner->view()); else - text->CursorRightOneWord(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, true); + TEXT(false)->CursorRightOneWord(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(false, true); owner->showState(); break; case LFUN_WORDLEFTSEL: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) - text->CursorRightOneWord(owner->view()); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) + TEXT(false)->CursorRightOneWord(owner->view()); else - text->CursorLeftOneWord(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(text, true); + TEXT(false)->CursorLeftOneWord(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(false, true); owner->showState(); break; case LFUN_BEGINNINGBUFSEL: - if (text->inset_owner) + if (TEXT(false)->inset_owner) break; - owner->view()->update(owner->view()->text, BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorTop(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, true); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); + TEXT()->CursorTop(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, true); owner->showState(); break; case LFUN_ENDBUFSEL: - if (text->inset_owner) + if (TEXT(false)->inset_owner) break; - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); - owner->view()->text->CursorBottom(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, true); + TEXT()->CursorBottom(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, true); owner->showState(); break; // --- text changing commands ------------------------ case LFUN_BREAKLINE: - owner->view()->beforeChange(owner->view()->text); - owner->view()->text->InsertChar(owner->view(), LyXParagraph::META_NEWLINE); - owner->view()->update(owner->view()->text, + owner->view()->beforeChange(TEXT()); + TEXT()->InsertChar(owner->view(), LyXParagraph::META_NEWLINE); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - moveCursorUpdate(owner->view()->text, false); + moveCursorUpdate(true, false); break; case LFUN_PROTECTEDSPACE: { LyXLayout const & style = textclasslist.Style(owner->view()->buffer()->params.textclass, - text->cursor.par()->GetLayout()); + TEXT(false)->cursor.par()->GetLayout()); if (style.free_spacing) { - text->InsertChar(owner->view(), ' '); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + TEXT(false)->InsertChar(owner->view(), ' '); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } else { - owner->view()->protectedBlank(text); + owner->view()->protectedBlank(TEXT(false)); } - moveCursorUpdate(text, false); + moveCursorUpdate(false, false); } break; case LFUN_SETMARK: - if (text->mark_set) { - owner->view()->beforeChange(text); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); + if (TEXT(false)->mark_set) { + owner->view()->beforeChange(TEXT(false)); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); setMessage(N_("Mark removed")); } else { - owner->view()->beforeChange(text); - text->mark_set = 1; - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); + owner->view()->beforeChange(TEXT(false)); + TEXT(false)->mark_set = 1; + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); setMessage(N_("Mark set")); } - text->sel_cursor = text->cursor; + TEXT(false)->sel_cursor = TEXT(false)->cursor; break; case LFUN_DELETE: - if (!owner->view()->text->selection) { - owner->view()->text->Delete(owner->view()); - owner->view()->text->sel_cursor = - owner->view()->text->cursor; - owner->view()->update(owner->view()->text, + if (!TEXT()->selection) { + TEXT()->Delete(owner->view()); + TEXT()->sel_cursor = + TEXT()->cursor; + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); // It is possible to make it a lot faster still // just comment out the line below... @@ -1858,7 +1857,7 @@ string const LyXFunc::Dispatch(int ac, } else { owner->view()->cut(); } - moveCursorUpdate(owner->view()->text, false); + moveCursorUpdate(true, false); owner->showState(); owner->view()->setState(); break; @@ -1867,16 +1866,16 @@ string const LyXFunc::Dispatch(int ac, { // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP. - LyXCursor cursor = owner->view()->text->cursor; + LyXCursor cursor = TEXT()->cursor; - if (!owner->view()->text->selection) { + if (!TEXT()->selection) { if (cursor.pos() == cursor.par()->Last()) { - owner->view()->text->CursorRight(owner->view()); - cursor = owner->view()->text->cursor; + TEXT()->CursorRight(owner->view()); + cursor = TEXT()->cursor; if (cursor.pos() == 0 && !(cursor.par()->added_space_top == VSpace (VSpace::NONE))) { - owner->view()->text->SetParagraph + TEXT()->SetParagraph (owner->view(), cursor.par()->line_top, cursor.par()->line_bottom, @@ -1886,22 +1885,22 @@ string const LyXFunc::Dispatch(int ac, cursor.par()->added_space_bottom, cursor.par()->align, cursor.par()->labelwidthstring, 0); - owner->view()->text->CursorLeft(owner->view()); - owner->view()->update(owner->view()->text, + TEXT()->CursorLeft(owner->view()); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } else { - owner->view()->text->CursorLeft(owner->view()); - owner->view()->text->Delete(owner->view()); - owner->view()->text->sel_cursor = - owner->view()->text->cursor; - owner->view()->update(owner->view()->text, + TEXT()->CursorLeft(owner->view()); + TEXT()->Delete(owner->view()); + TEXT()->sel_cursor = + TEXT()->cursor; + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } } else { - owner->view()->text->Delete(owner->view()); - owner->view()->text->sel_cursor = - owner->view()->text->cursor; - owner->view()->update(owner->view()->text, + TEXT()->Delete(owner->view()); + TEXT()->sel_cursor = + TEXT()->cursor; + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } } else { @@ -1912,55 +1911,55 @@ string const LyXFunc::Dispatch(int ac, /* -------> Delete word forward. */ case LFUN_DELETE_WORD_FORWARD: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->DeleteWordForward(owner->view()); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - moveCursorUpdate(text, false); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->DeleteWordForward(owner->view()); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + moveCursorUpdate(false, false); owner->showState(); break; /* -------> Delete word backward. */ case LFUN_DELETE_WORD_BACKWARD: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->DeleteWordBackward(owner->view()); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - moveCursorUpdate(text, false); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->DeleteWordBackward(owner->view()); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + moveCursorUpdate(false, false); owner->showState(); break; /* -------> Kill to end of line. */ case LFUN_DELETE_LINE_FORWARD: - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->DeleteLineForward(owner->view()); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - moveCursorUpdate(text, false); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->DeleteLineForward(owner->view()); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + moveCursorUpdate(false, false); break; /* -------> Set mark off. */ case LFUN_MARK_OFF: - owner->view()->beforeChange(text); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->sel_cursor = text->cursor; + owner->view()->beforeChange(TEXT(false)); + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->sel_cursor = TEXT(false)->cursor; setMessage(N_("Mark off")); break; /* -------> Set mark on. */ case LFUN_MARK_ON: - owner->view()->beforeChange(text); - text->mark_set = 1; - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); - text->sel_cursor = text->cursor; + owner->view()->beforeChange(TEXT(false)); + TEXT(false)->mark_set = 1; + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR); + TEXT(false)->sel_cursor = TEXT(false)->cursor; setMessage(N_("Mark on")); break; case LFUN_BACKSPACE: { - if (!owner->view()->text->selection) { + if (!TEXT()->selection) { if (owner->getIntl()->getTrans().backspace()) { - owner->view()->text->Backspace(owner->view()); - owner->view()->text->sel_cursor = - owner->view()->text->cursor; - owner->view()->update(owner->view()->text, + TEXT()->Backspace(owner->view()); + TEXT()->sel_cursor = + TEXT()->cursor; + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); // It is possible to make it a lot faster still // just comment out the line below... @@ -1978,13 +1977,13 @@ string const LyXFunc::Dispatch(int ac, { // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP. - LyXCursor cursor = owner->view()->text->cursor; + LyXCursor cursor = TEXT()->cursor; - if (!owner->view()->text->selection) { + if (!TEXT()->selection) { if (cursor.pos() == 0 && !(cursor.par()->added_space_top == VSpace (VSpace::NONE))) { - owner->view()->text->SetParagraph + TEXT()->SetParagraph (owner->view(), cursor.par()->line_top, cursor.par()->line_bottom, @@ -1993,13 +1992,13 @@ string const LyXFunc::Dispatch(int ac, VSpace(VSpace::NONE), cursor.par()->added_space_bottom, cursor.par()->align, cursor.par()->labelwidthstring, 0); - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } else { - owner->view()->text->Backspace(owner->view()); - owner->view()->text->sel_cursor + TEXT()->Backspace(owner->view()); + TEXT()->sel_cursor = cursor; - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } } else @@ -2009,12 +2008,12 @@ string const LyXFunc::Dispatch(int ac, case LFUN_BREAKPARAGRAPH: { - owner->view()->beforeChange(owner->view()->text); - owner->view()->text->BreakParagraph(owner->view(), 0); - owner->view()->update(owner->view()->text, + owner->view()->beforeChange(TEXT()); + TEXT()->BreakParagraph(owner->view(), 0); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - owner->view()->text->sel_cursor = - owner->view()->text->cursor; + TEXT()->sel_cursor = + TEXT()->cursor; owner->view()->setState(); owner->showState(); break; @@ -2022,12 +2021,12 @@ string const LyXFunc::Dispatch(int ac, case LFUN_BREAKPARAGRAPHKEEPLAYOUT: { - owner->view()->beforeChange(owner->view()->text); - owner->view()->text->BreakParagraph(owner->view(), 1); - owner->view()->update(owner->view()->text, + owner->view()->beforeChange(TEXT()); + TEXT()->BreakParagraph(owner->view(), 1); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - owner->view()->text->sel_cursor = - owner->view()->text->cursor; + TEXT()->sel_cursor = + TEXT()->cursor; owner->view()->setState(); owner->showState(); break; @@ -2039,12 +2038,12 @@ string const LyXFunc::Dispatch(int ac, // indentation and add a "defskip" at the top. // Otherwise, do the same as LFUN_BREAKPARAGRAPH. - LyXCursor cursor = owner->view()->text->cursor; + LyXCursor cursor = TEXT()->cursor; - owner->view()->beforeChange(owner->view()->text); + owner->view()->beforeChange(TEXT()); if (cursor.pos() == 0) { if (cursor.par()->added_space_top == VSpace(VSpace::NONE)) { - owner->view()->text->SetParagraph + TEXT()->SetParagraph (owner->view(), cursor.par()->line_top, cursor.par()->line_bottom, @@ -2057,13 +2056,13 @@ string const LyXFunc::Dispatch(int ac, } } else { - owner->view()->text->BreakParagraph(owner->view(), 0); + TEXT()->BreakParagraph(owner->view(), 0); //owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - owner->view()->text->sel_cursor = cursor; + TEXT()->sel_cursor = cursor; owner->view()->setState(); owner->showState(); } @@ -2071,7 +2070,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_PARAGRAPH_SPACING: { - LyXParagraph * par = owner->view()->text->cursor.par(); + LyXParagraph * par = TEXT()->cursor.par(); Spacing::Space cur_spacing = par->spacing.getSpace(); float cur_value = 1.0; if (cur_spacing == Spacing::Other) { @@ -2108,18 +2107,18 @@ string const LyXFunc::Dispatch(int ac, } if (cur_spacing != new_spacing || cur_value != new_value) { par->spacing.set(new_spacing, new_value); - owner->view()->text->RedoParagraph(owner->view()); - owner->view()->update(owner->view()->text, + TEXT()->RedoParagraph(owner->view()); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } } break; case LFUN_QUOTE: - owner->view()->beforeChange(text); - text->InsertChar(owner->view(), '\"'); // This " matches the single quote in the code - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - moveCursorUpdate(text, false); + owner->view()->beforeChange(TEXT(false)); + TEXT(false)->InsertChar(owner->view(), '\"'); // This " matches the single quote in the code + owner->view()->update(TEXT(false), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + moveCursorUpdate(false, false); break; case LFUN_HTMLURL: @@ -2271,7 +2270,7 @@ string const LyXFunc::Dispatch(int ac, InsetTabular * new_inset = new InsetTabular(*owner->buffer(), r, c); bool rtl = - owner->view()->getLyXText()->real_current_font.isRightToLeft(); + TEXT(false)->real_current_font.isRightToLeft(); if (!owner->view()->open_new_inset(new_inset, rtl)) delete new_inset; } @@ -2282,12 +2281,12 @@ string const LyXFunc::Dispatch(int ac, case LFUN_CHARATCURSOR: { LyXParagraph::size_type pos = - owner->view()->text->cursor.pos(); - if (pos < owner->view()->text->cursor.par()->size()) - //dispatch_buffer = owner->view()->text-> + TEXT()->cursor.pos(); + if (pos < TEXT()->cursor.par()->size()) + //dispatch_buffer = TEXT()-> // cursor.par()->text[pos]; dispatch_buffer = - owner->view()->text-> + TEXT()-> cursor.par()->GetChar(pos); else dispatch_buffer = "EOF"; @@ -2296,8 +2295,8 @@ string const LyXFunc::Dispatch(int ac, case LFUN_GETXY: dispatch_buffer = - tostr(owner->view()->text->cursor.x()) + ' ' - + tostr(owner->view()->text->cursor.y()); + tostr(TEXT()->cursor.x()) + ' ' + + tostr(TEXT()->cursor.y()); break; case LFUN_SETXY: @@ -2305,18 +2304,18 @@ string const LyXFunc::Dispatch(int ac, int x; int y; ::sscanf(argument.c_str(), " %d %d", &x, &y); - owner->view()->text->SetCursorFromCoordinates(owner->view(), x, y); + TEXT()->SetCursorFromCoordinates(owner->view(), x, y); } break; case LFUN_GETLAYOUT: dispatch_buffer = - tostr(owner->view()->text->cursor.par()->layout); + tostr(TEXT()->cursor.par()->layout); break; case LFUN_GETFONT: { - LyXFont & font = owner->view()->text->current_font; + LyXFont & font = TEXT()->current_font; if (font.shape() == LyXFont::ITALIC_SHAPE) dispatch_buffer = 'E'; else if (font.shape() == LyXFont::SMALLCAPS_SHAPE) @@ -2329,7 +2328,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_GETLATEX: { - LyXFont & font = owner->view()->text->current_font; + LyXFont & font = TEXT()->current_font; if (font.latex() == LyXFont::ON) dispatch_buffer = 'L'; else @@ -2382,10 +2381,10 @@ string const LyXFunc::Dispatch(int ac, int id; istr >> id; - LyXParagraph * par = owner->view()->text->GetParFromID(id); + LyXParagraph * par = TEXT()->GetParFromID(id); // Set the cursor - owner->view()->text->SetCursor(owner->view(), par, 0); + TEXT()->SetCursor(owner->view(), par, 0); owner->view()->setState(); owner->showState(); @@ -2429,7 +2428,7 @@ string const LyXFunc::Dispatch(int ac, owner->getIntl()->getTrans() .deadkey(c, get_accent(action).accent, - owner->view()->text); + TEXT()); // Need to reset, in case the minibuffer calls these // actions @@ -2437,11 +2436,11 @@ string const LyXFunc::Dispatch(int ac, keyseq.length = 0; // copied verbatim from do_accent_char - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - owner->view()->text->sel_cursor = - owner->view()->text->cursor; + TEXT()->sel_cursor = + TEXT()->cursor; } break; @@ -2662,11 +2661,11 @@ string const LyXFunc::Dispatch(int ac, if (argument.empty()) { // Get the word immediately preceding the cursor LyXParagraph::size_type curpos = - owner->view()->text->cursor.pos() - 1; + TEXT()->cursor.pos() - 1; string curstring; if (curpos >= 0 ) - curstring = owner->view()->text + curstring = TEXT() ->cursor.par()->GetWord(curpos); p.setContents( curstring ); @@ -2695,11 +2694,11 @@ string const LyXFunc::Dispatch(int ac, { // Get word immediately preceding the cursor LyXParagraph::size_type curpos = - owner->view()->text->cursor.pos() - 1; + TEXT()->cursor.pos() - 1; // Can't do that at the beginning of a paragraph if (curpos < 0) break; - string const curstring(owner->view()->text + string const curstring(TEXT() ->cursor.par()->GetWord(curpos)); InsetCommandParams p("index", curstring); @@ -2800,8 +2799,8 @@ string const LyXFunc::Dispatch(int ac, setErrorMessage(N_("Unknown kind of footnote")); break; } - owner->view()->text->InsertFootnoteEnvironment(owner->view(), kind); - owner->view()->update(owner->view()->text, + TEXT()->InsertFootnoteEnvironment(owner->view(), kind); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); owner->view()->setState(); } @@ -2829,21 +2828,21 @@ string const LyXFunc::Dispatch(int ac, case LFUN_SELFINSERT: { - LyXFont const old_font(owner->view()->text->real_current_font); + LyXFont const old_font(TEXT()->real_current_font); for (string::size_type i = 0; i < argument.length(); ++i) { - owner->view()->text->InsertChar(owner->view(), argument[i]); + TEXT()->InsertChar(owner->view(), argument[i]); // This needs to be in the loop, or else we // won't break lines correctly. (Asger) - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } - owner->view()->text->sel_cursor = - owner->view()->text->cursor; - moveCursorUpdate(owner->view()->text, false); + TEXT()->sel_cursor = + TEXT()->cursor; + moveCursorUpdate(true, false); // real_current_font.number can change so we need to // update the minibuffer - if (old_font != owner->view()->text->real_current_font) + if (old_font != TEXT()->real_current_font) owner->showState(); } break; @@ -2875,13 +2874,13 @@ string const LyXFunc::Dispatch(int ac, int const datetmp_len = ::strftime(datetmp, 32, arg.c_str(), now_tm); for (int i = 0; i < datetmp_len; i++) { - owner->view()->text->InsertChar(owner->view(), datetmp[i]); - owner->view()->update(owner->view()->text, + TEXT()->InsertChar(owner->view(), datetmp[i]); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } - owner->view()->text->sel_cursor = owner->view()->text->cursor; - moveCursorUpdate(owner->view()->text, false); + TEXT()->sel_cursor = TEXT()->cursor; + moveCursorUpdate(true, false); } break; @@ -2957,35 +2956,35 @@ string const LyXFunc::Dispatch(int ac, * true (on). */ if (lyxrc.auto_region_delete) { - if (owner->view()->text->selection){ - owner->view()->text->CutSelection(owner->view(), false); - owner->view()->update(owner->view()->text, + if (TEXT()->selection){ + TEXT()->CutSelection(owner->view(), false); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } } - owner->view()->beforeChange(owner->view()->text); - LyXFont const old_font(owner->view()->text->real_current_font); + owner->view()->beforeChange(TEXT()); + LyXFont const old_font(TEXT()->real_current_font); for (string::size_type i = 0; i < argument.length(); ++i) { if (greek_kb_flag) { if (!math_insert_greek(owner->view(), argument[i])) - owner->getIntl()->getTrans().TranslateAndInsert(argument[i], owner->view()->text); + owner->getIntl()->getTrans().TranslateAndInsert(argument[i], TEXT()); } else - owner->getIntl()->getTrans().TranslateAndInsert(argument[i], owner->view()->text); + owner->getIntl()->getTrans().TranslateAndInsert(argument[i], TEXT()); } - owner->view()->update(owner->view()->text, + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - owner->view()->text->sel_cursor = - owner->view()->text->cursor; - moveCursorUpdate(owner->view()->text, false); + TEXT()->sel_cursor = + TEXT()->cursor; + moveCursorUpdate(true, false); // real_current_font.number can change so we need to // update the minibuffer - if (old_font != owner->view()->text->real_current_font) + if (old_font != TEXT()->real_current_font) owner->showState(); return string(); } else { @@ -3344,7 +3343,7 @@ void LyXFunc::CloseBuffer() Inset * LyXFunc::getInsetByCode(Inset::Code code) { - LyXCursor cursor = owner->view()->text->cursor; + LyXCursor cursor = TEXT()->cursor; Buffer * buffer = owner->view()->buffer(); Buffer::inset_iterator it = find_if(Buffer::inset_iterator(cursor.par(), diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 40226d5138..ca807c67c1 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -94,7 +94,7 @@ private: /// unsigned meta_fake_bit; /// - void moveCursorUpdate(LyXText *, bool selecting = false); + void moveCursorUpdate(bool flag = true, bool selecting = false); /// void setupLocalKeymap(); /// @@ -128,7 +128,12 @@ private: void CloseBuffer(); /// void reloadBuffer(); - /// This is the same for all lyxfunc objects + /// + // This return or directly text (default) of getLyXText() + /// + LyXText * TEXT(bool) const; + /// + // This is the same for all lyxfunc objects static bool show_sc; }; diff --git a/src/lyxtext.h b/src/lyxtext.h index a2092628ae..ed5dd4c804 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -235,7 +235,7 @@ public: /// need the selection cursor: void SetSelection(BufferView *); /// - void ClearSelection() const; + void ClearSelection(BufferView *) const; /// string const selectionAsString(Buffer const *) const; diff --git a/src/text.C b/src/text.C index 2964b22df4..e60dfb18a5 100644 --- a/src/text.C +++ b/src/text.C @@ -1895,7 +1895,7 @@ void LyXText::OpenFootnote(BufferView * bview) // Just a macro to make some thing easier. void LyXText::RedoParagraph(BufferView * bview) const { - ClearSelection(); + ClearSelection(bview); RedoParagraphs(bview, cursor, cursor.par()->Next()); SetCursorIntern(bview, cursor.par(), cursor.pos()); } @@ -4091,7 +4091,7 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview, SetCursor(bview, sel_start_cursor.par()->Next(), 0); - ClearSelection(); + ClearSelection(bview); } #endif diff --git a/src/text2.C b/src/text2.C index 8517d5a738..70b47c90a9 100644 --- a/src/text2.C +++ b/src/text2.C @@ -657,7 +657,7 @@ void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout) SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos(), false); UpdateCounters(bview, cursor.row()); - ClearSelection(); + ClearSelection(bview); SetSelection(bview); SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true); } @@ -775,7 +775,7 @@ void LyXText::IncDepth(BufferView * bview) sel_cursor = cursor; SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); UpdateCounters(bview, cursor.row()); - ClearSelection(); + ClearSelection(bview); SetSelection(bview); SetCursor(bview, tmpcursor.par(), tmpcursor.pos()); } @@ -852,7 +852,7 @@ void LyXText::DecDepth(BufferView * bview) sel_cursor = cursor; SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); UpdateCounters(bview, cursor.row()); - ClearSelection(); + ClearSelection(bview); SetSelection(bview); SetCursor(bview, tmpcursor.par(), tmpcursor.pos()); } @@ -934,7 +934,7 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall) SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos()); sel_cursor = cursor; SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); - ClearSelection(); + ClearSelection(bview); SetSelection(bview); SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true, tmpcursor.boundary()); @@ -1208,10 +1208,8 @@ string const LyXText::selectionAsString(Buffer const * buffer) const } -void LyXText::ClearSelection() const +void LyXText::ClearSelection(BufferView * bview) const { - if (selection) - status = LyXText::NEED_MORE_REFRESH; selection = false; mark_set = false; } @@ -1298,7 +1296,7 @@ void LyXText::ToggleFree(BufferView * bview, /* Implicit selections are cleared afterwards and cursor is set to the original position. */ if (implicitSelection) { - ClearSelection(); + ClearSelection(bview); cursor = resetCursor; SetCursor(bview, cursor.par(), cursor.pos()); sel_cursor = cursor; @@ -1327,7 +1325,7 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview) { LyXParagraph * tmppar, * firsttmppar; - ClearSelection(); + ClearSelection(bview); /* is is only allowed, if the cursor is IN an open footnote. * Otherwise it is too dangerous */ @@ -1413,7 +1411,7 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview) UpdateCounters(bview, row); - ClearSelection(); + ClearSelection(bview); } #endif @@ -1520,7 +1518,7 @@ void LyXText::SetParagraph(BufferView * bview, RedoParagraphs(bview, sel_start_cursor, endpar); - ClearSelection(); + ClearSelection(bview); SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos()); sel_cursor = cursor; SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); @@ -1610,7 +1608,7 @@ void LyXText::SetParagraphExtraOpt(BufferView * bview, int type, #endif } RedoParagraphs(bview, sel_start_cursor, endpar); - ClearSelection(); + ClearSelection(bview); SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos()); sel_cursor = cursor; SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); @@ -2281,7 +2279,7 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) RedoParagraphs(bview, sel_start_cursor, endpar); - ClearSelection(); + ClearSelection(bview); cursor = sel_start_cursor; SetCursor(bview, cursor.par(), cursor.pos()); sel_cursor = cursor; @@ -2369,7 +2367,7 @@ void LyXText::PasteSelection(BufferView * bview) RedoParagraphs(bview, cursor, endpar); SetCursor(bview, cursor.par(), cursor.pos()); - ClearSelection(); + ClearSelection(bview); sel_cursor = cursor; SetCursor(bview, actpar, pos); @@ -2509,7 +2507,7 @@ void LyXText::InsertStringA(BufferView * bview, string const & str) textclasslist.Style(bview->buffer()->params.textclass, cursor.par()->GetLayout()).isEnvironment(); // only to be sure, should not be neccessary - ClearSelection(); + ClearSelection(bview); // insert the string, don't insert doublespace string::size_type i = 0;