]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
remove unused macro
[lyx.git] / src / BufferView.cpp
index d632b12177753d6933efe11b5d042e82b6af39b3..4997d458da49e86a26a62f40f8105b51fc179351 100644 (file)
@@ -69,7 +69,6 @@
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/ExceptionMessage.h"
-#include "support/FileFilterList.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
@@ -501,6 +500,13 @@ docstring BufferView::contextMenu(int x, int y) const
 
 void BufferView::scrollDocView(int value)
 {
+       int const offset = value - d->scrollbarParameters_.position;
+       // If the offset is less than 2 screen height, prefer to scroll instead.
+       if (abs(offset) <= 2 * height_) {
+               scroll(offset);
+               return;
+       }
+
        // cut off at the top
        if (value <= d->scrollbarParameters_.min) {
                DocIterator dit = doc_iterator_begin(buffer_.inset());
@@ -518,14 +524,6 @@ void BufferView::scrollDocView(int value)
                return;
        }
 
-
-       int const offset = value - d->scrollbarParameters_.position;
-       // If the offset is less than 2 screen height, prefer to scroll instead.
-       if (abs(offset) <= 2 * height_) {
-               scroll(offset);
-               return;
-       }
-
        // find paragraph at target position
        int par_pos = d->scrollbarParameters_.min;
        pit_type i = 0;
@@ -1337,6 +1335,8 @@ void BufferView::clearSelection()
 
 void BufferView::resize(int width, int height)
 {
+       bool initialResize = (height_ == 0);
+       
        // Update from work area
        width_ = width;
        height_ = height;
@@ -1345,6 +1345,13 @@ void BufferView::resize(int width, int height)
        d->par_height_.clear();
 
        updateMetrics();
+
+       // view got his initial size, make sure that
+       // the cursor has a proper position
+       if (initialResize) {
+               updateScrollbar();
+               showCursor();
+       }
 }
 
 
@@ -1769,6 +1776,19 @@ void BufferView::updateMetrics()
        // Rebreak anchor paragraph.
        tm.redoParagraph(d->anchor_pit_);
        ParagraphMetrics & anchor_pm = tm.par_metrics_[d->anchor_pit_];
+       
+       // position anchor
+       if (d->anchor_pit_ == 0) {
+               int scrollRange = d->scrollbarParameters_.max - d->scrollbarParameters_.min;
+               
+               // Complete buffer visible? Then it's easy.
+               if (scrollRange == 0)
+                       d->anchor_ypos_ = anchor_pm.ascent();
+       
+               // FIXME: Some clever handling needed to show
+               // the _first_ paragraph up to the top if the cursor is
+               // in the first line.
+       }               
        anchor_pm.setPosition(d->anchor_ypos_);
 
        LYXERR(Debug::PAINTING, "metrics: "