]> git.lyx.org Git - features.git/blobdiff - src/BufferView_pimpl.C
move the most important changes from branch new_insets to head. Still dependant on...
[features.git] / src / BufferView_pimpl.C
index 152a5bf0c590842383515b284ede86b302d4b5a1..a94ef0dedbee284155ad63833cab03feba1d1597 100644 (file)
@@ -3,6 +3,7 @@
 #include <ctime>
 #include <unistd.h>
 #include <sys/wait.h>
+#include <locale.h>
 
 #ifdef __GNUG__
 #pragma implementation
@@ -110,9 +111,6 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
          current_scrollbar_value(0), cursor_timeout(400),
          workarea_(xpos, ypos, width, height), using_xterm_cursor(false)
 {
-       //buffer_ = 0;
-       //workarea_ = new WorkArea(xpos, ypos, width, height);
-       
        // Setup the signals
        workarea_.scrollCB.connect(slot(this, &BufferView::Pimpl::scrollCB));
        workarea_.workAreaExpose
@@ -281,11 +279,11 @@ int BufferView::Pimpl::resizeCurrentBuffer()
        LyXParagraph * selendpar = 0;
        UpdatableInset * the_locking_inset = 0;
        
-       int pos = 0;
-       int selstartpos = 0;
-       int selendpos = 0;
-       int selection = 0;
-       int mark_set = 0;
+       LyXParagraph::size_type pos = 0;
+       LyXParagraph::size_type selstartpos = 0;
+       LyXParagraph::size_type selendpos = 0;
+       bool selection = false;
+       bool mark_set  = false;
 
        ProhibitInput(bv_);
 
@@ -808,6 +806,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
                return;
        }
 
+#ifndef NEW_INSETS
        // check whether we want to open a float
        if (bv_->text) {
                bool hit = false;
@@ -817,7 +816,6 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
                        c = bv_->text->cursor.par()->
                                GetChar(bv_->text->cursor.pos());
                }
-#ifndef NEW_INSETS
               if(!bv_->text->selection)
                if (c == LyXParagraph::META_FOOTNOTE
                    || c == LyXParagraph::META_MARGIN
@@ -828,11 +826,9 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
                     || c == LyXParagraph::META_ALGORITHM){
                        hit = true;
                } else
-#endif
                        if (bv_->text->cursor.pos() - 1 >= 0) {
                        c = bv_->text->cursor.par()->
                                GetChar(bv_->text->cursor.pos() - 1);
-#ifndef NEW_INSETS
                        if (c == LyXParagraph::META_FOOTNOTE
                            || c == LyXParagraph::META_MARGIN
                            || c == LyXParagraph::META_FIG
@@ -844,18 +840,13 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
                                bv_->text->CursorLeft(bv_);
                                hit = true;
                        }
-#endif
                }
                if (hit == true) {
-#ifndef NEW_INSETS
                        bv_->toggleFloat();
-#endif
                        selection_possible = false;
                        return;
                }
        }
-
-#ifndef NEW_INSETS
        // Do we want to close a float? (click on the float-label)
        if (bv_->text->cursor.row()->par()->footnoteflag == 
            LyXParagraph::OPEN_FOOTNOTE
@@ -881,8 +872,26 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
                        return;
                }
        }
+#else
+       // check whether we want to open a float
+       if (bv_->text) {
+               bool hit = false;
+               char c = ' ';
+               if (bv_->text->cursor.pos() <
+                   bv_->text->cursor.par()->size()) {
+                       c = bv_->text->cursor.par()->
+                               GetChar(bv_->text->cursor.pos());
+               }
+                       if (bv_->text->cursor.pos() - 1 >= 0) {
+                       c = bv_->text->cursor.par()->
+                               GetChar(bv_->text->cursor.pos() - 1);
+               }
+               if (hit == true) {
+                       selection_possible = false;
+                       return;
+               }
+       }
 #endif
-
        // Maybe we want to edit a bibitem ale970302
        if (bv_->text->cursor.par()->bibkey && x < 20 + 
            bibitemMaxWidth(bv_, textclasslist.
@@ -911,7 +920,11 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
        LyXCursor cursor;
        text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp);
 
+#ifndef NEW_INSETS
        if (cursor.pos() < cursor.par()->Last()
+#else
+       if (cursor.pos() < cursor.par()->size()
+#endif
            && cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
            && cursor.par()->GetInset(cursor.pos())
            && cursor.par()->GetInset(cursor.pos())->Editable()) {
@@ -1224,8 +1237,13 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
        if (!par)
                return;
 
+#ifndef NEW_INSETS
        bv_->text->SetCursor(bv_, par,
                             min(par->Last(), saved_positions[i].par_pos));
+#else
+       bv_->text->SetCursor(bv_, par,
+                            min(par->size(), saved_positions[i].par_pos));
+#endif
        update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
        if (i > 0)
                owner_->getMiniBuffer()->Set(_("Moved to bookmark ") + tostr(i));
@@ -1810,7 +1828,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR);
                if (is_rtl)
                        TEXT(bv_)->CursorLeft(bv_, false);
+#ifndef NEW_INSETS
                if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last()
+#else
+               if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size()
+#endif
                    && TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos())
                    == LyXParagraph::META_INSET
                    && TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos())
@@ -1848,7 +1870,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                if (!is_rtl)
                        TEXT(bv_)->CursorLeft(bv_, false);
                if ((is_rtl || cur != TEXT(bv_)->cursor) && // only if really moved!
+#ifndef NEW_INSETS
                    TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last() &&
+#else
+                   TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size() &&
+#endif
                    (TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos()) ==
                     LyXParagraph::META_INSET) &&
                    TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos()) &&
@@ -2219,7 +2245,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                LyXCursor cursor = TEXT(bv_)->cursor;
 
                if (!TEXT(bv_)->selection) {
+#ifndef NEW_INSETS
                        if (cursor.pos() == cursor.par()->Last()) {
+#else
+                       if (cursor.pos() == cursor.par()->size()) {
+#endif
                                TEXT(bv_)->CursorRight(bv_);
                                cursor = TEXT(bv_)->cursor;
                                if (cursor.pos() == 0