]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView2.C
fix "make dist" target
[lyx.git] / src / BufferView2.C
index 7263f0ac85f115fc9af2d98fa42e8f94e4522b9b..d24181d0657af06e8eb4b2fdf652cc584cd2dfff 100644 (file)
@@ -33,7 +33,6 @@
 #include "support/lyxfunctional.h" //equal_1st_in_pair
 #include "language.h"
 #include "gettext.h"
-#include "lyxfunc.h"
 
 extern BufferList bufferlist;
 
@@ -107,26 +106,7 @@ bool BufferView::removeAutoInsets()
        LyXCursor cursor;
 
        bool a = false;
-#ifndef NEW_INSETS
-       while (par) {
-               // this has to be done before the delete
-               if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE)
-                       text->SetCursor(this, cursor, par, 0);
-               if (par->AutoDeleteInsets()){
-                       a = true;
-                       if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
-                               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()->Last())
-               tmpcursor.pos(tmpcursor.par()->Last());
-#else
        while (par) {
                // this has to be done before the delete
                text->SetCursor(this, cursor, par, 0);
@@ -142,7 +122,7 @@ bool BufferView::removeAutoInsets()
        // 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;
@@ -154,12 +134,6 @@ 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();
             ++cit) {
@@ -238,11 +212,7 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
                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);
@@ -282,23 +252,6 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
 }
 
 
-// Open and lock an updatable inset
-bool BufferView::open_new_inset(UpdatableInset * new_inset, bool behind)
-{
-       beforeChange(text);
-       text->FinishUndo();
-       if (!insertInset(new_inset)) {
-               delete new_inset;
-               return false;
-       }
-       if (behind) {
-               LyXFont & font = getLyXText()->real_current_font;
-               new_inset->Edit(this, new_inset->width(this, font), 0, 0);
-       } else
-               new_inset->Edit(this, 0, 0, 0);
-       return true;
-}
-
 /* This is also a buffer property (ale) */
 // Not so sure about that. a goto Label function can not be buffer local, just
 // think how this will work in a multiwindo/buffer environment, all the
@@ -323,145 +276,15 @@ bool BufferView::gotoLabel(string const & label)
 }
 
 
-#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
-           && ((figmar 
-                && cursor.par()->footnotekind != LyXParagraph::FOOTNOTE 
-                && cursor.par()->footnotekind != LyXParagraph::MARGIN
-                   )
-               || (!figmar
-                   && cursor.par()->footnotekind != LyXParagraph::FIG 
-                   && cursor.par()->footnotekind != LyXParagraph::TAB
-                   && cursor.par()->footnotekind != LyXParagraph::WIDE_FIG 
-                   && cursor.par()->footnotekind != LyXParagraph::WIDE_TAB
-                   && cursor.par()->footnotekind != LyXParagraph::ALGORITHM)))
-               toggleFloat();
-       else
-               beforeChange(text);
-
-       LyXCursor tmpcursor = cursor;
-       cursor.par(tmpcursor.par()->ParFromPos(tmpcursor.pos()));
-       cursor.pos(tmpcursor.par()->PositionInParFromPos(tmpcursor.pos()));
-
-       LyXParagraph *par = buffer()->paragraph;
-       while (par) {
-               if (flag) {
-                       if (par->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE
-                           && ((figmar 
-                                && par->footnotekind != LyXParagraph::FOOTNOTE 
-                                && par->footnotekind !=  LyXParagraph::MARGIN)
-                               || (!figmar
-                                   && par->footnotekind != LyXParagraph::FIG 
-                                   && par->footnotekind != LyXParagraph::TAB
-                                   && par->footnotekind != LyXParagraph::WIDE_FIG 
-                                   && par->footnotekind != LyXParagraph::WIDE_TAB
-                                   && par->footnotekind != LyXParagraph::ALGORITHM
-                                       )
-                                   )
-                               ) {
-                               if (par->previous_
-                                   && par->previous_->footnoteflag != 
-                                   LyXParagraph::CLOSED_FOOTNOTE){ /* should be */ 
-                                       text->SetCursorIntern(this, 
-                                                             par->previous_,
-                                                             0);
-                                       text->OpenFootnote(this);
-                               }
-                       }
-               } else {
-                       if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
-                           && (
-                                   (figmar 
-                                    &&
-                                    par->footnotekind != LyXParagraph::FOOTNOTE 
-                                    &&
-                                    par->footnotekind !=  LyXParagraph::MARGIN
-                                           )
-                                   ||
-                                   (!figmar
-                                    &&
-                                    par->footnotekind != LyXParagraph::FIG 
-                                    &&
-                                    par->footnotekind != LyXParagraph::TAB
-                                    &&
-                                    par->footnotekind != LyXParagraph::WIDE_FIG 
-                                    &&
-                                    par->footnotekind != LyXParagraph::WIDE_TAB
-                                    &&
-                                    par->footnotekind != LyXParagraph::ALGORITHM
-                                           )
-                                   )
-                               ) {
-                               text->SetCursorIntern(this, par, 0);
-                               text->CloseFootnote(this);
-                       }
-               }
-               par = par->next_;
-       }
-
-       text->SetCursorIntern(this, cursor.par(), cursor.pos());
-       redraw();
-       fitCursor(text);
-}
-#endif
-
-
-void BufferView::insertNote()
-{
-       InsetInfo * new_inset = new InsetInfo();
-       insertInset(new_inset);
-       new_inset->Edit(this, 0, 0, 0);
-}
-
-
-#ifndef NEW_INSETS
-void BufferView::openStuff()
-{
-       if (available()) {
-               owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                               _("Open/Close..."));
-               hideCursor();
-               beforeChange(text);
-               update(text, BufferView::SELECT|BufferView::FITCUR);
-               text->OpenStuff(this);
-               update(text, BufferView::SELECT|BufferView::FITCUR);
-               setState();
-       }
-}
-
-
-void BufferView::toggleFloat()
-{
-       if (available()) {
-               owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                               _("Open/Close..."));
-               hideCursor();
-               beforeChange(text);
-               update(text, BufferView::SELECT|BufferView::FITCUR);
-               text->ToggleFootnote(this);
-               update(text, BufferView::SELECT|BufferView::FITCUR);
-               setState();
-       }
-}
-#endif
-
 void BufferView::menuUndo()
 {
        if (available()) {
-               owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, _("Undo"));
+               owner()->message(_("Undo"));
                hideCursor();
                beforeChange(text);
                update(text, BufferView::SELECT|BufferView::FITCUR);
                if (!text->TextUndo(this))
-                       owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                                       _("No forther undo information"));
+                       owner()->message(_("No forther undo information"));
                else
                        update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                setState();
@@ -472,20 +295,17 @@ void BufferView::menuUndo()
 void BufferView::menuRedo()
 {
        if (theLockingInset()) {
-               owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                               _("Redo not yet supported in math mode"));
+               owner()->message(_("Redo not yet supported in math mode"));
                return;
        }    
    
        if (available()) {
-               owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                               _("Redo"));
+               owner()->message(_("Redo"));
                hideCursor();
                beforeChange(text);
                update(text, BufferView::SELECT|BufferView::FITCUR);
                if (!text->TextRedo(this))
-                       owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                                       _("No further redo information"));
+                       owner()->message(_("No further redo information"));
                else
                        update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                setState();
@@ -586,8 +406,7 @@ void BufferView::copyEnvironment()
                toggleSelection();
                text->ClearSelection(this);
                update(text, BufferView::SELECT|BufferView::FITCUR);
-               owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                               _("Paragraph environment type copied"));
+               owner()->message(_("Paragraph environment type copied"));
        }
 }
 
@@ -596,8 +415,7 @@ void BufferView::pasteEnvironment()
 {
        if (available()) {
                text->pasteEnvironmentType(this);
-               owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE,
-                                               _("Paragraph environment type set"));
+               owner()->message(_("Paragraph environment type set"));
                update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
        }
 }
@@ -611,7 +429,7 @@ void BufferView::copy()
                toggleSelection();
                text->ClearSelection(this);
                update(text, BufferView::SELECT|BufferView::FITCUR);
-               owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, _("Copy"));
+               owner()->message(_("Copy"));
        }
 }
 
@@ -622,7 +440,7 @@ void BufferView::cut()
                update(text, BufferView::SELECT|BufferView::FITCUR);
                text->CutSelection(this);
                update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-               owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, _("Cut"));
+               owner()->message(_("Cut"));
        }
 }
 
@@ -631,7 +449,7 @@ void BufferView::paste()
 {
        if (!available()) return;
 
-       owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, _("Paste"));
+       owner()->message(_("Paste"));
 
        hideCursor();
        // clear the selection
@@ -677,14 +495,10 @@ void BufferView::gotoInset(std::vector<Inset::Code> const & codes,
                                text->cursor.pos(0);
                                if (!text->GotoNextInset(this, codes, contents)) {
                                        text->cursor = tmp;
-                                       owner()->getLyXFunc()
-                                               ->Dispatch(LFUN_MESSAGE,
-                                                          _("No more insets"));
+                                       owner()->message(_("No more insets"));
                                }
                        } else {
-                               owner()->getLyXFunc()
-                                       ->Dispatch(LFUN_MESSAGE,
-                                                  _("No more insets"));
+                               owner()->message(_("No more insets"));
                        }
        }
        update(text, BufferView::SELECT|BufferView::FITCUR);
@@ -854,17 +668,9 @@ 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;
-#ifndef NEW_INSETS
-       text->SetUndo(buffer(), kind,
-                     text->cursor.par()->
-                     ParFromPos(text->cursor.pos())->previous_, 
-                     text->cursor.par()->
-                     ParFromPos(text->cursor.pos())->next_);
-#else
        text->SetUndo(buffer(), kind,
                      text->cursor.par()->previous(), 
                      text->cursor.par()->next());
-#endif
 }
 
 
@@ -918,13 +724,8 @@ bool BufferView::ChangeInsets(Inset::Code code,
        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;
@@ -938,20 +739,6 @@ bool BufferView::ChangeInsets(Inset::Code code,
                                }
                        }
                }
-#ifndef NEW_INSETS
-               if (flag2) {
-                       flag = true;
-                       if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
-                               // 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_;
-#else
                if (flag2) {
                        flag = true;
                        // this is possible now, since SetCursor takes
@@ -962,7 +749,6 @@ bool BufferView::ChangeInsets(Inset::Code code,
                        text->FullRebreak(this);
                }
                par = par->next();
-#endif
        }
        text->SetCursorIntern(this, cursor.par(), cursor.pos());
        return flag;
@@ -985,7 +771,7 @@ bool BufferView::ChangeCitationsIfUnique(string const & from, string const & to)
 
        vector<pair<string,string> > keys = buffer()->getBibkeyList();  
        if (count_if(keys.begin(), keys.end(), 
-                    equal_1st_in_pair<string,string>(from)) 
+                    lyx::equal_1st_in_pair<string,string>(from)) 
            > 1)
                return false;
 
@@ -1003,7 +789,7 @@ UpdatableInset * BufferView::theLockingInset() const
 
 void BufferView::theLockingInset(UpdatableInset * inset)
 {
-    text->the_locking_inset = inset;
+       text->the_locking_inset = inset;
 }