X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView2.C;h=e58b0e4ef7665cdebe8851e7895d1aa701576b1e;hb=a69e7a45780e94f4330a91facfe35126c678e34e;hp=0e56648dcb479f6ce57ba960450e9c6709e3a05d;hpb=572556e94f635a132521ba759cea6b66dc56e2b8;p=lyx.git diff --git a/src/BufferView2.C b/src/BufferView2.C index 0e56648dcb..e58b0e4ef7 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -73,10 +73,11 @@ bool BufferView::insertLyXFile(string const & filen) MakeDisplayPath(fname, 50)); return false; } + + char c = ifs.peek(); + LyXLex lex(0, 0); lex.setStream(ifs); - char c; ifs.get(c); - ifs.putback(c); bool res = true; @@ -102,15 +103,21 @@ bool BufferView::removeAutoInsets() bool a = false; 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()); text->FullRebreak(this); +#ifndef NEW_INSETS } +#endif } par = par->next; } @@ -128,9 +135,11 @@ void BufferView::insertErrors(TeXErrors & terr) // Save the cursor position LyXCursor cursor = text->cursor; +#ifndef NEW_INSETS // This is drastic, but it's the only fix, I could find. (Asger) allFloats(1, 0); allFloats(1, 1); +#endif for (TeXErrors::Errors::const_iterator cit = terr.begin(); cit != terr.end(); @@ -144,8 +153,10 @@ void BufferView::insertErrors(TeXErrors & terr) int tmpid = -1; int tmppos = -1; - buffer()->texrow.getIdFromRow(errorrow, tmpid, tmppos); - + if (buffer()->texrow.getIdFromRow(errorrow, tmpid, tmppos)) { + buffer()->texrow.increasePos(tmpid, tmppos); + } + LyXParagraph * texrowpar = 0; if (tmpid == -1) { @@ -272,14 +283,16 @@ bool BufferView::insertInset(Inset * inset, string const & lout, // Open and lock an updatable inset -void BufferView::open_new_inset(UpdatableInset * new_inset) +bool BufferView::open_new_inset(UpdatableInset * new_inset) { beforeChange(); text->FinishUndo(); - insertInset(new_inset); + if (!insertInset(new_inset)) + return false; text->CursorLeft(this); update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); new_inset->Edit(this, 0, 0, 0); + return true; } /* This is also a buffer property (ale) */ @@ -305,16 +318,20 @@ bool BufferView::gotoLabel(string const & label) return false; } + +#ifndef NEW_INSETS void BufferView::allFloats(char flag, char figmar) { if (!available()) return; LyXCursor cursor = text->cursor; - if (!flag && cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE + if (!flag + && cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE && ((figmar && cursor.par()->footnotekind != LyXParagraph::FOOTNOTE - && cursor.par()->footnotekind != LyXParagraph::MARGIN) + && cursor.par()->footnotekind != LyXParagraph::MARGIN + ) || (!figmar && cursor.par()->footnotekind != LyXParagraph::FIG && cursor.par()->footnotekind != LyXParagraph::TAB @@ -390,6 +407,7 @@ void BufferView::allFloats(char flag, char figmar) fitCursor(); //updateScrollbar(); } +#endif void BufferView::insertNote() @@ -400,6 +418,7 @@ void BufferView::insertNote() } +#ifndef NEW_INSETS void BufferView::openStuff() { if (available()) { @@ -426,6 +445,7 @@ void BufferView::toggleFloat() setState(); } } +#endif void BufferView::menuUndo() { @@ -792,10 +812,16 @@ void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind) if (kind == Undo::EDIT) // in this case insets would not be stored! kind = Undo::FINISH; text->SetUndo(buffer(), kind, +#ifndef NEW_INSETS text->cursor.par()-> 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 +#endif + ); } @@ -853,8 +879,13 @@ bool BufferView::ChangeRefs(string const & from, string const & to) LyXParagraph * par = buffer()->paragraph; LyXCursor cursor = text->cursor; LyXCursor tmpcursor = cursor; +#ifndef NEW_INSETS cursor.par(tmpcursor.par()->ParFromPos(tmpcursor.pos())); cursor.pos(tmpcursor.par()->PositionInParFromPos(tmpcursor.pos())); +#else + cursor.par(tmpcursor.par()); + cursor.pos(tmpcursor.pos()); +#endif while (par) { bool flag2 = false; @@ -870,14 +901,18 @@ bool BufferView::ChangeRefs(string const & from, string const & to) } 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->FullRebreak(this); +#ifndef NEW_INSETS } +#endif } par = par->next; }