X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView2.C;h=7263f0ac85f115fc9af2d98fa42e8f94e4522b9b;hb=664eb7ff45dbb4fabc22ec0b56798031a82335b1;hp=010be99a7980fe8c048aa383d4d999b4fca4a593;hpb=ff67bee1179e8f12f739213b2d0074d1938028d1;p=lyx.git diff --git a/src/BufferView2.C b/src/BufferView2.C index 010be99a79..7263f0ac85 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -22,7 +22,6 @@ #include "insets/insetinfo.h" #include "insets/insetspecialchar.h" #include "LyXView.h" -#include "minibuffer.h" #include "bufferlist.h" #include "support/FileInfo.h" #include "lyxscreen.h" @@ -32,6 +31,9 @@ #include "BufferView_pimpl.h" #include "insets/insetcommand.h" //ChangeRefs #include "support/lyxfunctional.h" //equal_1st_in_pair +#include "language.h" +#include "gettext.h" +#include "lyxfunc.h" extern BufferList bufferlist; @@ -105,29 +107,42 @@ bool BufferView::removeAutoInsets() LyXCursor cursor; bool a = false; +#ifndef NEW_INSETS while (par) { // this has to be done before the delete -#ifndef NEW_INSETS if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) -#endif text->SetCursor(this, cursor, par, 0); if (par->AutoDeleteInsets()){ a = true; -#ifndef NEW_INSETS if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ -#endif text->RedoParagraphs(this, cursor, - cursor.par()->Next()); + cursor.par()->next()); text->FullRebreak(this); -#ifndef NEW_INSETS } -#endif } - par = par->next; + par = par->next_; } + // avoid forbidden cursor positions caused by error removing if (tmpcursor.pos() > tmpcursor.par()->Last()) tmpcursor.pos(tmpcursor.par()->Last()); +#else + while (par) { + // this has to be done before the delete + text->SetCursor(this, cursor, par, 0); + if (par->AutoDeleteInsets()){ + a = true; + text->RedoParagraphs(this, cursor, + cursor.par()->next()); + text->FullRebreak(this); + } + par = par->next(); + } + + // avoid forbidden cursor positions caused by error removing + if (tmpcursor.pos() > tmpcursor.par()->size()) + tmpcursor.pos(tmpcursor.par()->size()); +#endif text->SetCursorIntern(this, tmpcursor.par(), tmpcursor.pos()); return a; @@ -222,8 +237,12 @@ bool BufferView::insertInset(Inset * inset, string const & lout, update(text, BufferView::SELECT|BufferView::FITCUR); text->BreakParagraph(this); update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - + +#ifndef NEW_INSETS if (text->cursor.par()->Last()) { +#else + if (text->cursor.par()->size()) { +#endif text->CursorLeft(this); text->BreakParagraph(this); @@ -347,11 +366,11 @@ void BufferView::allFloats(char flag, char figmar) ) ) ) { - if (par->previous - && par->previous->footnoteflag != + if (par->previous_ + && par->previous_->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ /* should be */ text->SetCursorIntern(this, - par->previous, + par->previous_, 0); text->OpenFootnote(this); } @@ -384,7 +403,7 @@ void BufferView::allFloats(char flag, char figmar) text->CloseFootnote(this); } } - par = par->next; + par = par->next_; } text->SetCursorIntern(this, cursor.par(), cursor.pos()); @@ -406,7 +425,8 @@ void BufferView::insertNote() void BufferView::openStuff() { if (available()) { - owner()->getMiniBuffer()->Set(_("Open/Close...")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, + _("Open/Close...")); hideCursor(); beforeChange(text); update(text, BufferView::SELECT|BufferView::FITCUR); @@ -420,7 +440,8 @@ void BufferView::openStuff() void BufferView::toggleFloat() { if (available()) { - owner()->getMiniBuffer()->Set(_("Open/Close...")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, + _("Open/Close...")); hideCursor(); beforeChange(text); update(text, BufferView::SELECT|BufferView::FITCUR); @@ -434,12 +455,13 @@ void BufferView::toggleFloat() void BufferView::menuUndo() { if (available()) { - owner()->getMiniBuffer()->Set(_("Undo")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, _("Undo")); hideCursor(); beforeChange(text); update(text, BufferView::SELECT|BufferView::FITCUR); if (!text->TextUndo(this)) - owner()->getMiniBuffer()->Set(_("No further undo information")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, + _("No forther undo information")); else update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); setState(); @@ -450,17 +472,20 @@ void BufferView::menuUndo() void BufferView::menuRedo() { if (theLockingInset()) { - owner()->getMiniBuffer()->Set(_("Redo not yet supported in math mode")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, + _("Redo not yet supported in math mode")); return; } if (available()) { - owner()->getMiniBuffer()->Set(_("Redo")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, + _("Redo")); hideCursor(); beforeChange(text); update(text, BufferView::SELECT|BufferView::FITCUR); if (!text->TextRedo(this)) - owner()->getMiniBuffer()->Set(_("No further redo information")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, + _("No further redo information")); else update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); setState(); @@ -552,6 +577,7 @@ void BufferView::hfill() } } + void BufferView::copyEnvironment() { if (available()) { @@ -560,7 +586,8 @@ void BufferView::copyEnvironment() toggleSelection(); text->ClearSelection(this); update(text, BufferView::SELECT|BufferView::FITCUR); - owner()->getMiniBuffer()->Set(_("Paragraph environment type copied")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, + _("Paragraph environment type copied")); } } @@ -569,7 +596,8 @@ void BufferView::pasteEnvironment() { if (available()) { text->pasteEnvironmentType(this); - owner()->getMiniBuffer()->Set(_("Paragraph environment type set")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, + _("Paragraph environment type set")); update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } } @@ -583,7 +611,7 @@ void BufferView::copy() toggleSelection(); text->ClearSelection(this); update(text, BufferView::SELECT|BufferView::FITCUR); - owner()->getMiniBuffer()->Set(_("Copy")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, _("Copy")); } } @@ -594,7 +622,7 @@ void BufferView::cut() update(text, BufferView::SELECT|BufferView::FITCUR); text->CutSelection(this); update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - owner()->getMiniBuffer()->Set(_("Cut")); + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, _("Cut")); } } @@ -602,8 +630,9 @@ void BufferView::cut() void BufferView::paste() { if (!available()) return; - - owner()->getMiniBuffer()->Set(_("Paste")); + + owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, _("Paste")); + hideCursor(); // clear the selection toggleSelection(); @@ -648,10 +677,14 @@ void BufferView::gotoInset(std::vector const & codes, text->cursor.pos(0); if (!text->GotoNextInset(this, codes, contents)) { text->cursor = tmp; - owner()->getMiniBuffer()->Set(_("No more insets")); + owner()->getLyXFunc() + ->Dispatch(LFUN_MESSAGE, + _("No more insets")); } } else { - owner()->getMiniBuffer()->Set(_("No more insets")); + owner()->getLyXFunc() + ->Dispatch(LFUN_MESSAGE, + _("No more insets")); } } update(text, BufferView::SELECT|BufferView::FITCUR); @@ -821,17 +854,17 @@ void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind) return; // shouldn't happen if (kind == Undo::EDIT) // in this case insets would not be stored! kind = Undo::FINISH; - text->SetUndo(buffer(), kind, #ifndef NEW_INSETS + text->SetUndo(buffer(), kind, text->cursor.par()-> - ParFromPos(text->cursor.pos())->previous, + ParFromPos(text->cursor.pos())->previous_, text->cursor.par()-> - ParFromPos(text->cursor.pos())->next + ParFromPos(text->cursor.pos())->next_); #else - text->cursor.par()->previous, - text->cursor.par()->next + text->SetUndo(buffer(), kind, + text->cursor.par()->previous(), + text->cursor.par()->next()); #endif - ); } @@ -846,9 +879,6 @@ void BufferView::updateInset(Inset * inset, bool mark_dirty) if (text->UpdateInset(this, inset)) { update(); if (mark_dirty) { - if (buffer()->isLyxClean()) - owner()->getMiniBuffer()-> - setTimer(4); buffer()->markDirty(); } updateScrollbar(); @@ -858,9 +888,6 @@ void BufferView::updateInset(Inset * inset, bool mark_dirty) if (text->UpdateInset(this, theLockingInset())) { update(); if (mark_dirty){ - if (buffer()->isLyxClean()) - owner()->getMiniBuffer()-> - setTimer(4); buffer()->markDirty(); } updateScrollbar(); @@ -884,7 +911,8 @@ void BufferView::updateInset(Inset * inset, bool mark_dirty) } -bool BufferView::ChangeInsets(Inset::Code code, string const & from, string const & to) +bool BufferView::ChangeInsets(Inset::Code code, + string const & from, string const & to) { bool flag = false; LyXParagraph * par = buffer()->paragraph; @@ -910,22 +938,31 @@ bool BufferView::ChangeInsets(Inset::Code code, string const & from, string cons } } } +#ifndef NEW_INSETS if (flag2) { flag = true; -#ifndef NEW_INSETS if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ -#endif // this is possible now, since SetCursor takes // care about footnotes text->SetCursorIntern(this, par, 0); text->RedoParagraphs(this, text->cursor, - text->cursor.par()->Next()); + text->cursor.par()->next()); text->FullRebreak(this); -#ifndef NEW_INSETS } -#endif } - par = par->next; + par = par->next_; +#else + if (flag2) { + flag = true; + // this is possible now, since SetCursor takes + // care about footnotes + text->SetCursorIntern(this, par, 0); + text->RedoParagraphs(this, text->cursor, + text->cursor.par()->next()); + text->FullRebreak(this); + } + par = par->next(); +#endif } text->SetCursorIntern(this, cursor.par(), cursor.pos()); return flag; @@ -994,6 +1031,7 @@ LyXText * BufferView::getParentText(Inset * inset) const return text; } + Language const * BufferView::getParentLanguage(Inset * inset) const { LyXText * text = getParentText(inset);