]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView2.C
fix "make dist" target
[lyx.git] / src / BufferView2.C
index eb766c0bcdfffd28f0fc4f127dd2619852e4b488..d24181d0657af06e8eb4b2fdf652cc584cd2dfff 100644 (file)
@@ -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"
@@ -33,6 +32,7 @@
 #include "insets/insetcommand.h" //ChangeRefs
 #include "support/lyxfunctional.h" //equal_1st_in_pair
 #include "language.h"
+#include "gettext.h"
 
 extern BufferList bufferlist;
 
@@ -106,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);
@@ -141,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;
@@ -153,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) {
@@ -237,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);
@@ -281,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
@@ -322,142 +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()->getMiniBuffer()->Set(_("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()->getMiniBuffer()->Set(_("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()->getMiniBuffer()->Set(_("Undo"));
+               owner()->message(_("Undo"));
                hideCursor();
                beforeChange(text);
                update(text, BufferView::SELECT|BufferView::FITCUR);
                if (!text->TextUndo(this))
-                       owner()->getMiniBuffer()->Set(_("No further undo information"));
+                       owner()->message(_("No forther undo information"));
                else
                        update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                setState();
@@ -468,17 +295,17 @@ void BufferView::menuUndo()
 void BufferView::menuRedo()
 {
        if (theLockingInset()) {
-               owner()->getMiniBuffer()->Set(_("Redo not yet supported in math mode"));
+               owner()->message(_("Redo not yet supported in math mode"));
                return;
        }    
    
        if (available()) {
-               owner()->getMiniBuffer()->Set(_("Redo"));
+               owner()->message(_("Redo"));
                hideCursor();
                beforeChange(text);
                update(text, BufferView::SELECT|BufferView::FITCUR);
                if (!text->TextRedo(this))
-                       owner()->getMiniBuffer()->Set(_("No further redo information"));
+                       owner()->message(_("No further redo information"));
                else
                        update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                setState();
@@ -570,6 +397,7 @@ void BufferView::hfill()
        }
 }
 
+
 void BufferView::copyEnvironment()
 {
        if (available()) {
@@ -578,7 +406,7 @@ void BufferView::copyEnvironment()
                toggleSelection();
                text->ClearSelection(this);
                update(text, BufferView::SELECT|BufferView::FITCUR);
-               owner()->getMiniBuffer()->Set(_("Paragraph environment type copied"));
+               owner()->message(_("Paragraph environment type copied"));
        }
 }
 
@@ -587,7 +415,7 @@ void BufferView::pasteEnvironment()
 {
        if (available()) {
                text->pasteEnvironmentType(this);
-               owner()->getMiniBuffer()->Set(_("Paragraph environment type set"));
+               owner()->message(_("Paragraph environment type set"));
                update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
        }
 }
@@ -601,7 +429,7 @@ void BufferView::copy()
                toggleSelection();
                text->ClearSelection(this);
                update(text, BufferView::SELECT|BufferView::FITCUR);
-               owner()->getMiniBuffer()->Set(_("Copy"));
+               owner()->message(_("Copy"));
        }
 }
 
@@ -612,7 +440,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()->message(_("Cut"));
        }
 }
 
@@ -620,8 +448,9 @@ void BufferView::cut()
 void BufferView::paste()
 {
        if (!available()) return;
-       
-       owner()->getMiniBuffer()->Set(_("Paste"));
+
+       owner()->message(_("Paste"));
+
        hideCursor();
        // clear the selection
        toggleSelection();
@@ -666,10 +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()->getMiniBuffer()->Set(_("No more insets"));
+                                       owner()->message(_("No more insets"));
                                }
                        } else {
-                               owner()->getMiniBuffer()->Set(_("No more insets"));
+                               owner()->message(_("No more insets"));
                        }
        }
        update(text, BufferView::SELECT|BufferView::FITCUR);
@@ -839,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
 }
 
 
@@ -864,9 +685,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();
@@ -876,9 +694,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();
@@ -902,19 +717,15 @@ 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;
        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;
@@ -928,20 +739,6 @@ bool BufferView::ChangeInsets(Inset::Code code, string const & from, string cons
                                }
                        }
                }
-#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
@@ -952,7 +749,6 @@ bool BufferView::ChangeInsets(Inset::Code code, string const & from, string cons
                        text->FullRebreak(this);
                }
                par = par->next();
-#endif
        }
        text->SetCursorIntern(this, cursor.par(), cursor.pos());
        return flag;
@@ -975,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;
 
@@ -993,7 +789,7 @@ UpdatableInset * BufferView::theLockingInset() const
 
 void BufferView::theLockingInset(UpdatableInset * inset)
 {
-    text->the_locking_inset = inset;
+       text->the_locking_inset = inset;
 }