]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Account for old versions of Pygments
[lyx.git] / src / BufferView.cpp
index a6b2ae2ac45c6a3df968beb24e2212b6a70e341e..77ab989d193962f602d96435b8c0fbc1f41e0128 100644 (file)
@@ -351,8 +351,8 @@ BufferView::~BufferView()
 
 int BufferView::rightMargin() const
 {
-       // The value used to be hardcoded to 10, which is 2.5mm at 100dpi
-       int const default_margin = Length(2.5, Length::MM).inPixels(0);
+       // The value used to be hardcoded to 10, which is 0.1in at 100dpi
+       int const default_margin = Length(0.1, Length::IN).inPixels(0);
        // The additional test for the case the outliner is opened.
        if (!full_screen_ || !lyxrc.full_screen_limit
            || width_ < lyxrc.full_screen_width + 2 * default_margin)
@@ -368,6 +368,13 @@ int BufferView::leftMargin() const
 }
 
 
+int BufferView::inPixels(Length const & len) const
+{
+       Font const font = buffer().params().getFont();
+       return len.inPixels(workWidth(), theFontMetrics(font).em());
+}
+
+
 bool BufferView::isTopScreen() const
 {
        return 0 == d->scrollbarParameters_.min;
@@ -1028,7 +1035,10 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
        if (buffer_.isReadonly()
            && !lyxaction.funcHasFlag(act, LyXAction::ReadOnly)
            && !lyxaction.funcHasFlag(act, LyXAction::NoBuffer)) {
-               flag.message(from_utf8(N_("Document is read-only")));
+               if (buffer_.hasReadonlyFlag())
+                       flag.message(from_utf8(N_("Document is read-only")));
+               else
+                       flag.message(from_utf8(N_("Document has been modified externally")));
                flag.setEnabled(false);
                return true;
        }
@@ -2345,14 +2355,8 @@ int BufferView::scrollUp(int offset)
 
 bool BufferView::setCursorFromRow(int row)
 {
-       return setCursorFromRow(row, buffer_.texrow());
-}
-
-
-bool BufferView::setCursorFromRow(int row, TexRow const & texrow)
-{
-       TextEntry start, end;
-       tie(start,end) = texrow.getEntriesFromRow(row);
+       TexRow::TextEntry start, end;
+       tie(start,end) = buffer_.texrow().getEntriesFromRow(row);
        LYXERR(Debug::LATEX,
               "setCursorFromRow: for row " << row << ", TexRow has found "
               "start (id=" << start.id << ",pos=" << start.pos << "), "
@@ -2361,7 +2365,8 @@ bool BufferView::setCursorFromRow(int row, TexRow const & texrow)
 }
 
 
-bool BufferView::setCursorFromEntries(TextEntry start, TextEntry end)
+bool BufferView::setCursorFromEntries(TexRow::TextEntry start,
+                                      TexRow::TextEntry end)
 {
        DocIterator dit_start, dit_end;
        tie(dit_start,dit_end) =
@@ -2809,19 +2814,7 @@ Point BufferView::coordOffset(DocIterator const & dit) const
                }
 
                // remember width for the case that sl.inset() is positioned in an RTL inset
-               if (i && dit[i - 1].text()) {
-                       // If this Inset is inside a Text Inset, retrieve the Dimension
-                       // from the containing text instead of using Inset::dimension() which
-                       // might not be implemented.
-                       // FIXME (Abdel 23/09/2007): this is a bit messy because of the
-                       // elimination of Inset::dim_ cache. This coordOffset() method needs
-                       // to be rewritten in light of the new design.
-                       Dimension const & dim = coordCache().getInsets().dim(&sl.inset());
-                       lastw = dim.wid;
-               } else {
-                       Dimension const dim = sl.inset().dimension(*this);
-                       lastw = dim.wid;
-               }
+               lastw = sl.inset().dimension(*this).wid;
 
                //lyxerr << "Cursor::getPos, i: "
                // << i << " x: " << xx << " y: " << y << endl;
@@ -2896,7 +2889,7 @@ bool BufferView::paragraphVisible(DocIterator const & dit) const
 void BufferView::cursorPosAndHeight(Point & p, int & h) const
 {
        Cursor const & cur = cursor();
-       Font const font = cur.getFont();
+       Font const font = cur.real_current_font;
        frontend::FontMetrics const & fm = theFontMetrics(font);
        int const asc = fm.maxAscent();
        int const des = fm.maxDescent();