From a3148db9a40d144d0754434e40aad60d85d02f95 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Tue, 3 Oct 2000 13:55:48 +0000 Subject: [PATCH] Moved the_locking_inset form BufferView to LyXText (where it belongs!) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1075 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 15 ++++++++ src/BufferView.C | 1 - src/BufferView.h | 3 +- src/BufferView2.C | 56 +++++++++++++++++----------- src/BufferView_pimpl.C | 55 +++++++++++++-------------- src/bufferlist.C | 2 +- src/bufferview_funcs.C | 8 ++-- src/frontends/xforms/FormParagraph.C | 8 ++-- src/insets/inset.C | 2 +- src/insets/insettabular.C | 2 +- src/insets/insettext.C | 7 ++-- src/insets/insettext.h | 2 +- src/insets/lyxinset.h | 2 +- src/lyxfunc.C | 54 +++++++++++++-------------- src/lyxtext.h | 2 + src/mathed/formula.C | 2 +- src/mathed/formula.h | 2 +- src/mathed/math_symbols.C | 14 +++---- src/text2.C | 20 +++++----- 19 files changed, 145 insertions(+), 112 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23fc2ce91a..2f44366f77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2000-10-03 Juergen Vigna + + * various files: changed use of BufferView::the_locking_inset. + + * src/BufferView2.C (theLockingInset): + (theLockingInset): new functions. + + * src/BufferView.h: removed the_locking_inset. + + * src/lyxtext.h: added the_locking_inset + + * src/BufferView_pimpl.C (checkInsetHit): y_tmp form uint to int. + + * src/insets/lyxinset.h: added bool to ShowInsetCursor definition. + 2000-10-02 Angus Leeming * src/mathed/formula.C (IsMacro): declared but not referenced; removed. diff --git a/src/BufferView.C b/src/BufferView.C index 88cbba5f8f..5c31794885 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -27,7 +27,6 @@ BufferView::BufferView(LyXView * o, int xpos, int ypos, : pimpl_(new Pimpl(this, o, xpos, ypos, width, height)) { text = 0; - the_locking_inset = 0; inset_slept = false; } diff --git a/src/BufferView.h b/src/BufferView.h index e13893664a..e6bbd847c5 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -102,7 +102,8 @@ public: /// int workWidth() const; /// - UpdatableInset * the_locking_inset; + UpdatableInset * theLockingInset() const; + void theLockingInset(UpdatableInset const * inset); /// void updateInset(Inset * inset, bool mark_dirty); /// diff --git a/src/BufferView2.C b/src/BufferView2.C index 524a4f1001..5ec1a284de 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -202,9 +202,9 @@ bool BufferView::insertInset(Inset * inset, string const & lout, { // if we are in a locking inset we should try to insert the // inset there otherwise this is a illegal function now - if (the_locking_inset) { - if (the_locking_inset->InsertInsetAllowed(inset)) - return the_locking_inset->InsertInset(this, inset); + if (theLockingInset()) { + if (theLockingInset()->InsertInsetAllowed(inset)) + return theLockingInset()->InsertInset(this, inset); return false; } @@ -440,7 +440,7 @@ void BufferView::menuUndo() void BufferView::menuRedo() { - if (the_locking_inset) { + if (theLockingInset()) { owner()->getMiniBuffer()->Set(_("Redo not yet supported in math mode")); return; } @@ -716,11 +716,11 @@ void BufferView::replaceWord(string const & replacestring) bool BufferView::lockInset(UpdatableInset * inset) { - if (!the_locking_inset && inset) { - the_locking_inset = inset; + if (!theLockingInset() && inset) { + theLockingInset(inset); return true; } else if (inset) { - return the_locking_inset->LockInsetInInset(this, inset); + return theLockingInset()->LockInsetInInset(this, inset); } return false; } @@ -728,16 +728,16 @@ bool BufferView::lockInset(UpdatableInset * inset) void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc) { - if (the_locking_inset && available()) { + if (theLockingInset() && available()) { LyXCursor cursor = text->cursor; if ((cursor.pos() - 1 >= 0) && (cursor.par()->GetChar(cursor.pos() - 1) == LyXParagraph::META_INSET) && (cursor.par()->GetInset(cursor.pos() - 1) == - the_locking_inset->GetLockingInset())) + theLockingInset()->GetLockingInset())) text->SetCursor(this, cursor, cursor.par(), cursor.pos() - 1); - y += cursor.y() + the_locking_inset->InsetInInsetY(); + y += cursor.y() + theLockingInset()->InsetInInsetY(); pimpl_->screen_->ShowManualCursor(text, x, y, asc, desc, LyXScreen::BAR_SHAPE); } @@ -746,7 +746,7 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc) void BufferView::hideLockedInsetCursor() { - if (the_locking_inset && available()) { + if (theLockingInset() && available()) { pimpl_->screen_->HideCursor(); } } @@ -754,8 +754,8 @@ void BufferView::hideLockedInsetCursor() void BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc) { - if (the_locking_inset && available()){ - y += text->cursor.y() + the_locking_inset->InsetInInsetY(); + if (theLockingInset() && available()){ + y += text->cursor.y() + theLockingInset()->InsetInInsetY(); if (pimpl_->screen_->FitManualCursor(text, x, y, asc, desc)) updateScrollbar(); } @@ -764,13 +764,13 @@ void BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc) int BufferView::unlockInset(UpdatableInset * inset) { - if (inset && the_locking_inset == inset) { + if (inset && theLockingInset() == inset) { inset->InsetUnlock(this); - the_locking_inset = 0; + theLockingInset(0); text->FinishUndo(); return 0; - } else if (inset && the_locking_inset && - the_locking_inset->UnlockInsetInInset(this, inset)) { + } else if (inset && theLockingInset() && + theLockingInset()->UnlockInsetInInset(this, inset)) { text->FinishUndo(); return 0; } @@ -780,7 +780,7 @@ int BufferView::unlockInset(UpdatableInset * inset) void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind) { - if (!the_locking_inset) + if (!theLockingInset()) return; // shouldn't happen if (kind == Undo::EDIT) // in this case insets would not be stored! kind = Undo::FINISH; @@ -804,8 +804,8 @@ void BufferView::updateInset(Inset * inset, bool mark_dirty) return; // first check for locking insets - if (the_locking_inset) { - if (the_locking_inset == inset) { + if (theLockingInset()) { + if (theLockingInset() == inset) { if (text->UpdateInset(this, inset)){ update(); if (mark_dirty){ @@ -817,8 +817,8 @@ void BufferView::updateInset(Inset * inset, bool mark_dirty) updateScrollbar(); return; } - } else if (the_locking_inset->UpdateInsetInInset(this,inset)) { - if (text->UpdateInset(this, the_locking_inset)) { + } else if (theLockingInset()->UpdateInsetInInset(this,inset)) { + if (text->UpdateInset(this, theLockingInset())) { update(); if (mark_dirty){ if (buffer()->isLyxClean()) @@ -892,3 +892,15 @@ bool BufferView::ChangeRefs(string const & from, string const & to) text->SetCursorIntern(this, cursor.par(), cursor.pos()); return flag; } + + +UpdatableInset * BufferView::theLockingInset() const +{ + return text->the_locking_inset; +} + + +void BufferView::theLockingInset(UpdatableInset const * inset) +{ + text->the_locking_inset = inset; +} diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 36dbfa07c3..c50fbf5f1d 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -430,12 +430,13 @@ void BufferView::Pimpl::scrollCB(double value) LyXText * vbt = bv_->text; unsigned int height = vbt->DefaultHeight(); - if (vbt->cursor.y() < bv_->text->first + height) { + if (vbt->cursor.y() < (int)(bv_->text->first + height)) { vbt->SetCursorFromCoordinates(bv_, 0, bv_->text->first + height); } else if (vbt->cursor.y() > - bv_->text->first + workarea_->height() - height) { + (int)(bv_->text->first+workarea_->height()-height)) + { vbt->SetCursorFromCoordinates(bv_, 0, bv_->text->first + workarea_->height() - @@ -519,12 +520,12 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state) if (buffer_ == 0 || !screen_) return; // Check for inset locking - if (bv_->the_locking_inset) { + if (bv_->theLockingInset()) { LyXCursor cursor = bv_->text->cursor; - bv_->the_locking_inset-> + bv_->theLockingInset()-> InsetMotionNotify(bv_, x - cursor.x() - - bv_->the_locking_inset->scroll(), + bv_->theLockingInset()->scroll(), y - cursor.y() + bv_->text->first, state); return; @@ -572,19 +573,19 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, } } - if (bv_->the_locking_inset) { + if (bv_->theLockingInset()) { // We are in inset locking mode /* Check whether the inset was hit. If not reset mode, otherwise give the event to the inset */ - if (inset_hit == bv_->the_locking_inset) { - bv_->the_locking_inset-> + if (inset_hit == bv_->theLockingInset()) { + bv_->theLockingInset()-> InsetButtonPress(bv_, xpos, ypos, button); return; } else { - bv_->unlockInset(bv_->the_locking_inset); + bv_->unlockInset(bv_->theLockingInset()); } } @@ -657,7 +658,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) { // select a word - if (buffer_ && !bv_->the_locking_inset) { + if (buffer_ && !bv_->theLockingInset()) { if (screen_ && button == 1) { screen_->HideCursor(); screen_->ToggleSelection(bv_->text); @@ -674,7 +675,7 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button) { // select a line - if (buffer_ && screen_ && !bv_->the_locking_inset && (button == 1)) { + if (buffer_ && screen_ && !bv_->theLockingInset() && (button == 1)) { screen_->HideCursor(); screen_->ToggleSelection(bv_->text); bv_->text->CursorHome(bv_); @@ -717,13 +718,13 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, // inset, inset_hit is 0, and inset_x == x, inset_y == y. Inset * inset_hit = checkInsetHit(bv_->text, x, y, button); - if (bv_->the_locking_inset) { + if (bv_->theLockingInset()) { // We are in inset locking mode. /* LyX does a kind of work-area grabbing for insets. Only a ButtonPress Event outside the inset will force a InsetUnlock. */ - bv_->the_locking_inset-> + bv_->theLockingInset()-> InsetButtonRelease(bv_, x, y, button); return; } @@ -868,7 +869,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, if (!screen_) return 0; - unsigned int y_tmp = y + text->first; + int y_tmp = y + text->first; LyXCursor cursor; text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp); @@ -927,7 +928,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, && y_tmp > cursor.y() - tmpinset->ascent(bv_, font) && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) { #if 0 - if (move_cursor && (tmpinset != bv_->the_locking_inset)) + if (move_cursor && (tmpinset != bv_->theLockingInset())) #endif text->SetCursor(bv_, cursor.par(),cursor.pos()-1,true); x = x - start_x; @@ -1119,11 +1120,10 @@ void BufferView::Pimpl::cursorToggle() goto set_timer_and_return; } - if (!bv_->the_locking_inset) { + if (!bv_->theLockingInset()) { screen_->CursorToggle(bv_->text); } else { - bv_->the_locking_inset-> - ToggleInsetCursor(bv_); + bv_->theLockingInset()->ToggleInsetCursor(bv_); } set_timer_and_return: @@ -1245,9 +1245,9 @@ void BufferView::Pimpl::setState() void BufferView::Pimpl::insetSleep() { - if (bv_->the_locking_inset && !bv_->inset_slept) { - bv_->the_locking_inset->GetCursorPos(bv_, bv_->slx, bv_->sly); - bv_->the_locking_inset->InsetUnlock(bv_); + if (bv_->theLockingInset() && !bv_->inset_slept) { + bv_->theLockingInset()->GetCursorPos(bv_, bv_->slx, bv_->sly); + bv_->theLockingInset()->InsetUnlock(bv_); bv_->inset_slept = true; } } @@ -1255,8 +1255,8 @@ void BufferView::Pimpl::insetSleep() void BufferView::Pimpl::insetWakeup() { - if (bv_->the_locking_inset && bv_->inset_slept) { - bv_->the_locking_inset->Edit(bv_, bv_->slx, bv_->sly, 0); + if (bv_->theLockingInset() && bv_->inset_slept) { + bv_->theLockingInset()->Edit(bv_, bv_->slx, bv_->sly, 0); bv_->inset_slept = false; } } @@ -1264,9 +1264,10 @@ void BufferView::Pimpl::insetWakeup() void BufferView::Pimpl::insetUnlock() { - if (bv_->the_locking_inset) { - if (!bv_->inset_slept) bv_->the_locking_inset->InsetUnlock(bv_); - bv_->the_locking_inset = 0; + if (bv_->theLockingInset()) { + if (!bv_->inset_slept) + bv_->theLockingInset()->InsetUnlock(bv_); + bv_->theLockingInset(0); bv_->text->FinishUndo(); bv_->inset_slept = false; } @@ -1328,7 +1329,7 @@ void BufferView::Pimpl::toggleToggle() void BufferView::Pimpl::center() { beforeChange(); - if (bv_->text->cursor.y() > workarea_->height() / 2) { + if (bv_->text->cursor.y() > (int)(workarea_->height() / 2)) { screen_->Draw(bv_->text, bv_->text->cursor.y() - workarea_->height() / 2); } else { screen_->Draw(bv_->text, 0); diff --git a/src/bufferlist.C b/src/bufferlist.C index 677e92a3f0..92019c0de4 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -251,7 +251,7 @@ int BufferList::unlockInset(UpdatableInset * inset) for(BufferStorage::iterator it = bstore.begin(); it != bstore.end(); ++it) { if ((*it)->getUser() - && (*it)->getUser()->the_locking_inset == inset) { + && (*it)->getUser()->theLockingInset() == inset) { (*it)->getUser()->insetUnlock(); return 0; } diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 26073afe8d..ff4f699d48 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -249,8 +249,8 @@ string const CurrentState(BufferView * bv) // font. (Asger) LyXText *text = 0; - if (bv->the_locking_inset) - text = bv->the_locking_inset->getLyXText(bv); + if (bv->theLockingInset()) + text = bv->theLockingInset()->getLyXText(bv); if (!text) text = bv->text; @@ -305,8 +305,8 @@ void ToggleAndShow(BufferView * bv, LyXFont const & font) if (bv->available()) { bv->hideCursor(); bv->update(BufferView::SELECT|BufferView::FITCUR); - if (bv->the_locking_inset) - bv->the_locking_inset->SetFont(bv, font, toggleall); + if (bv->theLockingInset()) + bv->theLockingInset()->SetFont(bv, font, toggleall); else bv->text->ToggleFree(bv, font, toggleall); bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); diff --git a/src/frontends/xforms/FormParagraph.C b/src/frontends/xforms/FormParagraph.C index f75eb448c4..4395c61125 100644 --- a/src/frontends/xforms/FormParagraph.C +++ b/src/frontends/xforms/FormParagraph.C @@ -261,8 +261,8 @@ void FormParagraph::general_apply() noindent = fl_get_button(general_->check_noindent); LyXText * text = 0; - if (lv_->view()->the_locking_inset) - text = lv_->view()->the_locking_inset->getLyXText(lv_->view()); + if (lv_->view()->theLockingInset()) + text = lv_->view()->theLockingInset()->getLyXText(lv_->view()); if (!text) text = lv_->view()->text; text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top, @@ -326,8 +326,8 @@ void FormParagraph::general_update() Buffer * buf = lv_->view()->buffer(); LyXText * text = 0; - if (lv_->view()->the_locking_inset) - text = lv_->view()->the_locking_inset->getLyXText(lv_->view()); + if (lv_->view()->theLockingInset()) + text = lv_->view()->theLockingInset()->getLyXText(lv_->view()); if (!text) text = lv_->view()->text; diff --git a/src/insets/inset.C b/src/insets/inset.C index 77b969764d..aa1fadca81 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -132,7 +132,7 @@ void UpdatableInset::ToggleInsetCursor(BufferView *) } -void UpdatableInset::ShowInsetCursor(BufferView *) +void UpdatableInset::ShowInsetCursor(BufferView *, bool) { } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 8b00bf278d..7b44fc76a8 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -618,7 +618,7 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button) the_locking_inset->InsetUnlock(bv); } the_locking_inset = 0; - if (inset_hit && bv->the_locking_inset) { + if (inset_hit && bv->theLockingInset()) { if (ActivateCellInset(bv, x, y, button)) the_locking_inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button); diff --git a/src/insets/insettext.C b/src/insets/insettext.C index ddf5d153f9..e6bee21a06 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -592,7 +592,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) the_locking_inset->InsetUnlock(bv); the_locking_inset = 0; } - if (bv->the_locking_inset) { + if (bv->theLockingInset()) { if (inset && inset->Editable() == Inset::HIGHLY_EDITABLE) { UpdatableInset * uinset = static_cast(inset); inset_x = cx(bv) - top_x + drawTextXOffset; @@ -1109,7 +1109,7 @@ void InsetText::ToggleInsetCursor(BufferView * bv) } -void InsetText::ShowInsetCursor(BufferView * bv) +void InsetText::ShowInsetCursor(BufferView * bv, bool show) { if (the_locking_inset) { the_locking_inset->ShowInsetCursor(bv); @@ -1122,7 +1122,8 @@ void InsetText::ShowInsetCursor(BufferView * bv) int desc = lyxfont::maxDescent(font); bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc); - bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc); + if (show) + bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc); cursor_visible = true; } } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 0080b9894e..631582fddd 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -196,7 +196,7 @@ private: /// int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const; /// - void ShowInsetCursor(BufferView *); + void ShowInsetCursor(BufferView *, bool show=true); /// void HideInsetCursor(BufferView *); /// diff --git a/src/insets/lyxinset.h b/src/insets/lyxinset.h index 5a33df2bc7..0e50b02f49 100644 --- a/src/insets/lyxinset.h +++ b/src/insets/lyxinset.h @@ -304,7 +304,7 @@ public: /// may call ToggleLockedInsetCursor virtual void ToggleInsetCursor(BufferView *); /// - virtual void ShowInsetCursor(BufferView *); + virtual void ShowInsetCursor(BufferView *, bool show=true); /// virtual void HideInsetCursor(BufferView *); /// diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 22369a0ac4..87c4594042 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -192,7 +192,7 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) } // this function should be used always [asierra060396] - UpdatableInset * tli = owner->view()->the_locking_inset; + UpdatableInset * tli = owner->view()->theLockingInset(); if (owner->view()->available() && tli && (keysym == XK_Escape)) { if (tli == tli->GetLockingInset()) { owner->view()->unlockInset(tli); @@ -321,7 +321,7 @@ int LyXFunc::processKeyEvent(XEvent * ev) } // this function should be used always [asierra060396] - UpdatableInset * tli = owner->view()->the_locking_inset; + UpdatableInset * tli = owner->view()->theLockingInset(); if (owner->view()->available() && tli && (keysym_return==XK_Escape)) { if (tli == tli->GetLockingInset()) { owner->view()->unlockInset(tli); @@ -500,23 +500,23 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const case LFUN_LAYOUT_TABULAR: disable = true; - if (owner->view()->the_locking_inset) { - disable = (owner->view()->the_locking_inset->LyxCode() != Inset::TABULAR_CODE) && - !owner->view()->the_locking_inset->GetFirstLockingInsetOfType(Inset::TABULAR_CODE); + if (owner->view()->theLockingInset()) { + disable = (owner->view()->theLockingInset()->LyxCode() != Inset::TABULAR_CODE) && + !owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE); } break; case LFUN_TABULAR_FEATURE: disable = true; - if (owner->view()->the_locking_inset) { + if (owner->view()->theLockingInset()) { func_status ret = LyXFunc::Disabled; - if (owner->view()->the_locking_inset->LyxCode() == Inset::TABULAR_CODE) { + if (owner->view()->theLockingInset()->LyxCode() == Inset::TABULAR_CODE) { ret = static_cast - (owner->view()->the_locking_inset)-> + (owner->view()->theLockingInset())-> getStatus(argument); - } else if (owner->view()->the_locking_inset->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)) { + } else if (owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)) { ret = static_cast - (owner->view()->the_locking_inset-> + (owner->view()->theLockingInset()-> GetFirstLockingInsetOfType(Inset::TABULAR_CODE))-> getStatus(argument); } @@ -560,9 +560,9 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const if (buf) { func_status box = LyXFunc::ToggleOff; LyXFont font; - if (owner->view()->the_locking_inset && - owner->view()->the_locking_inset->getLyXText(owner->view())) - font = owner->view()->the_locking_inset-> + if (owner->view()->theLockingInset() && + owner->view()->theLockingInset()->getLyXText(owner->view())) + font = owner->view()->theLockingInset()-> getLyXText(owner->view())->real_current_font; else font = owner->view()->text->real_current_font; @@ -686,8 +686,8 @@ string const LyXFunc::Dispatch(int ac, } } - if (owner->view()->available() && owner->view()->the_locking_inset) { - text = owner->view()->the_locking_inset->getLyXText(owner->view()); + if (owner->view()->available() && owner->view()->theLockingInset()) { + text = owner->view()->theLockingInset()->getLyXText(owner->view()); UpdatableInset::RESULT result; if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) && (keyseq.length >= -1))) @@ -700,7 +700,7 @@ string const LyXFunc::Dispatch(int ac, int slx; int sly; UpdatableInset * inset = - owner->view()->the_locking_inset; + owner->view()->theLockingInset(); inset->GetCursorPos(owner->view(), slx, sly); owner->view()->unlockInset(inset); owner->view()->menuUndo(); @@ -720,7 +720,7 @@ string const LyXFunc::Dispatch(int ac, int slx; int sly; UpdatableInset * inset = owner->view()-> - the_locking_inset; + theLockingInset(); inset->GetCursorPos(owner->view(), slx, sly); owner->view()->unlockInset(inset); owner->view()->menuRedo(); @@ -731,7 +731,7 @@ string const LyXFunc::Dispatch(int ac, if (inset) inset->Edit(owner->view(),slx,sly,0); return string(); - } else if (((result=owner->view()->the_locking_inset-> + } else if (((result=owner->view()->theLockingInset()-> LocalDispatch(owner->view(), action, argument)) == UpdatableInset::DISPATCHED) || @@ -1375,15 +1375,15 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_LAYOUT_TABULAR: - if (owner->view()->the_locking_inset) { - if (owner->view()->the_locking_inset->LyxCode()==Inset::TABULAR_CODE) { + if (owner->view()->theLockingInset()) { + if (owner->view()->theLockingInset()->LyxCode()==Inset::TABULAR_CODE) { InsetTabular * inset = static_cast - (owner->view()->the_locking_inset); + (owner->view()->theLockingInset()); inset->OpenLayoutDialog(owner->view()); - } else if (owner->view()->the_locking_inset-> + } else if (owner->view()->theLockingInset()-> GetFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) { InsetTabular * inset = static_cast( - owner->view()->the_locking_inset->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)); + owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)); inset->OpenLayoutDialog(owner->view()); } } @@ -2311,11 +2311,11 @@ string const LyXFunc::Dispatch(int ac, case LFUN_INSET_CAPTION: { // Do we have a locking inset... - if (owner->view()->the_locking_inset) { + if (owner->view()->theLockingInset()) { lyxerr << "Locking inset code: " - << static_cast(owner->view()->the_locking_inset->LyxCode()); + << static_cast(owner->view()->theLockingInset()->LyxCode()); InsetCaption * new_inset = new InsetCaption; - new_inset->setOwner(owner->view()->the_locking_inset); + new_inset->setOwner(owner->view()->theLockingInset()); new_inset->SetAutoBreakRows(true); new_inset->SetDrawFrame(0, InsetText::LOCKED); new_inset->SetFrameColor(0, LColor::footnoteframe); @@ -2572,7 +2572,7 @@ string const LyXFunc::Dispatch(int ac, owner->view()-> open_new_inset(new InsetFormula(false)); owner->view() - ->the_locking_inset + ->theLockingInset() ->LocalDispatch(owner->view(), action, argument); diff --git a/src/lyxtext.h b/src/lyxtext.h index d80ecd259a..b1acc90325 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -71,6 +71,8 @@ public: BufferView * bv_owner; /// InsetText * inset_owner; + /// + UpdatableInset * the_locking_inset; /// LyXFont const GetFont(Buffer const *, LyXParagraph * par, diff --git a/src/mathed/formula.C b/src/mathed/formula.C index e1fe06392c..611e4d2a4f 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -548,7 +548,7 @@ void InsetFormula::ToggleInsetCursor(BufferView * bv) } -void InsetFormula::ShowInsetCursor(BufferView * bv) +void InsetFormula::ShowInsetCursor(BufferView * bv, bool) { if (!cursor_visible) { if (mathcursor) { diff --git a/src/mathed/formula.h b/src/mathed/formula.h index dbee7144b7..99a018f276 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -86,7 +86,7 @@ public: /// void ToggleInsetCursor(BufferView *); /// - void ShowInsetCursor(BufferView *); + void ShowInsetCursor(BufferView *, bool show=true); /// void HideInsetCursor(BufferView *); /// diff --git a/src/mathed/math_symbols.C b/src/mathed/math_symbols.C index 34447a4f9d..a91347731b 100644 --- a/src/mathed/math_symbols.C +++ b/src/mathed/math_symbols.C @@ -338,7 +338,7 @@ bool math_insert_greek(char c) ('a'<= c && c<= 'z'))) { string tmp; tmp = c; - if (!current_view->the_locking_inset) { + if (!current_view->theLockingInset()) { int greek_kb_flag_save = greek_kb_flag; InsetFormula * new_inset = new InsetFormula(); current_view->beforeChange(); @@ -347,10 +347,10 @@ bool math_insert_greek(char c) new_inset->Edit(current_view, 0, 0, 0); new_inset->LocalDispatch(current_view, LFUN_SELFINSERT, tmp); if (greek_kb_flag_save < 2) - current_view->unlockInset(current_view->the_locking_inset); + current_view->unlockInset(current_view->theLockingInset()); } else - if (current_view->the_locking_inset->LyxCode() == Inset::MATH_CODE) - static_cast(current_view->the_locking_inset)->LocalDispatch(current_view, LFUN_SELFINSERT, tmp); + if (current_view->theLockingInset()->LyxCode() == Inset::MATH_CODE) + static_cast(current_view->theLockingInset())->LocalDispatch(current_view, LFUN_SELFINSERT, tmp); else lyxerr << "Math error: attempt to write on a wrong " "class of inset." << endl; @@ -363,7 +363,7 @@ bool math_insert_greek(char c) void math_insert_symbol(string const & s) { if (current_view->available()) { - if (!current_view->the_locking_inset) { + if (!current_view->theLockingInset()) { InsetFormula * new_inset = new InsetFormula(); current_view->beforeChange(); current_view->insertInset(new_inset); @@ -371,8 +371,8 @@ void math_insert_symbol(string const & s) new_inset->Edit(current_view, 0, 0, 0); new_inset->InsertSymbol(current_view, s); } else - if (current_view->the_locking_inset->LyxCode() == Inset::MATH_CODE) - static_cast(current_view->the_locking_inset)->InsertSymbol(current_view, s); + if (current_view->theLockingInset()->LyxCode() == Inset::MATH_CODE) + static_cast(current_view->theLockingInset())->InsertSymbol(current_view, s); else lyxerr << "Math error: attempt to write on a wrong " "class of inset." << endl; diff --git a/src/text2.C b/src/text2.C index 8836bccca5..24ff26b183 100644 --- a/src/text2.C +++ b/src/text2.C @@ -67,6 +67,7 @@ LyXText::LyXText(InsetText * inset) void LyXText::init() { + the_locking_inset = 0; firstrow = 0; lastrow = 0; number_of_rows = 0; @@ -2380,16 +2381,17 @@ bool LyXText::IsStringInText(LyXParagraph * par, LyXParagraph::size_type pos, string const & str) const { - if (par) { - LyXParagraph::size_type i = 0; - while (pos + i < par->Last() - && string::size_type(i) < str.length() - && str[i] == par->GetChar(pos + i)) { - ++i; - } - if (str.length() == string::size_type(i)) - return true; + if (!par) + return false; + + LyXParagraph::size_type i = 0; + while (pos + i < par->Last() + && string::size_type(i) < str.length() + && str[i] == par->GetChar(pos + i)) { + ++i; } + if (str.length() == string::size_type(i)) + return true; return false; } -- 2.39.2