]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/WorkArea.C
hopefully fix tex2lyx linking.
[lyx.git] / src / frontends / WorkArea.C
index ac74e2000dce2ea1a3ecda07d2693f1b7ec76bd9..c2b8faf25c2638ed82d55d4da4f1fa7d6c958af2 100644 (file)
@@ -71,8 +71,8 @@ namespace lyx {
 namespace frontend {
 
 WorkArea::WorkArea(int id, LyXView & lyx_view)
-       : id_(id), buffer_view_(0), lyx_view_(lyx_view), greyed_out_(true),
-         cursor_visible_(false), cursor_timeout_(400)
+       : buffer_view_(0), lyx_view_(lyx_view), greyed_out_(true),
+         id_(id), cursor_visible_(false), cursor_timeout_(400)
 {
        // Start loading the pixmap as soon as possible
        //if (lyxrc.show_banner) {
@@ -94,8 +94,6 @@ void WorkArea::setBufferView(BufferView * buffer_view)
                lyx_view_.disconnectBufferView();
        }
 
-       theApp->setBufferView(buffer_view);
-
        hideCursor();
        buffer_view_ = buffer_view;
        toggleCursor();
@@ -119,31 +117,39 @@ BufferView const & WorkArea::bufferView() const
 }
 
 
-void WorkArea::checkAndGreyOut()
+void WorkArea::stopBlinkingCursor()
 {
-       if (greyed_out_)
-               greyOut();
+       cursor_timeout_.stop();
+       hideCursor();
 }
 
 
-void WorkArea::redraw()
+void WorkArea::startBlinkingCursor()
 {
-       if (!buffer_view_)
-               return;
+       showCursor();
+       cursor_timeout_.restart();
+}
 
-       if (!buffer_view_->buffer()) {
-               checkAndGreyOut();
+
+void WorkArea::redraw(bool singlePar)
+{
+       if (!buffer_view_ || !buffer_view_->buffer()) {
+               greyed_out_ = true;
+               // The argument here are meaningless.
+               expose(1,1,1,1);
                return;
        }
 
-       buffer_view_->updateMetrics(false);
+       buffer_view_->updateMetrics(singlePar && hasFocus());
 
        updateScrollbar();
 
        ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
        greyed_out_ = false;
 
-       lyxerr[Debug::WORKAREA] << "WorkArea::redraw screen" << endl;
+       if (lyxerr.debugging(Debug::WORKAREA)) {
+               lyxerr[Debug::WORKAREA] << "WorkArea::redraw screen" << endl;
+       }
        int const ymin = std::max(vi.y1, 0);
        int const ymax = vi.p2 < vi.size - 1 ? vi.y2 : height();
 
@@ -161,20 +167,17 @@ void WorkArea::redraw()
 void WorkArea::processKeySym(LyXKeySymPtr key,
                                                         key_modifier::state state)
 {
-       hideCursor();
+       // In order to avoid bad surprise in the middle of an operation, we better stop
+       // the blinking cursor.
+       stopBlinkingCursor();
 
        theLyXFunc().setLyXView(&lyx_view_);
        theLyXFunc().processKeySym(key, state);
 
-       /* This is perhaps a bit of a hack. When we move
-        * around, or type, it's nice to be able to see
-        * the cursor immediately after the keypress. So
-        * we reset the toggle timeout and force the visibility
-        * of the cursor. Note we cannot do this inside
-        * dispatch() itself, because that's called recursively.
+       /* When we move around, or type, it's nice to be able to see
+        * the cursor immediately after the keypress.
         */
-//     if (buffer_view_->buffer())
-       toggleCursor();
+       startBlinkingCursor();
 }
 
 
@@ -188,7 +191,7 @@ void WorkArea::dispatch(FuncRequest const & cmd0)
 
        theLyXFunc().setLyXView(&lyx_view_);
 
-       buffer_view_->workAreaDispatch(cmd0);
+       std::pair<bool, bool> needRedraw = buffer_view_->workAreaDispatch(cmd0);
 
        // Skip these when selecting
        if (cmd0.action != LFUN_MOUSE_MOTION) {
@@ -202,7 +205,12 @@ void WorkArea::dispatch(FuncRequest const & cmd0)
        // of the new status here.
        lyx_view_.clearMessage();
 
-       redraw();
+       // Show the cursor immediately after any operation.
+       hideCursor();
+       toggleCursor();
+
+       if (needRedraw.first)
+               redraw(needRedraw.second);
 }
 
 
@@ -240,13 +248,6 @@ void WorkArea::scrollBufferView(int position)
 }
 
 
-void WorkArea::greyOut()
-{
-       greyed_out_ = true;
-       expose(4, 5, 3, 3);
-}
-
-
 void WorkArea::showCursor()
 {
        if (cursor_visible_)