]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
use more std::functors add some of my own, some change to fl_display etc. read the...
[lyx.git] / src / BufferView_pimpl.C
index c50fbf5f1de87cefc738e0f448e6b5b2b3d66585..993db847162302b2fd132335453cbb49a34305d4 100644 (file)
@@ -61,12 +61,12 @@ void SetXtermCursor(Window win)
        static Cursor cursor;
        static bool cursor_undefined = true;
        if (cursor_undefined){
-               cursor = XCreateFontCursor(fl_display, XC_xterm);
-               XFlush(fl_display);
+               cursor = XCreateFontCursor(fl_get_display(), XC_xterm);
+               XFlush(fl_get_display());
                cursor_undefined = false;
        }
-       XDefineCursor(fl_display, win, cursor);
-       XFlush(fl_display);
+       XDefineCursor(fl_get_display(), win, cursor);
+       XFlush(fl_get_display());
 }
 
 
@@ -161,13 +161,17 @@ void BufferView::Pimpl::buffer(Buffer * b)
                bv_->text->first = screen_->TopCursorVisible(bv_->text);
                owner_->updateMenubar();
                owner_->updateToolbar();
-               redraw();
+               // Similarly, buffer-dependent dialogs should be updated or
+               // hidden. This should go here because some dialogs (eg ToC)
+               // require bv_->text.
                owner_->getDialogs()->updateBufferDependent();
+               redraw();
                bv_->insetWakeup();
        } else {
                lyxerr[Debug::INFO] << "  No Buffer!" << endl;
                owner_->updateMenubar();
                owner_->updateToolbar();
+               owner_->getDialogs()->hideBufferDependent();
                updateScrollbar();
                workarea_->redraw();
 
@@ -413,8 +417,6 @@ void BufferView::Pimpl::updateScrollbar()
 // Callback for scrollbar slider
 void BufferView::Pimpl::scrollCB(double value)
 {
-       extern bool cursor_follows_scrollbar;
-       
        if (buffer_ == 0) return;
 
        current_scrollbar_value = long(value);
@@ -426,9 +428,9 @@ void BufferView::Pimpl::scrollCB(double value)
 
        screen_->Draw(bv_->text, current_scrollbar_value);
 
-       if (cursor_follows_scrollbar) {
+       if (lyxrc.cursor_follows_scrollbar) {
                LyXText * vbt = bv_->text;
-               unsigned int height = vbt->DefaultHeight();
+               int height = vbt->DefaultHeight();
                
                if (vbt->cursor.y() < (int)(bv_->text->first + height)) {
                        vbt->SetCursorFromCoordinates(bv_, 0,
@@ -702,7 +704,7 @@ void BufferView::Pimpl::enterView()
 void BufferView::Pimpl::leaveView()
 {
        if (using_xterm_cursor) {
-               XUndefineCursor(fl_display, workarea_->getWin());
+               XUndefineCursor(fl_get_display(), workarea_->getWin());
                using_xterm_cursor = false;
        }
 }
@@ -884,7 +886,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
                LyXFont font = text->GetFont(bv_->buffer(),
                                                  cursor.par(), cursor.pos());
                bool is_rtl = font.isVisibleRightToLeft();
-               int start_x, end_x;
+               int start_x;
+               int end_x;
 
                if (is_rtl) {
                        start_x = cursor.x() - tmpinset->width(bv_, font) + tmpinset->scroll();
@@ -913,7 +916,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
                LyXFont font = text->GetFont(bv_->buffer(), cursor.par(),
                                                  cursor.pos()-1);
                bool is_rtl = font.isVisibleRightToLeft();
-               int start_x, end_x;
+               int start_x;
+               int end_x;
 
                if (!is_rtl) {
                        start_x = cursor.x() - tmpinset->width(bv_, font) +
@@ -1132,45 +1136,53 @@ void BufferView::Pimpl::cursorToggle()
 }
 
 
-void BufferView::Pimpl::cursorPrevious()
+void BufferView::Pimpl::cursorPrevious(LyXText * text)
 {
-       if (!bv_->text->cursor.row()->previous()) return;
+       if (!text->cursor.row()->previous())
+               return;
        
-       int y = bv_->text->first;
-       Row * cursorrow = bv_->text->cursor.row();
-       bv_->text->SetCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y);
+       int y = text->first;
+       if (text->inset_owner)
+               y += bv_->text->first;
+       Row * cursorrow = text->cursor.row();
+       text->SetCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y);
        bv_->text->FinishUndo();
        // This is to allow jumping over large insets
-       if ((cursorrow == bv_->text->cursor.row()))
-               bv_->text->CursorUp(bv_);
+       if ((cursorrow == text->cursor.row()))
+               text->CursorUp(bv_);
        
-       if (bv_->text->cursor.row()->height() < workarea_->height())
+       if (text->inset_owner ||
+           text->cursor.row()->height() < workarea_->height())
                screen_->Draw(bv_->text,
-                             bv_->text->cursor.y()
-                             - bv_->text->cursor.row()->baseline()
-                             + bv_->text->cursor.row()->height()
+                             text->cursor.y()
+                             - text->cursor.row()->baseline()
+                             + text->cursor.row()->height()
                              - workarea_->height() + 1 );
        updateScrollbar();
 }
 
 
-void BufferView::Pimpl::cursorNext()
+void BufferView::Pimpl::cursorNext(LyXText * text)
 {
-       if (!bv_->text->cursor.row()->next()) return;
+       if (!text->cursor.row()->next())
+               return;
        
-       int y = bv_->text->first;
-       bv_->text->GetRowNearY(y);
-       Row * cursorrow = bv_->text->cursor.row();
-       bv_->text->SetCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y
+       int y = text->first;
+//     if (text->inset_owner)
+//             y += bv_->text->first;
+       text->GetRowNearY(y);
+       Row * cursorrow = text->cursor.row();
+       text->SetCursorFromCoordinates(bv_, text->cursor.x_fix(), y
                                       + workarea_->height());
        bv_->text->FinishUndo();
        // This is to allow jumping over large insets
        if ((cursorrow == bv_->text->cursor.row()))
-               bv_->text->CursorDown(bv_);
+               text->CursorDown(bv_);
        
-       if (bv_->text->cursor.row()->height() < workarea_->height())
-               screen_->Draw(bv_->text, bv_->text->cursor.y()
-                            - bv_->text->cursor.row()->baseline());
+       if (text->inset_owner ||
+           text->cursor.row()->height() < workarea_->height())
+               screen_->Draw(bv_->text, text->cursor.y() -
+                             text->cursor.row()->baseline());
        updateScrollbar();
 }