]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Add empty InsetLayout for undefined cases. Should avoid possible bugs caused by empty...
[lyx.git] / src / BufferView.cpp
index 4c3ab44f65e647eccecadf78bc146a75eb5a1348..9abb3d7d1f4a86f2f1d18dbfaa45a946d7149117 100644 (file)
@@ -257,7 +257,7 @@ struct BufferView::Private
 
 
 BufferView::BufferView(Buffer & buf)
-       : width_(0), height_(0), buffer_(buf), d(new Private(*this))
+       : width_(0), height_(0), full_screen_(false), buffer_(buf), d(new Private(*this))
 {
        d->xsel_cache_.set = false;
        d->intl_.initKeyMapper(lyxrc.use_kbmap);
@@ -287,6 +287,24 @@ BufferView::~BufferView()
 }
 
 
+int BufferView::rightMargin() const
+{
+       // The additional test for the case the outliner is opened.
+       if (!full_screen_ ||
+               !lyxrc.full_screen_limit ||
+               width_ < lyxrc.full_screen_width + 20)
+                       return 10;
+
+       return (width_ - lyxrc.full_screen_width) / 2;
+}
+
+
+int BufferView::leftMargin() const
+{
+       return rightMargin();
+}
+
+
 Intl & BufferView::getIntl()
 {
        return d->intl_;
@@ -877,7 +895,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
 
        case LFUN_LAYOUT:
        case LFUN_LAYOUT_PARAGRAPH:
-               flag.enabled(cur.inset().forceDefaultParagraphs(cur.idx()));
+               flag.enabled(cur.inset().allowParagraphCustomization(cur.idx()));
                break;
 
        case LFUN_INSET_SETTINGS: {
@@ -1001,24 +1019,24 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                        DocIterator dit = b->getParFromID(id);
                        if (dit.atEnd()) {
                                LYXERR(Debug::INFO, "No matching paragraph found! [" << id << "].");
+                               ++i;
+                               continue;
+                       }
+                       LYXERR(Debug::INFO, "Paragraph " << dit.paragraph().id()
+                               << " found in buffer `"
+                               << b->absFileName() << "'.");
+
+                       if (b == &buffer_) {
+                               // Set the cursor
+                               setCursor(dit);
+                               processUpdateFlags(Update::Force | Update::FitCursor);
                        } else {
-                               LYXERR(Debug::INFO, "Paragraph " << dit.paragraph().id()
-                                       << " found in buffer `"
-                                       << b->absFileName() << "'.");
-
-                               if (b == &buffer_) {
-                                       // Set the cursor
-                                       setCursor(dit);
-                                       showCursor();
-                               } else {
-                                       // Switch to other buffer view and resend cmd
-                                       theLyXFunc().dispatch(FuncRequest(
-                                               LFUN_BUFFER_SWITCH, b->absFileName()));
-                                       theLyXFunc().dispatch(cmd);
-                               }
-                               break;
+                               // Switch to other buffer view and resend cmd
+                               theLyXFunc().dispatch(FuncRequest(
+                                       LFUN_BUFFER_SWITCH, b->absFileName()));
+                               theLyXFunc().dispatch(cmd);
                        }
-                       ++i;
+                       break;
                }
                break;
        }
@@ -1091,7 +1109,10 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                break;
 
        case LFUN_WORD_FIND:
-               find(this, cmd);
+               if (find(this, cmd))
+                       showCursor();
+               else
+                       message(_("String not found!"));
                break;
 
        case LFUN_WORD_REPLACE: {
@@ -1336,23 +1357,14 @@ void BufferView::clearSelection()
 
 void BufferView::resize(int width, int height)
 {
-       bool initialResize = (height_ == 0);
-       
        // Update from work area
        width_ = width;
        height_ = height;
 
        // Clear the paragraph height cache.
        d->par_height_.clear();
-
+       // Redo the metrics.
        updateMetrics();
-
-       // view got his initial size, make sure that
-       // the cursor has a proper position
-       if (initialResize) {
-               updateScrollbar();
-               showCursor();
-       }
 }
 
 
@@ -1710,6 +1722,9 @@ void BufferView::putSelectionAt(DocIterator const & cur,
                } else
                        d->cursor_.setSelection(d->cursor_, length);
        }
+       // Ensure a redraw happens in any case because the new selection could 
+       // possibly be on the same screen as the previous selection.
+       processUpdateFlags(Update::Force | Update::FitCursor);
 }