[LyX/master] Change cell numbers so that 0 is the main cell

2018-11-07 Thread Jean-Marc Lasgouttes
commit 097da3a943dc5b7df5272860662c41ed625d849a
Author: Jean-Marc Lasgouttes 
Date:   Mon Nov 5 21:29:47 2018 -1000

Change cell numbers so that 0 is the main cell

This leads to code simplification in overset, root and underset.
Further simplification is possible.
---
 src/mathed/InsetMathOverset.cpp  |   43 +++--
 src/mathed/InsetMathOverset.h|4 +--
 src/mathed/InsetMathRoot.cpp |   23 ---
 src/mathed/InsetMathRoot.h   |5 +---
 src/mathed/InsetMathStackrel.cpp |   56 +++--
 src/mathed/InsetMathStackrel.h   |4 ---
 src/mathed/InsetMathUnderset.cpp |   41 ++-
 src/mathed/InsetMathUnderset.h   |6 
 8 files changed, 86 insertions(+), 96 deletions(-)

diff --git a/src/mathed/InsetMathOverset.cpp b/src/mathed/InsetMathOverset.cpp
index 1295685..b659a9e 100644
--- a/src/mathed/InsetMathOverset.cpp
+++ b/src/mathed/InsetMathOverset.cpp
@@ -19,6 +19,8 @@
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 
+#include "support/lassert.h"
+
 using namespace std;
 
 namespace lyx {
@@ -32,14 +34,14 @@ Inset * InsetMathOverset::clone() const
 void InsetMathOverset::metrics(MetricsInfo & mi, Dimension & dim) const
 {
Changer dummy2 = mi.base.changeEnsureMath();
-   Dimension dim1;
-   cell(1).metrics(mi, dim1);
-   Changer dummy = mi.base.changeFrac();
Dimension dim0;
cell(0).metrics(mi, dim0);
-   dim.wid = max(dim0.width(), dim1.wid) + 4;
-   dim.asc = dim1.asc + dim0.height() + 4;
-   dim.des = dim1.des;
+   Changer dummy = mi.base.changeFrac();
+   Dimension dim1;
+   cell(1).metrics(mi, dim1);
+   dim.wid = max(dim1.width(), dim0.wid) + 4;
+   dim.asc = dim0.asc + dim1.height() + 4;
+   dim.des = dim0.des;
 }
 
 
@@ -47,13 +49,24 @@ void InsetMathOverset::draw(PainterInfo & pi, int x, int y) 
const
 {
Changer dummy2 = pi.base.changeEnsureMath();
Dimension const dim = dimension(*pi.base.bv);
-   Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
+   Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
int m  = x + dim.wid / 2;
-   int yo = y - dim1.asc - dim0.des - 1;
-   cell(1).draw(pi, m - dim1.wid / 2, y);
+   int yo = y - dim0.asc - dim1.des - 1;
+   cell(0).draw(pi, m - dim0.wid / 2, y);
Changer dummy = pi.base.changeFrac();
-   cell(0).draw(pi, m - dim0.width() / 2, yo);
+   cell(1).draw(pi, m - dim1.width() / 2, yo);
+}
+
+
+bool InsetMathOverset::idxUpDown(Cursor & cur, bool up) const
+{
+   idx_type target = up; // up ? 1 : 0, since upper cell has idx 1
+   if (cur.idx() == target)
+   return false;
+   cur.idx() = target;
+   cur.pos() = cur.cell().x2pos(&cur.bv(), cur.x_target());
+   return true;
 }
 
 
@@ -62,27 +75,27 @@ void InsetMathOverset::write(WriteStream & os) const
MathEnsurer ensurer(os);
if (os.fragile())
os << "\\protect";
-   os << "\\overset{" << cell(0) << "}{" << cell(1) << '}';
+   os << "\\overset{" << cell(1) << "}{" << cell(0) << '}';
 }
 
 
 void InsetMathOverset::normalize(NormalStream & os) const
 {
-   os << "[overset " << cell(0) << ' ' << cell(1) << ']';
+   os << "[overset " << cell(1) << ' ' << cell(0) << ']';
 }
 
 
 void InsetMathOverset::mathmlize(MathStream & ms) const
 {
-   ms << "" << cell(1) << cell(0) << "";
+   ms << "" << cell(0) << cell(1) << "";
 }
 
 
 void InsetMathOverset::htmlize(HtmlStream & os) const
 {
os << MTag("span", "class='overset'")
-<< MTag("span", "class='top'") << cell(0) << ETag("span")
-<< MTag("span") << cell(1) << ETag("span")
+<< MTag("span", "class='top'") << cell(1) << ETag("span")
+<< MTag("span") << cell(0) << ETag("span")
 << ETag("span");
 }
 
diff --git a/src/mathed/InsetMathOverset.h b/src/mathed/InsetMathOverset.h
index 1202bbc..eb6b86b 100644
--- a/src/mathed/InsetMathOverset.h
+++ b/src/mathed/InsetMathOverset.h
@@ -28,9 +28,7 @@ public:
///
void draw(PainterInfo & pi, int x, int y) const;
///
-   idx_type firstIdx() const 

[LyX/master] Fixup 097da3a9: update the math parser

2018-11-07 Thread Jean-Marc Lasgouttes
commit 974766cd1c90edb7cc70bd0146ee59594aef321a
Author: Jean-Marc Lasgouttes 
Date:   Wed Nov 7 08:24:54 2018 -1000

Fixup 097da3a9: update the math parser

One has to account for the change in cell numbering.
---
 src/mathed/MathParser.cpp |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp
index 21bdb66..2452b6b 100644
--- a/src/mathed/MathParser.cpp
+++ b/src/mathed/MathParser.cpp
@@ -1432,12 +1432,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned 
flags,
parse(ar, FLAG_OPTION, mode);
if (!ar.empty()) {
cell->push_back(MathAtom(new 
InsetMathRoot(buf)));
-   cell->back().nucleus()->cell(0) = ar;
-   parse(cell->back().nucleus()->cell(1), 
FLAG_ITEM, mode);
-   } else {
+   cell->back().nucleus()->cell(1) = ar;
+   } else
cell->push_back(MathAtom(new 
InsetMathSqrt(buf)));
-   parse(cell->back().nucleus()->cell(0), 
FLAG_ITEM, mode);
-   }
+   parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
}
 
else if (t.cs() == "cancelto") {
@@ -1529,8 +1527,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
cell->push_back(MathAtom(new InsetMathStackrel(buf, 
!ar.empty(;
if (!ar.empty())
cell->back().nucleus()->cell(2) = ar;
-   parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
+   parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
}
 
else if (t.cs() == "xrightarrow" || t.cs() == "xleftarrow") {
@@ -2034,6 +2032,12 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
putback();
}
 
+   else if (l->inset == "underset" || l->inset == 
"overset") {
+   cell->push_back(createInsetMath(t.cs(), 
buf));
+   parse(cell->back().nucleus()->cell(1), 
FLAG_ITEM, mode);
+   parse(cell->back().nucleus()->cell(0), 
FLAG_ITEM, mode);
+   }
+
else {
MathAtom at = createInsetMath(t.cs(), 
buf);
for (InsetMath::idx_type i = 0; i < 
at->nargs(); ++i)


[LyX/master] Fixup 097da3a9: fix horizontal navigatiion in InsetMathRoot

2018-11-07 Thread Jean-Marc Lasgouttes
commit 2daf493cbcb3b72ae93f7286e781508957fd1cc6
Author: Jean-Marc Lasgouttes 
Date:   Wed Nov 7 11:53:00 2018 -1000

Fixup 097da3a9: fix horizontal navigatiion in InsetMathRoot

Exchanging cells 0 and 1 requires to implement idxBackWard/Forward.
---
 src/mathed/InsetMathRoot.cpp |   24 
 src/mathed/InsetMathRoot.h   |4 
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/mathed/InsetMathRoot.cpp b/src/mathed/InsetMathRoot.cpp
index b3723fa..5659511 100644
--- a/src/mathed/InsetMathRoot.cpp
+++ b/src/mathed/InsetMathRoot.cpp
@@ -156,6 +156,30 @@ bool InsetMathRoot::idxUpDown(Cursor & cur, bool up) const
 }
 
 
+bool InsetMathRoot::idxForward(Cursor & cur) const
+{
+   // nucleus is 0 and is on the right
+   if (cur.idx() == 0)
+   return false;
+   else
+   cur.idx() = 0;
+
+   return true;
+}
+
+
+bool InsetMathRoot::idxBackward(Cursor & cur) const
+{
+   // nucleus is 0 and is on the right
+   if (cur.idx() == 1)
+   return false;
+   else
+   cur.idx() = 1;
+
+   return true;
+}
+
+
 void InsetMathRoot::maple(MapleStream & os) const
 {
os << '(' << cell(0) << ")^(1/(" << cell(1) <<"))";
diff --git a/src/mathed/InsetMathRoot.h b/src/mathed/InsetMathRoot.h
index 63c35b6..d9e92c0 100644
--- a/src/mathed/InsetMathRoot.h
+++ b/src/mathed/InsetMathRoot.h
@@ -26,6 +26,10 @@ public:
InsetMathRoot(Buffer * buf);
///
bool idxUpDown(Cursor & cur, bool up) const;
+   ///
+   bool idxForward(Cursor & cur) const;
+   ///
+   bool idxBackward(Cursor & cur) const;
 
///
void metrics(MetricsInfo & mi, Dimension & dim) const;


[LyX/master] improve left/right navigation in root inset

2018-11-09 Thread Jean-Marc Lasgouttes
commit ee9451aaf58d15e82b1e25eea13a11a6b4906cad
Author: Jean-Marc Lasgouttes 
Date:   Thu Nov 8 21:22:04 2018 -0800

improve left/right navigation in root inset

Now the cursor is correctly set when changing cell with xursor left/right.
---
 src/mathed/InsetMathRoot.cpp |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mathed/InsetMathRoot.cpp b/src/mathed/InsetMathRoot.cpp
index 5659511..f4c8bf8 100644
--- a/src/mathed/InsetMathRoot.cpp
+++ b/src/mathed/InsetMathRoot.cpp
@@ -161,9 +161,9 @@ bool InsetMathRoot::idxForward(Cursor & cur) const
// nucleus is 0 and is on the right
if (cur.idx() == 0)
return false;
-   else
-   cur.idx() = 0;
 
+   cur.idx() = 0;
+   cur.pos() = 0;
return true;
 }
 
@@ -173,9 +173,9 @@ bool InsetMathRoot::idxBackward(Cursor & cur) const
// nucleus is 0 and is on the right
if (cur.idx() == 1)
return false;
-   else
-   cur.idx() = 1;
 
+   cur.idx() = 1;
+   cur.pos() = cur.lastpos();
return true;
 }
 


[LyX/master] Make cell-forward/backward cycle in math

2018-11-09 Thread Jean-Marc Lasgouttes
commit 93db2bd08e4c1a9b5e78aecbb71055f22fa3683e
Author: Jean-Marc Lasgouttes 
Date:   Fri Nov 9 15:21:55 2018 +

Make cell-forward/backward cycle in math

Make cell-backward put the cursor at the end of cell when using
mac-like cursor movement.
---
 src/mathed/InsetMathGrid.cpp |   19 ---
 src/mathed/InsetMathNest.cpp |   18 +++---
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 5a4830c..4ce79bd 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -1432,25 +1432,6 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest 
& cmd)
splitCell(cur);
break;
 
-   case LFUN_CELL_BACKWARD:
-   // See below.
-   cur.selection(false);
-   if (!idxPrev(cur)) {
-   cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
-   cur.undispatched();
-   }
-   break;
-
-   case LFUN_CELL_FORWARD:
-   // Can't handle selection by additional 'shift' as this is
-   // hard bound to LFUN_CELL_BACKWARD
-   cur.selection(false);
-   if (!idxNext(cur)) {
-   cmd = FuncRequest(LFUN_FINISHED_FORWARD);
-   cur.undispatched();
-   }
-   break;
-
case LFUN_NEWLINE_INSERT: {
cur.recordUndoInset();
row_type const r = cur.row();
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 857fd7f..8cd1254 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -216,7 +216,7 @@ bool InsetMathNest::idxPrev(Cursor & cur) const
if (cur.idx() == 0)
return false;
--cur.idx();
-   cur.pos() = cur.lastpos();
+   cur.pos() = lyxrc.mac_like_cursor_movement ? cur.lastpos() : 0;
return true;
 }
 
@@ -793,12 +793,24 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest 
& cmd)
 
case LFUN_CELL_FORWARD:
cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
-   cur.inset().idxNext(cur);
+   cur.selHandle(false);
+   cur.clearTargetX();
+   cur.macroModeClose();
+   if (!cur.inset().idxNext(cur)) {
+   cur.idx() = firstIdx();
+   cur.pos() = 0;
+   }
break;
 
case LFUN_CELL_BACKWARD:
cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
-   cur.inset().idxPrev(cur);
+   cur.selHandle(false);
+   cur.clearTargetX();
+   cur.macroModeClose();
+   if (!cur.inset().idxPrev(cur)) {
+   cur.idx() = lastIdx();
+   cur.pos() = lyxrc.mac_like_cursor_movement ? 
cur.lastpos() : 0;
+   }
break;
 
case LFUN_WORD_DELETE_BACKWARD:


[LyX/master] Change IgnoreFormats to a proper class

2018-11-09 Thread Jean-Marc Lasgouttes
commit 7055bb0098f2dd60bfa8054a4841a6c5bd485eb3
Author: Jean-Marc Lasgouttes 
Date:   Thu Nov 8 21:07:17 2018 -0800

Change IgnoreFormats to a proper class

Instantiate a global variabble holding the formats and allow to modify
it using the helper function setIgnoreFormat.
---
 src/lyxfind.cpp |  220 +--
 src/lyxfind.h   |3 +
 2 files changed, 120 insertions(+), 103 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 85e2d3b..4fc8528 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -59,6 +59,111 @@ using namespace lyx::support;
 
 namespace lyx {
 
+
+// Helper class for deciding what should be ignored
+class IgnoreFormats {
+ public:
+   ///
+   IgnoreFormats()
+   : ignoreFamily_(false), ignoreSeries_(false),
+ ignoreShape_(false), ignoreUnderline_(false),
+ ignoreMarkUp_(false), ignoreStrikeOut_(false),
+ ignoreSectioning_(false), ignoreFrontMatter_(true),
+ ignoreColor_(false), ignoreLanguage_(false) {}
+   ///
+   bool getFamily() { return ignoreFamily_; };
+   ///
+   bool getSeries() { return ignoreSeries_; };
+   ///
+   bool getShape() { return ignoreShape_; };
+   ///
+   bool getUnderline() { return ignoreUnderline_; };
+   ///
+   bool getMarkUp() { return ignoreMarkUp_; };
+   ///
+   bool getStrikeOut() { return ignoreStrikeOut_; };
+   ///
+   bool getSectioning() { return ignoreSectioning_; };
+   ///
+   bool getFrontMatter() { return ignoreFrontMatter_; };
+   ///
+   bool getColor() { return ignoreColor_; };
+   ///
+   bool getLanguage() { return ignoreLanguage_; };
+   ///
+   void setIgnoreFormat(string type, bool value);
+
+private:
+   ///
+   bool ignoreFamily_;
+   ///
+   bool ignoreSeries_;
+   ///
+   bool ignoreShape_;
+   ///
+   bool ignoreUnderline_;
+   ///
+   bool ignoreMarkUp_;
+   ///
+   bool ignoreStrikeOut_;
+   ///
+   bool ignoreSectioning_;
+   ///
+   bool ignoreFrontMatter_;
+   ///
+   bool ignoreColor_;
+   ///
+   bool ignoreLanguage_;
+};
+
+
+void IgnoreFormats::setIgnoreFormat(string type, bool value)
+{
+   if (type == "color") {
+   ignoreColor_ = value;
+   }
+   else if (type == "language") {
+   ignoreLanguage_ = value;
+   }
+   else if (type == "sectioning") {
+   ignoreSectioning_ = value;
+   ignoreFrontMatter_ = value;
+   }
+   else if (type == "font") {
+   ignoreSeries_ = value;
+   ignoreShape_ = value;
+   ignoreFamily_ = value;
+   }
+   else if (type == "series") {
+   ignoreSeries_ = value;
+   }
+   else if (type == "shape") {
+   ignoreShape_ = value;
+   }
+   else if (type == "family") {
+   ignoreFamily_ = value;
+   }
+   else if (type == "markup") {
+   ignoreMarkUp_ = value;
+   }
+   else if (type == "underline") {
+   ignoreUnderline_ = value;
+   }
+   else if (type == "strike") {
+   ignoreStrikeOut_ = value;
+   }
+}
+
+// The global variable that can be changed from outside
+IgnoreFormats ignoreFormats;
+
+
+void setIgnoreFormat(string type, bool value)
+{
+   ignoreFormats.setIgnoreFormat(type, value);
+}
+
+
 namespace {
 
 bool parse_bool(docstring & howto)
@@ -1121,96 +1226,6 @@ typedef map KeysMap;
 typedef vector< KeyInfo> Entries;
 static KeysMap keys = map();
 
-class IgnoreFormats {
-  static bool ignoreFamily;
-  static bool ignoreSeries;
-  static bool ignoreShape;
-  static bool ignoreUnderline;
-  static bool ignoreMarkUp;
-  static bool ignoreStrikeOut;
-  static bool ignoreSectioning;
-  static bool ignoreFrontMatter;
-  static bool ignoreColor;
-  static bool ignoreLanguage;
- public:
-  bool getFamily() { return ignoreFamily; };
-  bool getSeries() { return ignoreSeries; };
-  bool getShape() { return ignoreShape; };
-  bool getUnderline() { return ignoreUnderline; };
-  bool getMarkUp() { return ignoreMarkUp; };
-  bool getStrikeOut() { return ignoreStrikeOut; };
-  bool getSectioning() { return ignoreSectioning; };
-  bool getFrontMatter() { return ignoreFrontMatter; };
-  bool getColor() { return ignoreColor; };
-  bool getLanguage() { return ignoreLanguage; };
-
-  void setIgnoreFormat(string type, bool value);
-};
-
-bool IgnoreFormats::ignoreFamily = false;
-bool IgnoreFormats::ignoreSeries = false;
-bool IgnoreFormats::ignoreShape  = false;
-bool IgnoreFormats::ignoreUnderline  = false;
-bool IgnoreFormats::ignoreMarkUp = false;
-bool IgnoreFormats::ignoreStrikeOut  = false;
-bool IgnoreFormats::ignoreS

[LyX/master] Typo

2018-11-12 Thread Jean-Marc Lasgouttes
commit 1ff0816a022355d0a7200eb69eca374bd65d34c5
Author: Jean-Marc Lasgouttes 
Date:   Mon Nov 12 11:41:54 2018 +0100

Typo
---
 src/BufferView.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index ce1ec72..c8a43a0 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -493,7 +493,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
return;
 
/* FIXME We would like to avoid doing this here, since it is very
-* expensive and is called in updateBuffer already. Howaver, even
+* expensive and is called in updateBuffer already. However, even
 * inserting a plain character can invalidate the overly fragile
 * tables of child documents built by updateMacros. Some work is
 * needed to avoid doing that when not necessary.


[LyX/2.3.x] Avoid extra space in tooltips

2018-11-21 Thread Jean-Marc Lasgouttes
commit c1df5fb6efab2f8744a4052638f5e24fe88a7014
Author: Jean-Marc Lasgouttes 
Date:   Sun Nov 4 13:53:36 2018 -1000

Avoid extra space in tooltips

When using QTextDocument to check the natutal size of a text, one has
to remove the text margin, which is not useful here.

Fixes bug #11353.

(cherry picked from commit 7db99672e6838535d837096ab2344e7ecedb47e3)
---
 src/frontends/qt4/qt_helpers.cpp |1 +
 status.23x   |2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/frontends/qt4/qt_helpers.cpp b/src/frontends/qt4/qt_helpers.cpp
index d228510..d23ae9c 100644
--- a/src/frontends/qt4/qt_helpers.cpp
+++ b/src/frontends/qt4/qt_helpers.cpp
@@ -645,6 +645,7 @@ QString formatToolTip(QString text, int em)
QTextDocument td("");
td.setHtml(text);
td.setDefaultFont(QToolTip::font());
+   td.setDocumentMargin(0);
td.setTextWidth(px_width);
double best_width = td.idealWidth();
// Set the line wrapping with appropriate width
diff --git a/status.23x b/status.23x
index 6a85ae5..3c6bac7 100644
--- a/status.23x
+++ b/status.23x
@@ -181,6 +181,8 @@ What's new
 
 - Fix display of overset, underset, and stackrel insets (bug 11367).
 
+- Avoid extra space at the end of tooltips (bug 11353).
+
 
 * INTERNALS
 


[LyX/master] Show cursor correctly whn loading file

2018-11-22 Thread Jean-Marc Lasgouttes
commit 2dc84b69d5a040e6343e21606f1c16a7c0957383
Author: Jean-Marc Lasgouttes 
Date:   Wed Nov 21 13:49:20 2018 +0100

Show cursor correctly whn loading file

This is a fixup to 8d8988de4. When a file is loaded and the cursor is
set, it is required to first compute metrics to be able to scroll the
screen correctly.

Fixes bug #11377.
---
 src/BufferView.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 8d15c97..95024f5 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -868,7 +868,7 @@ bool BufferView::moveToPosition(pit_type bottom_pit, 
pos_type bottom_pos,
d->cursor_.setCurrentFont();
// Do not forget to reset the anchor (see #9912)
d->cursor_.resetAnchor();
-   processUpdateFlags(Update::FitCursor);
+   processUpdateFlags(Update::Force | Update::FitCursor);
}
 
return success;


[LyX/master] Update to boost 1.68

2018-11-23 Thread Jean-Marc Lasgouttes
commit c40d23deacc277e4a862db803c565ff04e6031f1
Author: Jean-Marc Lasgouttes 
Date:   Fri Nov 23 16:14:23 2018 +0100

Update to boost 1.68

This avoids warnings from gcc 8

 3rdparty/boost/boost/bind/bind.hpp |   37 +
 3rdparty/boost/boost/bind/bind_cc.hpp  |   60 +-
 3rdparty/boost/boost/bind/bind_mf_cc.hpp   |   72 +-
 3rdparty/boost/boost/config/auto_link.hpp  |   30 +-
 3rdparty/boost/boost/config/compiler/borland.hpp   |4 +
 3rdparty/boost/boost/config/compiler/clang.hpp |   17 +-
 3rdparty/boost/boost/config/compiler/codegear.hpp  |4 +
 .../boost/boost/config/compiler/common_edg.hpp |4 +
 3rdparty/boost/boost/config/compiler/cray.hpp  |  442 +-
 3rdparty/boost/boost/config/compiler/diab.hpp  |9 +-
 .../boost/boost/config/compiler/digitalmars.hpp|3 +
 3rdparty/boost/boost/config/compiler/gcc.hpp   |   20 +-
 3rdparty/boost/boost/config/compiler/gcc_xml.hpp   |3 +
 3rdparty/boost/boost/config/compiler/intel.hpp |9 +-
 .../boost/boost/config/compiler/metrowerks.hpp |3 +
 3rdparty/boost/boost/config/compiler/mpw.hpp   |3 +
 3rdparty/boost/boost/config/compiler/nvcc.hpp  |6 +-
 3rdparty/boost/boost/config/compiler/pathscale.hpp |3 +
 3rdparty/boost/boost/config/compiler/pgi.hpp   |  161 +--
 3rdparty/boost/boost/config/compiler/sunpro_cc.hpp |9 +-
 3rdparty/boost/boost/config/compiler/vacpp.hpp |8 +
 3rdparty/boost/boost/config/compiler/visualc.hpp   |   33 +-
 3rdparty/boost/boost/config/compiler/xlcpp.hpp |9 +
 3rdparty/boost/boost/config/compiler/xlcpp_zos.hpp |2 +
 .../boost/config/detail/select_compiler_config.hpp |8 +-
 3rdparty/boost/boost/config/detail/suffix.hpp  |   32 +-
 3rdparty/boost/boost/config/header_deprecated.hpp  |   26 +
 3rdparty/boost/boost/config/helper_macros.hpp  |   37 +
 3rdparty/boost/boost/config/platform/cygwin.hpp|   11 +
 3rdparty/boost/boost/config/platform/vxworks.hpp   |  233 ++--
 3rdparty/boost/boost/config/pragma_message.hpp |   31 +
 3rdparty/boost/boost/config/stdlib/dinkumware.hpp  |   11 +-
 3rdparty/boost/boost/config/stdlib/libcomo.hpp |1 +
 3rdparty/boost/boost/config/stdlib/libcpp.hpp  |   13 +-
 3rdparty/boost/boost/config/stdlib/libstdcpp3.hpp  |9 +-
 3rdparty/boost/boost/config/stdlib/modena.hpp  |1 +
 3rdparty/boost/boost/config/stdlib/msl.hpp |1 +
 3rdparty/boost/boost/config/stdlib/roguewave.hpp   |1 +
 3rdparty/boost/boost/config/stdlib/sgi.hpp |1 +
 3rdparty/boost/boost/config/stdlib/stlport.hpp |1 +
 3rdparty/boost/boost/config/stdlib/vacpp.hpp   |1 +
 3rdparty/boost/boost/config/stdlib/xlcpp_zos.hpp   |1 +
 3rdparty/boost/boost/config/workaround.hpp |2 +
 3rdparty/boost/boost/container/container_fwd.hpp   |   35 +-
 .../container_hash/detail/float_functions.hpp  |  336 
 .../boost/container_hash/detail/hash_float.hpp |  271 +++
 .../boost/boost/container_hash/detail/limits.hpp   |   62 +
 3rdparty/boost/boost/container_hash/extensions.hpp |  414 +
 3rdparty/boost/boost/container_hash/hash.hpp   |  761 +
 3rdparty/boost/boost/container_hash/hash_fwd.hpp   |   36 +
 3rdparty/boost/boost/core/addressof.hpp|   84 +-
 3rdparty/boost/boost/cstdint.hpp   |   30 +-
 3rdparty/boost/boost/detail/basic_pointerbuf.hpp   |2 +-
 3rdparty/boost/boost/function.hpp  |   16 +-
 .../boost/function/detail/gen_maybe_include.pl |2 +
 .../boost/boost/function/detail/maybe_include.hpp  |  102 ++
 3rdparty/boost/boost/function/function_base.hpp|   20 +
 .../boost/boost/function/function_template.hpp |   17 +-
 3rdparty/boost/boost/function_output_iterator.hpp  |   56 +-
 3rdparty/boost/boost/functional/hash.hpp   |3 +-
 .../functional/hash/detail/float_functions.hpp |  336 
 .../boost/functional/hash/detail/hash_float.hpp|  271 ---
 .../boost/boost/functional/hash/detail/limits.hpp  |   62 -
 .../boost/boost/functional/hash/extensions.hpp |  318 
 3rdparty/boost/boost/functional/hash/hash.hpp  |  595 ---
 3rdparty/boost/boost/functional/hash/hash_fwd.hpp  |   36 -
 3rdparty/boost/boost/functional/hash_fwd.hpp   |7 +-
 3rdparty/boost/boost/iterator.hpp  |   20 -
 3rdparty/boost/boost/iterator/distance.hpp |   65 +
 .../boost/iterator/function_output_iterator.hpp|   62 +
 3rdparty/boost/boost/iterator/iterator_adaptor.hpp |2 -
 .../boost/boost/iterator/iterator_categories.hpp   |5 +-
 .../boost/boost/iterator/iterator_concepts.hpp |   18 +-
 3rdparty/boost/boost/iterator/iterator_facade.hpp  |3 +-
 3rdparty/boost/boost/iterator/iterator_traits.hpp  |   13 +-
 3rdparty/boost/boost/iterator/reverse_iterator.hpp |1 -
 .../detail/converter_lexical_streams.hpp   |   14 +-
 3rdparty/boost/boost/math

[LyX/master] Fix undo after breaking a nested paragraph

2018-11-23 Thread Jean-Marc Lasgouttes
commit 57feb0fed0c078903900aaea069c49207c8cb9ac
Author: Jean-Marc Lasgouttes 
Date:   Fri Nov 23 16:53:53 2018 +0100

Fix undo after breaking a nested paragraph

We have to take into account that Buffer::updateBuffer can modify the 
document.

Fix bug #11292.
---
 src/frontends/qt4/GuiApplication.cpp |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index c476109..b9ba830 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -1412,11 +1412,13 @@ DispatchResult const & 
GuiApplication::dispatch(FuncRequest const & cmd)
// This handles undo groups automagically
UndoGroupHelper ugh(buffer);
dispatch(cmd, dr);
+   // redraw the screen at the end (first of the two drawing 
steps).
+   // This is done unless explicitly requested otherwise.
+   // This code is kept inside the undo group because updateBuffer
+   // can create undo actions (see #11292)
+   updateCurrentView(cmd, dr);
}
 
-   // redraw the screen at the end (first of the two drawing steps).
-   // This is done unless explicitly requested otherwise
-   updateCurrentView(cmd, dr);
d->dispatch_result_ = dr;
return d->dispatch_result_;
 }


[LyX/2.3.x] Show cursor correctly when loading file

2018-11-23 Thread Jean-Marc Lasgouttes
commit f7ebe1f70f137e8e08563ef4b8a8579a9a0ec40f
Author: Jean-Marc Lasgouttes 
Date:   Wed Nov 21 13:49:20 2018 +0100

Show cursor correctly when loading file

This is a fixup to 4ecbff00. When a file is loaded and the cursor is
set, it is required to first compute metrics to be able to scroll the
screen correctly.

Fixes bug #11377.

(cherry picked from commit 2dc84b69d5a040e6343e21606f1c16a7c0957383)
---
 src/BufferView.cpp |2 +-
 status.23x |4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 173c7b0..637c5b0 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -852,7 +852,7 @@ bool BufferView::moveToPosition(pit_type bottom_pit, 
pos_type bottom_pos,
d->cursor_.setCurrentFont();
// Do not forget to reset the anchor (see #9912)
d->cursor_.resetAnchor();
-   processUpdateFlags(Update::FitCursor);
+   processUpdateFlags(Update::Force | Update::FitCursor);
}
 
return success;
diff --git a/status.23x b/status.23x
index 3c6bac7..4060bc9 100644
--- a/status.23x
+++ b/status.23x
@@ -160,7 +160,7 @@ What's new
 
 - Avoid white space before math completion (bug 11283).
 
-- View and change Plural, Capitalization, and No Prefix options for 
+- View and change Plural, Capitalization, and No Prefix options for
   cross-references from the context menu (bug 11070).
 
 - Don't step counters in deleted material (bug 11135).
@@ -183,6 +183,8 @@ What's new
 
 - Avoid extra space at the end of tooltips (bug 11353).
 
+- Show cursor correctly when loading file (bug 11377).
+
 
 * INTERNALS
 


[LyX/master] Fix compilation with msvc 2015

2018-11-24 Thread Jean-Marc Lasgouttes
commit e2a3dd1167b6e3350245500fa7cadcc356e59b8e
Author: Jean-Marc Lasgouttes 
Date:   Sat Nov 24 19:17:31 2018 +0100

Fix compilation with msvc 2015

Without this, the compiler does not know whether 0 is a size_t or char
const *.
---
 src/lyxfind.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 63a3a44..c1f9b5a 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -2406,7 +2406,7 @@ int MatchStringAdv::findAux(DocIterator const & cur, int 
len, bool at_begin) con
else
result =  m[m.size() - close_wildcards].first - 
m[0].first;
 
-   size_t pos = m.position(0);
+   size_t pos = m.position(size_t(0));
// Ignore last closing characters
while (result > 0) {
if (str[pos+result-1] == '}')


[LyX/master] Set buffer correctly when changing math space type.

2018-12-13 Thread Jean-Marc Lasgouttes
commit 2ec25c8eef8c9acca3cb572800eab933c8564831
Author: Jean-Marc Lasgouttes 
Date:   Thu Dec 13 10:27:20 2018 +0100

Set buffer correctly when changing math space type.

Fixes bug #7747.
---
 src/mathed/InsetMathSpace.cpp |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/mathed/InsetMathSpace.cpp b/src/mathed/InsetMathSpace.cpp
index 627664b..db09609 100644
--- a/src/mathed/InsetMathSpace.cpp
+++ b/src/mathed/InsetMathSpace.cpp
@@ -320,9 +320,11 @@ void InsetMathSpace::doDispatch(Cursor & cur, FuncRequest 
& cmd)
case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "mathspace") {
MathData ar;
+   Buffer * buf = buffer_;
if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
cur.recordUndo();
*this = *ar[0].nucleus()->asSpaceInset();
+   buffer_ = buf;
break;
}
}


[LyX/2.3.x] Remove old workaround that is not needed anymore

2018-12-13 Thread Jean-Marc Lasgouttes
commit 3a123b90af838b08680471d87170c38e56787df9
Author: Jean-Marc Lasgouttes 
Date:   Sat Nov 3 14:29:10 2018 +

Remove old workaround that is not needed anymore

This causes a compilation error with boost 1.69.

Fixes bug #11349.

(cherry picked from commit 76e99e9a20cf635d20effa597551f3a9af484465)
---
 src/support/FileName.cpp |9 -
 status.23x   |1 +
 2 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp
index 189c564..890c95a 100644
--- a/src/support/FileName.cpp
+++ b/src/support/FileName.cpp
@@ -67,15 +67,6 @@
 using namespace std;
 using namespace lyx::support;
 
-// OK, this is ugly, but it is the only workaround I found to compile
-// with gcc (any version) on a system which uses a non-GNU toolchain.
-// The problem is that gcc uses a weak symbol for a particular
-// instantiation and that the system linker usually does not
-// understand those weak symbols (seen on HP-UX, tru64, AIX and
-// others). Thus we force an explicit instanciation of this particular
-// template (JMarc)
-template struct boost::detail::crc_table_t<32, 0x04C11DB7, true>;
-
 namespace lyx {
 namespace support {
 
diff --git a/status.23x b/status.23x
index 7a2970d..44e2b2e 100644
--- a/status.23x
+++ b/status.23x
@@ -81,3 +81,4 @@ What's new
 
 * BUILD/INSTALLATION
 
+- Fix build with boost 1.69 (bug 11349).


[LyX/2.3.x] Fix selection of unmarked RtL text

2018-12-13 Thread Jean-Marc Lasgouttes
commit 7950ace3d96543e3099aa3bde823f970a1ce6a86
Author: Jean-Marc Lasgouttes 
Date:   Sat Nov 3 15:55:33 2018 +

Fix selection of unmarked RtL text

With Qt 5.11 at least, RtL text will be drawn RtL even when the
(undocumented) flag Qt::TextForceLeftToRight is applied to the
QTextLayout object. This creates selection issues for Hebrew text
marked as English.

The solution is to do the same as in breakAt_helper, that is prepend
the string with a direction override unicode character.

Doing this requires to introduce a TEXTLAYOUT_OFFSET constant that has
to be used wisely to account for this extra character.

Fixes bug #11284.

(cherry picked from commit 1bed76e2a1057ab2f3f33f01ec23956653265d4a)
---
 src/frontends/qt4/GuiFontMetrics.cpp |   27 ---
 status.23x   |2 ++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/frontends/qt4/GuiFontMetrics.cpp 
b/src/frontends/qt4/GuiFontMetrics.cpp
index b9eab85..8ed8228 100644
--- a/src/frontends/qt4/GuiFontMetrics.cpp
+++ b/src/frontends/qt4/GuiFontMetrics.cpp
@@ -237,12 +237,27 @@ GuiFontMetrics::getTextLayout(docstring const & s, bool 
const rtl,
PROFILE_CACHE_MISS(getTextLayout);
auto const ptl = make_shared();
ptl->setCacheEnabled(true);
-   ptl->setText(toqstr(s));
QFont copy = font_;
copy.setWordSpacing(wordspacing);
ptl->setFont(copy);
+#if 1
+   /* Use unicode override characters to enforce drawing direction
+* Source: http://www.iamcal.com/understanding-bidirectional-text/
+*/
+   if (rtl)
+   // Right-to-left override: forces to draw text right-to-left
+   ptl->setText(QChar(0x202E) + toqstr(s));
+   else
+   // Left-to-right override: forces to draw text left-to-right
+   ptl->setText(QChar(0x202D) + toqstr(s));
+#define TEXTLAYOUT_OFFSET 1
+#else
+   // FIXME: This does not work with Qt 5.11 (ticket #11284).
// Note that both setFlags and the enums are undocumented
ptl->setFlags(rtl ? Qt::TextForceRightToLeft : 
Qt::TextForceLeftToRight);
+   ptl->setText(toqstr(s));
+#define TEXTLAYOUT_OFFSET 0
+#endif
ptl->beginLayout();
ptl->createLine();
ptl->endLayout();
@@ -261,7 +276,9 @@ int GuiFontMetrics::pos2x(docstring const & s, int pos, 
bool const rtl,
 * not be the same when there are high-plan unicode characters
 * (bug #10443).
 */
-   int const qpos = toqstr(s.substr(0, pos)).length();
+   // TEXTLAYOUT_OFFSET accounts for a possible direction override
+   // character in front of the string.
+   int const qpos = toqstr(s.substr(0, pos)).length() + TEXTLAYOUT_OFFSET;
return static_cast(tl->lineForTextPosition(qpos).cursorToX(qpos));
 }
 
@@ -303,7 +320,9 @@ int GuiFontMetrics::x2pos(docstring const & s, int & x, 
bool const rtl,
 * (bug #10443).
 */
 #if QT_VERSION < 0x040801 || QT_VERSION >= 0x050100
-   return qstring_to_ucs4(tl->text().left(qpos)).length();
+   int pos = qstring_to_ucs4(tl->text().left(qpos)).length();
+   // there may be a direction override character in front of the string.
+   return max(pos - TEXTLAYOUT_OFFSET, 0);
 #else
/* Due to QTBUG-25536 in 4.8.1 <= Qt < 5.1.0, the string returned
 * by QString::toUcs4 (used by qstring_to_ucs4) may have wrong
@@ -313,6 +332,8 @@ int GuiFontMetrics::x2pos(docstring const & s, int & x, 
bool const rtl,
 * worthwhile to implement a dichotomy search if this shows up
 * under a profiler.
 */
+   // there may be a direction override character in front of the string.
+   qpos = max(qpos - TEXTLAYOUT_OFFSET, 0);
int pos = min(qpos, static_cast(s.length()));
while (pos >= 0 && toqstr(s.substr(0, pos)).length() != qpos)
--pos;
diff --git a/status.23x b/status.23x
index 44e2b2e..a1fb4d9 100644
--- a/status.23x
+++ b/status.23x
@@ -56,6 +56,8 @@ What's new
 
 - Fix reloading of local layout file (bug 11120).
 
+- Fix selection of unmarked RtL characters with Qt 5.11 (bug 11284).
+
 
 * INTERNALS
 


Re: [LyX/master] Update to boost 1.68

2018-12-13 Thread Jean-Marc Lasgouttes

Le 23/11/2018 à 16:14, Jean-Marc Lasgouttes a écrit :

commit c40d23deacc277e4a862db803c565ff04e6031f1
Author: Jean-Marc Lasgouttes 
Date:   Fri Nov 23 16:14:23 2018 +0100

 Update to boost 1.68
 
 This avoids warnings from gcc 8


Riki, can this be done in stable branch too? The warnings with gcc 8 are 
annoying.


JMarc



  3rdparty/boost/boost/bind/bind.hpp |   37 +
  3rdparty/boost/boost/bind/bind_cc.hpp  |   60 +-
  3rdparty/boost/boost/bind/bind_mf_cc.hpp   |   72 +-
  3rdparty/boost/boost/config/auto_link.hpp  |   30 +-
  3rdparty/boost/boost/config/compiler/borland.hpp   |4 +
  3rdparty/boost/boost/config/compiler/clang.hpp |   17 +-
  3rdparty/boost/boost/config/compiler/codegear.hpp  |4 +
  .../boost/boost/config/compiler/common_edg.hpp |4 +
  3rdparty/boost/boost/config/compiler/cray.hpp  |  442 +-
  3rdparty/boost/boost/config/compiler/diab.hpp  |9 +-
  .../boost/boost/config/compiler/digitalmars.hpp|3 +
  3rdparty/boost/boost/config/compiler/gcc.hpp   |   20 +-
  3rdparty/boost/boost/config/compiler/gcc_xml.hpp   |3 +
  3rdparty/boost/boost/config/compiler/intel.hpp |9 +-
  .../boost/boost/config/compiler/metrowerks.hpp |3 +
  3rdparty/boost/boost/config/compiler/mpw.hpp   |3 +
  3rdparty/boost/boost/config/compiler/nvcc.hpp  |6 +-
  3rdparty/boost/boost/config/compiler/pathscale.hpp |3 +
  3rdparty/boost/boost/config/compiler/pgi.hpp   |  161 +--
  3rdparty/boost/boost/config/compiler/sunpro_cc.hpp |9 +-
  3rdparty/boost/boost/config/compiler/vacpp.hpp |8 +
  3rdparty/boost/boost/config/compiler/visualc.hpp   |   33 +-
  3rdparty/boost/boost/config/compiler/xlcpp.hpp |9 +
  3rdparty/boost/boost/config/compiler/xlcpp_zos.hpp |2 +
  .../boost/config/detail/select_compiler_config.hpp |8 +-
  3rdparty/boost/boost/config/detail/suffix.hpp  |   32 +-
  3rdparty/boost/boost/config/header_deprecated.hpp  |   26 +
  3rdparty/boost/boost/config/helper_macros.hpp  |   37 +
  3rdparty/boost/boost/config/platform/cygwin.hpp|   11 +
  3rdparty/boost/boost/config/platform/vxworks.hpp   |  233 ++--
  3rdparty/boost/boost/config/pragma_message.hpp |   31 +
  3rdparty/boost/boost/config/stdlib/dinkumware.hpp  |   11 +-
  3rdparty/boost/boost/config/stdlib/libcomo.hpp |1 +
  3rdparty/boost/boost/config/stdlib/libcpp.hpp  |   13 +-
  3rdparty/boost/boost/config/stdlib/libstdcpp3.hpp  |9 +-
  3rdparty/boost/boost/config/stdlib/modena.hpp  |1 +
  3rdparty/boost/boost/config/stdlib/msl.hpp |1 +
  3rdparty/boost/boost/config/stdlib/roguewave.hpp   |1 +
  3rdparty/boost/boost/config/stdlib/sgi.hpp |1 +
  3rdparty/boost/boost/config/stdlib/stlport.hpp |1 +
  3rdparty/boost/boost/config/stdlib/vacpp.hpp   |1 +
  3rdparty/boost/boost/config/stdlib/xlcpp_zos.hpp   |1 +
  3rdparty/boost/boost/config/workaround.hpp |2 +
  3rdparty/boost/boost/container/container_fwd.hpp   |   35 +-
  .../container_hash/detail/float_functions.hpp  |  336 
  .../boost/container_hash/detail/hash_float.hpp |  271 +++
  .../boost/boost/container_hash/detail/limits.hpp   |   62 +
  3rdparty/boost/boost/container_hash/extensions.hpp |  414 +
  3rdparty/boost/boost/container_hash/hash.hpp   |  761 +
  3rdparty/boost/boost/container_hash/hash_fwd.hpp   |   36 +
  3rdparty/boost/boost/core/addressof.hpp|   84 +-
  3rdparty/boost/boost/cstdint.hpp   |   30 +-
  3rdparty/boost/boost/detail/basic_pointerbuf.hpp   |2 +-
  3rdparty/boost/boost/function.hpp  |   16 +-
  .../boost/function/detail/gen_maybe_include.pl |2 +
  .../boost/boost/function/detail/maybe_include.hpp  |  102 ++
  3rdparty/boost/boost/function/function_base.hpp|   20 +
  .../boost/boost/function/function_template.hpp |   17 +-
  3rdparty/boost/boost/function_output_iterator.hpp  |   56 +-
  3rdparty/boost/boost/functional/hash.hpp   |3 +-
  .../functional/hash/detail/float_functions.hpp |  336 
  .../boost/functional/hash/detail/hash_float.hpp|  271 ---
  .../boost/boost/functional/hash/detail/limits.hpp  |   62 -
  .../boost/boost/functional/hash/extensions.hpp |  318 
  3rdparty/boost/boost/functional/hash/hash.hpp  |  595 ---
  3rdparty/boost/boost/functional/hash/hash_fwd.hpp  |   36 -
  3rdparty/boost/boost/functional/hash_fwd.hpp   |7 +-
  3rdparty/boost/boost/iterator.hpp  |   20 -
  3rdparty/boost/boost/iterator/distance.hpp |   65 +
  .../boost/iterator/function_output_iterator.hpp|   62 +
  3rdparty/boost/boost/iterator/iterator_adaptor.hpp |2 -
  .../boost/boost/iterator/iterator_categories.hpp   |5 +-
  .../boost/boost/iterator/iterator_concepts.hpp |   18 +-
  3rdparty/boost/boost/iterator/iterator_facade.hpp  |3

[LyX/2.3.x] Make sure inset buffer is correctly set in math grid

2018-12-14 Thread Jean-Marc Lasgouttes
commit ebe6612e2661f49dcfae6103f056c27afd47751f
Author: Jean-Marc Lasgouttes 
Date:   Wed Oct 3 10:39:09 2018 +0200

Make sure inset buffer is correctly set in math grid

Make MathData::setBuffer set the buffer of insets that it contains.
Remove corresponding code from InsetMathNest.

update the buffer() property in the following tabular-feature
actions : copy-row, add-row, copy-col, add-col.

(cherry picked from commit 837bcbb0433316ebe528b71e7c9952638ac1baee)
---
 src/mathed/InsetMathGrid.cpp |   14 +++---
 src/mathed/InsetMathNest.cpp |7 ++-
 src/mathed/MathData.cpp  |8 
 src/mathed/MathData.h|2 +-
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 71bcf84..f015285 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -809,7 +809,7 @@ void InsetMathGrid::addRow(row_type row)
 {
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
cells_.insert
-   (cells_.begin() + (row + 1) * ncols(), ncols(), MathData());
+   (cells_.begin() + (row + 1) * ncols(), ncols(), 
MathData(buffer_));
cellinfo_.insert
(cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
 }
@@ -833,8 +833,11 @@ void InsetMathGrid::delRow(row_type row)
 void InsetMathGrid::copyRow(row_type row)
 {
addRow(row);
-   for (col_type col = 0; col < ncols(); ++col)
+   for (col_type col = 0; col < ncols(); ++col) {
cells_[(row + 1) * ncols() + col] = cells_[row * ncols() + col];
+   // copying the cell does not set the buffer
+   cells_[(row + 1) * ncols() + col].setBuffer(*buffer_);
+   }
 }
 
 
@@ -864,6 +867,8 @@ void InsetMathGrid::addCol(col_type newcol)
= cellinfo_[row * nc + col];
}
swap(cells_, new_cells);
+   // copying cells loses the buffer reference
+   setBuffer(*buffer_);
swap(cellinfo_, new_cellinfo);
 
ColInfo inf;
@@ -895,8 +900,11 @@ void InsetMathGrid::delCol(col_type col)
 void InsetMathGrid::copyCol(col_type col)
 {
addCol(col+1);
-   for (row_type row = 0; row < nrows(); ++row)
+   for (row_type row = 0; row < nrows(); ++row) {
cells_[row * ncols() + col + 1] = cells_[row * ncols() + col];
+   // copying the cell does not set the buffer
+   cells_[row * ncols() + col + 1].setBuffer(*buffer_);
+   }
 }
 
 
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 4b19c3c..63fa74a 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -118,11 +118,8 @@ InsetMathNest & InsetMathNest::operator=(InsetMathNest 
const & inset)
 void InsetMathNest::setBuffer(Buffer & buffer)
 {
InsetMath::setBuffer(buffer);
-   for (idx_type i = 0, n = nargs(); i != n; ++i) {
-   MathData & data = cell(i);
-   for (size_t j = 0; j != data.size(); ++j)
-   data[j].nucleus()->setBuffer(buffer);
-   }
+   for (MathData & data : cells_)
+   data.setBuffer(buffer);
 }
 
 
diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
index 4bf7059..53a86d7 100644
--- a/src/mathed/MathData.cpp
+++ b/src/mathed/MathData.cpp
@@ -52,6 +52,14 @@ MathData::MathData(Buffer * buf, const_iterator from, 
const_iterator to)
 {}
 
 
+void MathData::setBuffer(Buffer & b)
+{
+   buffer_ = &b;
+   for (MathAtom & at : *this)
+   at.nucleus()->setBuffer(b);
+}
+
+
 MathAtom & MathData::operator[](pos_type pos)
 {
LBUFERR(pos < size());
diff --git a/src/mathed/MathData.h b/src/mathed/MathData.h
index 1b9d8ed..6224e91 100644
--- a/src/mathed/MathData.h
+++ b/src/mathed/MathData.h
@@ -185,7 +185,7 @@ public:
///
void updateBuffer(ParIterator const &, UpdateType);
///
-   void setBuffer(Buffer & b) { buffer_ = &b; }
+   void setBuffer(Buffer & b);
 
 protected:
/// cached values for super/subscript placement


[LyX/2.3.x] Set buffer correctly when changing math space type.

2018-12-14 Thread Jean-Marc Lasgouttes
commit 0e6cb4e599cc8aaf191200a963fa916274dc9b7f
Author: Jean-Marc Lasgouttes 
Date:   Thu Dec 13 10:27:20 2018 +0100

Set buffer correctly when changing math space type.

Fixes bug #7747.

(cherry picked from commit 2ec25c8eef8c9acca3cb572800eab933c8564831)
---
 src/mathed/InsetMathSpace.cpp |2 ++
 status.23x|1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/mathed/InsetMathSpace.cpp b/src/mathed/InsetMathSpace.cpp
index 88aae1d..79a4314 100644
--- a/src/mathed/InsetMathSpace.cpp
+++ b/src/mathed/InsetMathSpace.cpp
@@ -320,9 +320,11 @@ void InsetMathSpace::doDispatch(Cursor & cur, FuncRequest 
& cmd)
case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "mathspace") {
MathData ar;
+   Buffer * buf = buffer_;
if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
cur.recordUndo();
*this = *ar[0].nucleus()->asSpaceInset();
+   buffer_ = buf;
break;
}
}
diff --git a/status.23x b/status.23x
index 8eaa54b..4f50e5c 100644
--- a/status.23x
+++ b/status.23x
@@ -63,6 +63,7 @@ What's new
 
 - Do not swallow backspaces in custom viewer/editor paths (bug 9622).
 
+- Fix broken space dialog in mathed (bug 7747).
 
 * INTERNALS
 


[LyX/2.3.x] Update boost to 1.68.

2018-12-16 Thread Jean-Marc Lasgouttes
commit 09d742cc7f1707dfc04925912d11846ae0213172
Author: Jean-Marc Lasgouttes 
Date:   Sun Dec 16 21:45:02 2018 +0100

Update boost to 1.68.

This avoid lots of warnings from gcc 8.

 3rdparty/boost/boost/any.hpp   |   20 +-
 3rdparty/boost/boost/array.hpp |   95 +-
 3rdparty/boost/boost/bind/arg.hpp  |   13 +-
 3rdparty/boost/boost/bind/bind.hpp |   37 +
 3rdparty/boost/boost/bind/bind_cc.hpp  |   60 +-
 3rdparty/boost/boost/bind/bind_mf_cc.hpp   |   72 +-
 3rdparty/boost/boost/config.hpp|8 +-
 3rdparty/boost/boost/config/auto_link.hpp  |   41 +-
 3rdparty/boost/boost/config/compiler/borland.hpp   |   16 +
 3rdparty/boost/boost/config/compiler/clang.hpp |   42 +-
 3rdparty/boost/boost/config/compiler/codegear.hpp  |   18 +
 .../boost/boost/config/compiler/common_edg.hpp |   16 +
 3rdparty/boost/boost/config/compiler/cray.hpp  |  441 +-
 3rdparty/boost/boost/config/compiler/diab.hpp  |   26 +
 .../boost/boost/config/compiler/digitalmars.hpp|   15 +
 3rdparty/boost/boost/config/compiler/gcc.hpp   |   43 +-
 3rdparty/boost/boost/config/compiler/gcc_xml.hpp   |   15 +
 3rdparty/boost/boost/config/compiler/hp_acc.hpp|1 +
 3rdparty/boost/boost/config/compiler/intel.hpp |   33 +-
 .../boost/boost/config/compiler/metrowerks.hpp |   15 +
 3rdparty/boost/boost/config/compiler/mpw.hpp   |   15 +
 3rdparty/boost/boost/config/compiler/nvcc.hpp  |   36 +-
 3rdparty/boost/boost/config/compiler/pathscale.hpp |   22 +-
 3rdparty/boost/boost/config/compiler/pgi.hpp   |  149 +--
 3rdparty/boost/boost/config/compiler/sunpro_cc.hpp |   23 +-
 3rdparty/boost/boost/config/compiler/vacpp.hpp |   20 +
 3rdparty/boost/boost/config/compiler/visualc.hpp   |   77 +-
 3rdparty/boost/boost/config/compiler/xlcpp.hpp |   23 +
 3rdparty/boost/boost/config/compiler/xlcpp_zos.hpp |  170 ++
 .../boost/boost/config/detail/posix_features.hpp   |   95 ++
 .../boost/config/detail/select_compiler_config.hpp |  158 ++
 .../boost/config/detail/select_platform_config.hpp |  142 ++
 .../boost/config/detail/select_stdlib_config.hpp   |  110 ++
 3rdparty/boost/boost/config/detail/suffix.hpp  | 1036 
 3rdparty/boost/boost/config/header_deprecated.hpp  |   26 +
 3rdparty/boost/boost/config/helper_macros.hpp  |   37 +
 3rdparty/boost/boost/config/platform/aix.hpp   |2 +-
 3rdparty/boost/boost/config/platform/beos.hpp  |2 +-
 3rdparty/boost/boost/config/platform/bsd.hpp   |2 +-
 3rdparty/boost/boost/config/platform/cray.hpp  |2 +-
 3rdparty/boost/boost/config/platform/cygwin.hpp|   16 +-
 3rdparty/boost/boost/config/platform/haiku.hpp |2 +-
 3rdparty/boost/boost/config/platform/hpux.hpp  |2 +-
 3rdparty/boost/boost/config/platform/irix.hpp  |2 +-
 3rdparty/boost/boost/config/platform/linux.hpp |7 +-
 3rdparty/boost/boost/config/platform/macos.hpp |2 +-
 3rdparty/boost/boost/config/platform/qnxnto.hpp|2 +-
 3rdparty/boost/boost/config/platform/solaris.hpp   |2 +-
 3rdparty/boost/boost/config/platform/symbian.hpp   |2 +-
 3rdparty/boost/boost/config/platform/vxworks.hpp   |  246 ++-
 3rdparty/boost/boost/config/platform/zos.hpp   |   32 +
 3rdparty/boost/boost/config/posix_features.hpp |   95 --
 3rdparty/boost/boost/config/pragma_message.hpp |   31 +
 .../boost/boost/config/select_compiler_config.hpp  |  148 --
 .../boost/boost/config/select_platform_config.hpp  |  137 --
 .../boost/boost/config/select_stdlib_config.hpp|  105 --
 3rdparty/boost/boost/config/stdlib/dinkumware.hpp  |   66 +-
 3rdparty/boost/boost/config/stdlib/libcomo.hpp |9 +
 3rdparty/boost/boost/config/stdlib/libcpp.hpp  |   39 +-
 3rdparty/boost/boost/config/stdlib/libstdcpp3.hpp  |   60 +-
 3rdparty/boost/boost/config/stdlib/modena.hpp  |9 +
 3rdparty/boost/boost/config/stdlib/msl.hpp |   11 +-
 3rdparty/boost/boost/config/stdlib/roguewave.hpp   |9 +
 3rdparty/boost/boost/config/stdlib/sgi.hpp |   11 +-
 3rdparty/boost/boost/config/stdlib/stlport.hpp |9 +
 3rdparty/boost/boost/config/stdlib/vacpp.hpp   |9 +
 3rdparty/boost/boost/config/stdlib/xlcpp_zos.hpp   |   60 +
 3rdparty/boost/boost/config/suffix.hpp | 1017 
 3rdparty/boost/boost/config/workaround.hpp |  279 
 3rdparty/boost/boost/container/container_fwd.hpp   |   35 +-
 .../container_hash/detail/float_functions.hpp  |  336 
 .../boost/container_hash/detail/hash_float.hpp |  271 +++
 .../boost/boost/container_hash/detail/limits.hpp   |   62 +
 3rdparty/boost/boost/container_hash/extensions.hpp |  414 +
 3rdparty/boost/boost/container_hash/hash.hpp   |  761 +
 3rdparty/boost/boost/container_hash/hash_fwd.hpp   |   36 +
 3rdparty/boost/boost/core/addressof.hpp|  310 +++--
 3rdparty

[LyX/2.3.x] Fix undo after breaking a nested paragraph

2018-12-16 Thread Jean-Marc Lasgouttes
commit 47adf27ac3b90ef7899f838da7cee56c72e6ea0e
Author: Jean-Marc Lasgouttes 
Date:   Fri Nov 23 16:53:53 2018 +0100

Fix undo after breaking a nested paragraph

We have to take into account that Buffer::updateBuffer can modify the 
document.

Fix bug #11292.

(cherry picked from commit 57feb0fed0c078903900aaea069c49207c8cb9ac)
---
 src/frontends/qt4/GuiApplication.cpp |8 +---
 status.23x   |3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 79f14d6..3c6e137 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -1403,11 +1403,13 @@ DispatchResult const & 
GuiApplication::dispatch(FuncRequest const & cmd)
// This handles undo groups automagically
UndoGroupHelper ugh(buffer);
dispatch(cmd, dr);
+   // redraw the screen at the end (first of the two drawing 
steps).
+   // This is done unless explicitly requested otherwise.
+   // This code is kept inside the undo group because updateBuffer
+   // can create undo actions (see #11292)
+   updateCurrentView(cmd, dr);
}
 
-   // redraw the screen at the end (first of the two drawing steps).
-   // This is done unless explicitly requested otherwise
-   updateCurrentView(cmd, dr);
d->dispatch_result_ = dr;
return d->dispatch_result_;
 }
diff --git a/status.23x b/status.23x
index 544bc1a..97a9a3c 100644
--- a/status.23x
+++ b/status.23x
@@ -65,6 +65,9 @@ What's new
 
 - Fix broken space dialog in mathed (bug 7747).
 
+- Fix undo in some cases involving nesting (bug 11292).
+
+
 * INTERNALS
 
 


[LyX/master] Fix embarrassing typo

2018-12-17 Thread Jean-Marc Lasgouttes
commit 058c6750ac83b43819445ccf723283afb850ef91
Author: Jean-Marc Lasgouttes 
Date:   Mon Dec 17 12:28:32 2018 +0100

Fix embarrassing typo

Not clear whether this caused any bug.
---
 src/Dimension.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Dimension.h b/src/Dimension.h
index 0607be6..0f7fdab 100644
--- a/src/Dimension.h
+++ b/src/Dimension.h
@@ -32,8 +32,8 @@ public:
void operator+=(Dimension const & dim);
/// set to empty box
void clear() { wid = asc = des = 0; }
-   /// check if box is empty
-   bool empty() const { return wid == 0 && asc == 0 && wid == 0; }
+   /// check whether box is empty
+   bool empty() const { return wid == 0 && asc == 0 && des == 0; }
/// get height
int height() const { return asc + des; }
/// get ascent


[LyX/2.3.x] Fix embarrassing typo

2018-12-17 Thread Jean-Marc Lasgouttes
commit 833adc5c6b9d3b659bb24285bac38f23af66cba3
Author: Jean-Marc Lasgouttes 
Date:   Mon Dec 17 12:28:32 2018 +0100

Fix embarrassing typo

Not clear whether this caused any bug.

(cherry picked from commit 058c6750ac83b43819445ccf723283afb850ef91)
---
 src/Dimension.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Dimension.h b/src/Dimension.h
index 0607be6..0f7fdab 100644
--- a/src/Dimension.h
+++ b/src/Dimension.h
@@ -32,8 +32,8 @@ public:
void operator+=(Dimension const & dim);
/// set to empty box
void clear() { wid = asc = des = 0; }
-   /// check if box is empty
-   bool empty() const { return wid == 0 && asc == 0 && wid == 0; }
+   /// check whether box is empty
+   bool empty() const { return wid == 0 && asc == 0 && des == 0; }
/// get height
int height() const { return asc + des; }
/// get ascent


[LyX/master] Make DEPM respect current cursor position.

2018-12-21 Thread Jean-Marc Lasgouttes
commit dff0c5729e6eec4c799f60171e4d0a377327ab10
Author: Jean-Marc Lasgouttes 
Date:   Fri Dec 21 15:36:55 2018 +0100

Make DEPM respect current cursor position.

Spaces are now conserved when they surround current cursor. Examples:
  abc   |   def
becomes
  abc | def
after DEPM and
  abc |
is kept as it is.

Fixes ticket #11412.
---
 src/Text2.cpp |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index 17f32ad..cb394c2 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -845,7 +845,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
&& old.pos() == cur[depth].pos();
 
// If the chars around the old cursor were spaces, delete some of
-   // them , but only if the cursor has really moved.
+   // them, but only if the cursor has really moved.
if (!same_par_pos) {
// find range of spaces around cursors
int from = old.pos();
@@ -863,6 +863,9 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
if (from != to && from > 0 && to < oldpar.size())
++from;
 
+   if (same_par && cur.pos() > from && cur.pos() < to)
+   ++from;
+
// Remove spaces and adapt cursor.
if (from < to) {
oldpar.eraseChars(from, to, 
cur.buffer()->params().track_changes);
@@ -879,7 +882,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
}
}
 
-   // only do our magic if we changed paragraph
+   // only do our other magic if we changed paragraph
if (same_par)
return false;
 


[LyX/2.3.x] Make DEPM respect current cursor position.

2018-12-21 Thread Jean-Marc Lasgouttes
commit 714b731e398b89aaea403dab9929648534e7adc7
Author: Jean-Marc Lasgouttes 
Date:   Fri Dec 21 15:36:55 2018 +0100

Make DEPM respect current cursor position.

Spaces are now conserved when they surround current cursor. Examples:
  abc   |   def
becomes
  abc | def
after DEPM and
  abc |
is kept as it is.

Fixes ticket #11412.

(cherry picked from commit dff0c5729e6eec4c799f60171e4d0a377327ab10)
---
 src/Text2.cpp |7 +--
 status.23x|2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index e0f5963..d6f5a83 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -850,7 +850,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
&& old.pos() == cur[depth].pos();
 
// If the chars around the old cursor were spaces, delete some of
-   // them , but only if the cursor has really moved.
+   // them, but only if the cursor has really moved.
if (!same_par_pos) {
// find range of spaces around cursors
int from = old.pos();
@@ -868,6 +868,9 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
if (from != to && from > 0 && to < oldpar.size())
++from;
 
+   if (same_par && cur.pos() > from && cur.pos() < to)
+   ++from;
+
// Remove spaces and adapt cursor.
if (from < to) {
oldpar.eraseChars(from, to, 
cur.buffer()->params().track_changes);
@@ -884,7 +887,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
}
}
 
-   // only do our magic if we changed paragraph
+   // only do our other magic if we changed paragraph
if (same_par)
return false;
 
diff --git a/status.23x b/status.23x
index 9680d6f..386df1a 100644
--- a/status.23x
+++ b/status.23x
@@ -39,6 +39,8 @@ What's new
 
 - Insert new graphics inset on the correct cursor position.
 
+- Fix regression where spaces are disappearing when editing text (bug 11412).
+
 
 * DOCUMENTATION AND LOCALIZATION
 


[LyX/master] Remove premature (and bad) optimization

2019-01-02 Thread Jean-Marc Lasgouttes
commit fba9f5b9e884f0a988bd77992772eb4986eecdec
Author: Jean-Marc Lasgouttes 
Date:   Wed Jan 2 18:36:02 2019 +0100

Remove premature (and bad) optimization

When blinking the caret, it looks like a cool idea to only update the
small rectangle containing the caret. Actually it is an awful idea, since
the paint event will paint some rows, and these rows will not be
properly painted outside of the small rectangle. Unfortunately, the
painter will skip those "painted" rows on next paint events.

This leads to painting errors that depend on the ordering of "real"
and "caret" paint events. This is the reason why they only appeared
with split screens.

Quote of the day: ``The real problem is that programmers have spent far
too much time worrying about efficiency in the wrong places and at the
wrong times; premature optimization is the root of all evil (or at
least most of it) in programming.''
-- Donald Knuth, The Art of Computer Programming.

Fixes bug #11354.
---
 src/frontends/qt4/GuiWorkArea.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt4/GuiWorkArea.cpp 
b/src/frontends/qt4/GuiWorkArea.cpp
index 4244cee..7842958 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -639,7 +639,7 @@ void GuiWorkArea::Private::showCaret()
return;
 
updateCaretGeometry();
-   p->viewport()->update(caret_->rect());
+   p->viewport()->update();
 }
 
 
@@ -650,7 +650,7 @@ void GuiWorkArea::Private::hideCaret()
 
caret_visible_ = false;
//if (!qApp->focusWidget())
-   p->viewport()->update(caret_->rect());
+   p->viewport()->update();
 }
 
 


[LyX/master] Add override statements to please clang

2019-01-02 Thread Jean-Marc Lasgouttes
commit c8f4b68423520378d02fe9f953d94759b862dc55
Author: Jean-Marc Lasgouttes 
Date:   Wed Jan 2 18:49:23 2019 +0100

Add override statements to please clang

Eventually, all overridden virtual methods should be marked properly.
Currently, clang only warns about those in classes that already use
override in at least one place (which was the case dor GuiApplication).
---
 src/frontends/qt4/GuiApplication.h |   46 ++--
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/frontends/qt4/GuiApplication.h 
b/src/frontends/qt4/GuiApplication.h
index bc16fab..22d4365 100644
--- a/src/frontends/qt4/GuiApplication.h
+++ b/src/frontends/qt4/GuiApplication.h
@@ -63,22 +63,22 @@ public:
 
/// \name Methods inherited from Application class
//@{
-   DispatchResult const & dispatch(FuncRequest const &);
-   void dispatch(FuncRequest const &, DispatchResult & dr);
-   FuncStatus getStatus(FuncRequest const & cmd) const;
-   void restoreGuiSession();
-   Buffer const * updateInset(Inset const * inset) const;
-   int exec();
-   void exit(int status);
-   bool event(QEvent * e);
-   bool getRgbColor(ColorCode col, RGBColor & rgbcol);
-   std::string const hexName(ColorCode col);
-   void registerSocketCallback(int fd, SocketCallback func);
-   void unregisterSocketCallback(int fd);
-   bool searchMenu(FuncRequest const & func, docstring_list & names) const;
-   bool hasBufferView() const;
-   void handleKeyFunc(FuncCode action);
-   bool unhide(Buffer * buf); //override
+   DispatchResult const & dispatch(FuncRequest const &) override;
+   void dispatch(FuncRequest const &, DispatchResult & dr) override;
+   FuncStatus getStatus(FuncRequest const & cmd) const override;
+   void restoreGuiSession() override;
+   Buffer const * updateInset(Inset const * inset) const override;
+   int exec() override;
+   void exit(int status) override;
+   bool event(QEvent * e) override;
+   bool getRgbColor(ColorCode col, RGBColor & rgbcol) override;
+   std::string const hexName(ColorCode col) override;
+   void registerSocketCallback(int fd, SocketCallback func) override;
+   void unregisterSocketCallback(int fd) override;
+   bool searchMenu(FuncRequest const & func, docstring_list & names) const 
override;
+   bool hasBufferView() const override;
+   void handleKeyFunc(FuncCode action) override;
+   bool unhide(Buffer * buf) override;
//@}
 
///
@@ -106,13 +106,13 @@ public:
 
/// \name Methods inherited from QApplication class
//@{
-   bool notify(QObject * receiver, QEvent * event);
+   bool notify(QObject * receiver, QEvent * event) override;
void commitData(QSessionManager & sm);
 #ifdef Q_WS_X11
-   bool x11EventFilter(XEvent * ev);
+   bool x11EventFilter(XEvent * ev) override;
 #elif defined(QPA_XCB)
virtual bool nativeEventFilter(const QByteArray & eventType, void * 
message,
-  long * result) Q_DECL_OVERRIDE;
+  long * result) override;
 #endif
//@}
 
@@ -197,13 +197,13 @@ public:
void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
 
/// Start a long operation with some cancel possibility (button or ESC)
-   void startLongOperation();
+   void startLongOperation() override;
/// This needs to be periodically called to avoid freezing the GUI
-   bool longOperationCancelled();
+   bool longOperationCancelled() override;
/// Stop the long operation mode (i.e., release the GUI)
-   void stopLongOperation();
+   void stopLongOperation() override;
/// A started long operation is still in progress ?
-   bool longOperationStarted();
+   bool longOperationStarted() override;
 private Q_SLOTS:
///
void execBatchCommands();


[LyX/2.3.x] Add override statements to please clang

2019-01-03 Thread Jean-Marc Lasgouttes
commit b9116e8b81f55ee795ea444ee02ff921bf82606a
Author: Jean-Marc Lasgouttes 
Date:   Wed Jan 2 18:49:23 2019 +0100

Add override statements to please clang

Eventually, all overridden virtual methods should be marked properly.
Currently, clang only warns about those in classes that already use
override in at least one place (which was the case dor GuiApplication).

(cherry picked from commit c8f4b68423520378d02fe9f953d94759b862dc55)
---
 src/frontends/qt4/GuiApplication.h |   44 ++--
 status.23x |2 +
 2 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/src/frontends/qt4/GuiApplication.h 
b/src/frontends/qt4/GuiApplication.h
index fafdd46..970ae80 100644
--- a/src/frontends/qt4/GuiApplication.h
+++ b/src/frontends/qt4/GuiApplication.h
@@ -63,21 +63,21 @@ public:
 
/// \name Methods inherited from Application class
//@{
-   DispatchResult const & dispatch(FuncRequest const &);
-   void dispatch(FuncRequest const &, DispatchResult & dr);
-   FuncStatus getStatus(FuncRequest const & cmd) const;
-   void restoreGuiSession();
-   Buffer const * updateInset(Inset const * inset) const;
-   int exec();
-   void exit(int status);
-   bool event(QEvent * e);
-   bool getRgbColor(ColorCode col, RGBColor & rgbcol);
-   std::string const hexName(ColorCode col);
-   void registerSocketCallback(int fd, SocketCallback func);
-   void unregisterSocketCallback(int fd);
-   bool searchMenu(FuncRequest const & func, docstring_list & names) const;
-   void handleKeyFunc(FuncCode action);
-   bool unhide(Buffer * buf); //override
+   DispatchResult const & dispatch(FuncRequest const &) override;
+   void dispatch(FuncRequest const &, DispatchResult & dr) override;
+   FuncStatus getStatus(FuncRequest const & cmd) const override;
+   void restoreGuiSession() override;
+   Buffer const * updateInset(Inset const * inset) const override;
+   int exec() override;
+   void exit(int status) override;
+   bool event(QEvent * e) override;
+   bool getRgbColor(ColorCode col, RGBColor & rgbcol) override;
+   std::string const hexName(ColorCode col) override;
+   void registerSocketCallback(int fd, SocketCallback func) override;
+   void unregisterSocketCallback(int fd) override;
+   bool searchMenu(FuncRequest const & func, docstring_list & names) const 
override;
+   void handleKeyFunc(FuncCode action) override;
+   bool unhide(Buffer * buf) override;
//@}
 
///
@@ -105,13 +105,13 @@ public:
 
/// \name Methods inherited from QApplication class
//@{
-   bool notify(QObject * receiver, QEvent * event);
+   bool notify(QObject * receiver, QEvent * event) override;
void commitData(QSessionManager & sm);
 #ifdef Q_WS_X11
-   bool x11EventFilter(XEvent * ev);
+   bool x11EventFilter(XEvent * ev) override;
 #elif defined(QPA_XCB)
virtual bool nativeEventFilter(const QByteArray & eventType, void * 
message,
-  long * result) Q_DECL_OVERRIDE;
+  long * result) override;
 #endif
//@}
 
@@ -196,13 +196,13 @@ public:
void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
 
/// Start a long operation with some cancel possibility (button or ESC)
-   void startLongOperation();
+   void startLongOperation() override;
/// This needs to be periodically called to avoid freezing the GUI
-   bool longOperationCancelled();
+   bool longOperationCancelled() override;
/// Stop the long operation mode (i.e., release the GUI)
-   void stopLongOperation();
+   void stopLongOperation() override;
/// A started long operation is still in progress ?
-   bool longOperationStarted();
+   bool longOperationStarted() override;
 private Q_SLOTS:
///
void execBatchCommands();
diff --git a/status.23x b/status.23x
index 81dc948..e2f47e3 100644
--- a/status.23x
+++ b/status.23x
@@ -141,3 +141,5 @@ What's new
 
 - Update bundled boost distribution to 1.68.
 
+- Fix warnings with clang 7.
+


[LyX/master] Fix vertical offset of fonts like MinionPro

2019-01-03 Thread Jean-Marc Lasgouttes
commit d8498d4785282a6f42a69f56ebd46ac32e1d2f51
Author: Jean-Marc Lasgouttes 
Date:   Thu Jan 3 12:14:27 2019 +0100

Fix vertical offset of fonts like MinionPro

For some reason, adding a LTR/RTL Override unicode character before a
MinionPro string increases the ascent of the line.

This creates vertical offset issues when painting if the ascent used
as reference is the one of the font. Use the QTextLine ascent instead
for better results.

This is a followup to 1bed76e2a.

Fixes (reopened) ticket #11284.
---
 src/frontends/qt4/GuiPainter.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp
index 8bd9efb..e0b2177 100644
--- a/src/frontends/qt4/GuiPainter.cpp
+++ b/src/frontends/qt4/GuiPainter.cpp
@@ -329,7 +329,8 @@ void GuiPainter::text(int x, int y, docstring const & s,
setQPainterPen(computeColor(f.realColor()));
if (dir != Auto) {
auto ptl = fm.getTextLayout(s, dir == RtL, wordspacing);
-   ptl->draw(this, QPointF(x, y - fm.maxAscent()));
+   QTextLine const & tline = ptl->lineForTextPosition(0);
+   ptl->draw(this, QPointF(x, y - tline.ascent()));
} else {
if (font() != ff)
setFont(ff);


[LyX/2.3.x] Remove premature (and bad) optimization

2019-01-03 Thread Jean-Marc Lasgouttes
commit 1e2b503ac934e06cdd253b1d3d80c5ae7122c35b
Author: Jean-Marc Lasgouttes 
Date:   Wed Jan 2 18:36:02 2019 +0100

Remove premature (and bad) optimization

When blinking the caret, it looks like a cool idea to only update the
small rectangle containing the caret. Actually it is an awful idea, since
the paint event will paint some rows, and these rows will not be
properly painted outside of the small rectangle. Unfortunately, the
painter will skip those "painted" rows on next paint events.

This leads to painting errors that depend on the ordering of "real"
and "caret" paint events. This is the reason why they only appeared
with split screens.

Quote of the day: ``The real problem is that programmers have spent far
too much time worrying about efficiency in the wrong places and at the
wrong times; premature optimization is the root of all evil (or at
least most of it) in programming.''
-- Donald Knuth, The Art of Computer Programming.

Fixes bug #11354.

(cherry picked from commit fba9f5b9e884f0a988bd77992772eb4986eecdec)
---
 src/frontends/qt4/GuiWorkArea.cpp |4 ++--
 status.23x|2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt4/GuiWorkArea.cpp 
b/src/frontends/qt4/GuiWorkArea.cpp
index 18c25ca..fee3c33 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -636,7 +636,7 @@ void GuiWorkArea::Private::showCaret()
return;
 
updateCaretGeometry();
-   p->viewport()->update(caret_->rect());
+   p->viewport()->update();
 }
 
 
@@ -647,7 +647,7 @@ void GuiWorkArea::Private::hideCaret()
 
caret_visible_ = false;
//if (!qApp->focusWidget())
-   p->viewport()->update(caret_->rect());
+   p->viewport()->update();
 }
 
 
diff --git a/status.23x b/status.23x
index e2f47e3..1ee2757 100644
--- a/status.23x
+++ b/status.23x
@@ -110,6 +110,8 @@ What's new
 
 - Completion popup context menu now properly responds to Esc key.
 
+- Fix document updating issues with split view (bug 11354).
+
 
 * INTERNALS
 


[LyX/master] Remove unused mathod (CursorSlice::at_cell_end is the same)

2019-01-04 Thread Jean-Marc Lasgouttes
commit f97c11f4e9b0f99f49a16e367c6a0eb692fdcdc3
Author: Jean-Marc Lasgouttes 
Date:   Fri Jan 4 13:54:42 2019 +0100

Remove unused mathod (CursorSlice::at_cell_end is the same)
---
 src/DocIterator.h |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/DocIterator.h b/src/DocIterator.h
index 0653de8..8ee4d4e 100644
--- a/src/DocIterator.h
+++ b/src/DocIterator.h
@@ -71,8 +71,6 @@ public:
bool empty() const { return slices_.empty(); }
/// is this the end position?
bool atEnd() const { return slices_.empty(); }
-   /// is this the last possible position?
-   bool atLastPos() const { return pit() == lastpit() && pos() == 
lastpos(); }
 
/// checks the cursor slices for disabled spell checker insets
bool allowSpellCheck() const;


[LyX/master] Avoid crash when using inset-select-all in tabular

2019-01-04 Thread Jean-Marc Lasgouttes
commit a69e01d0b47aebbdfc3139533fcb7f1d0c04f156
Author: Jean-Marc Lasgouttes 
Date:   Fri Jan 4 13:57:13 2019 +0100

Avoid crash when using inset-select-all in tabular

When changing cell idx, it is important to set the pit to a reasonable
value.
---
 src/BufferView.cpp |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 6a32faa..af37287 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1904,10 +1904,12 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
// At least one complete cell is selected and inset is 
a table.
// Select all cells
cur.idx() = 0;
+   cur.pit() = 0;
cur.pos() = 0;
cur.resetAnchor();
cur.selection(true);
cur.idx() = cur.lastidx();
+   cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
} else {
// select current cell


[LyX/master] Fix drawing of labels in insets

2019-01-04 Thread Jean-Marc Lasgouttes
commit 5c1d65afee3a37d5befcf9eb55d8d50e1d8e4f13
Author: Jean-Marc Lasgouttes 
Date:   Fri Jan 4 16:24:18 2019 +0100

Fix drawing of labels in insets

In many cases, the origin xo_ of insets was forgotten.

Fixes bug #11425.
---
 src/RowPainter.cpp |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 43b3be2..60bb5a7 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -432,7 +432,7 @@ void RowPainter::paintLabel() const
double x = x_;
 
if (row_.isRTL())
-   x = tm_.width() - row_.right_margin + fm.width(layout.labelsep);
+   x = xo_ + tm_.width() - row_.right_margin + 
fm.width(layout.labelsep);
else
x = x_ - fm.width(layout.labelsep) - fm.width(str);
 
@@ -467,10 +467,10 @@ void RowPainter::paintTopLevelLabel() const
 
double x = x_;
if (layout.labeltype == LABEL_CENTERED) {
-   x = row_.left_margin + (tm_.width() - row_.left_margin - 
row_.right_margin) / 2;
+   x += (tm_.width() - row_.left_margin - row_.right_margin) / 2;
x -= fm.width(str) / 2;
} else if (row_.isRTL()) {
-   x = tm_.width() - row_.right_margin - fm.width(str);
+   x = xo_ + tm_.width() - row_.right_margin - fm.width(str);
}
pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
 }
@@ -557,9 +557,9 @@ void RowPainter::paintLast() const
}
 
if (endlabel == END_LABEL_BOX)
-   pi_.pain.rectangle(x, y, size, size, font.realColor());
+   pi_.pain.rectangle(xo_ + x, y, size, size, 
font.realColor());
else
-   pi_.pain.fillRectangle(x, y, size, size, 
font.realColor());
+   pi_.pain.fillRectangle(xo_ + x, y, size, size, 
font.realColor());
break;
}
 


[LyX/master] Fixup 5c1d65af: proper spacing between text and label in rtl

2019-01-04 Thread Jean-Marc Lasgouttes
commit 5fc035f99c42835da41d6eb6cf5a375382c06870
Author: Jean-Marc Lasgouttes 
Date:   Fri Jan 4 17:13:10 2019 +0100

Fixup 5c1d65af: proper spacing between text and label in rtl

Fix bug #11425.
---
 src/RowPainter.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 60bb5a7..a924614 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -432,7 +432,7 @@ void RowPainter::paintLabel() const
double x = x_;
 
if (row_.isRTL())
-   x = xo_ + tm_.width() - row_.right_margin + 
fm.width(layout.labelsep);
+   x = xo_ + row_.width() + fm.width(layout.labelsep);
else
x = x_ - fm.width(layout.labelsep) - fm.width(str);
 


[LyX/2.3.x] Fix vertical offset of fonts like MinionPro

2019-01-05 Thread Jean-Marc Lasgouttes
commit e73c0d6387f0be4b1d5e3a47e0b6d29585c52cbc
Author: Jean-Marc Lasgouttes 
Date:   Thu Jan 3 12:14:27 2019 +0100

Fix vertical offset of fonts like MinionPro

For some reason, adding a LTR/RTL Override unicode character before a
MinionPro string increases the ascent of the line.

This creates vertical offset issues when painting if the ascent used
as reference is the one of the font. Use the QTextLine ascent instead
for better results.

This is a followup to 1bed76e2a.

Fixes (reopened) ticket #11284.
Fixes ticket #10532.
Fixes ticket #10767.

(cherry picked from commit d8498d4785282a6f42a69f56ebd46ac32e1d2f51)
---
 src/frontends/qt4/GuiPainter.cpp |9 -
 status.23x   |2 ++
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp
index b03bb44..b0b1ec1 100644
--- a/src/frontends/qt4/GuiPainter.cpp
+++ b/src/frontends/qt4/GuiPainter.cpp
@@ -455,11 +455,10 @@ void GuiPainter::text(int x, int y, docstring const & s,
// don't use the pixmap cache
setQPainterPen(computeColor(f.realColor()));
if (dir != Auto) {
-   shared_ptr ptl =
-   fm.getTextLayout(s, dir == RtL, wordspacing);
-   ptl->draw(this, QPointF(x, y - fm.maxAscent()));
-   }
-   else {
+   auto ptl = fm.getTextLayout(s, dir == RtL, wordspacing);
+   QTextLine const & tline = ptl->lineForTextPosition(0);
+   ptl->draw(this, QPointF(x, y - tline.ascent()));
+   } else {
if (font() != ff)
setFont(ff);
drawText(x, y, str);
diff --git a/status.23x b/status.23x
index bcd0a13..baee939 100644
--- a/status.23x
+++ b/status.23x
@@ -115,6 +115,8 @@ What's new
 
 - Fix document updating issues with split view (bug 11354).
 
+- Fix cases where text is offset vertically (bug 10532, 10767).
+
 
 * INTERNALS
 


[LyX/2.3.x] Avoid crash when using inset-select-all in tabular

2019-01-05 Thread Jean-Marc Lasgouttes
commit 7f3407b89ac19f32e5a7af8f46de7b247d82a48e
Author: Jean-Marc Lasgouttes 
Date:   Fri Jan 4 13:57:13 2019 +0100

Avoid crash when using inset-select-all in tabular

When changing cell idx, it is important to set the pit to a reasonable
value.

(cherry picked from commit a69e01d0b47aebbdfc3139533fcb7f1d0c04f156)
---
 src/BufferView.cpp |2 ++
 status.23x |2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 66278e0..6b3a528 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1889,10 +1889,12 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
// At least one complete cell is selected and inset is 
a table.
// Select all cells
cur.idx() = 0;
+   cur.pit() = 0;
cur.pos() = 0;
cur.resetAnchor();
cur.selection(true);
cur.idx() = cur.lastidx();
+   cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
} else {
// select current cell
diff --git a/status.23x b/status.23x
index baee939..b8e5306 100644
--- a/status.23x
+++ b/status.23x
@@ -117,6 +117,8 @@ What's new
 
 - Fix cases where text is offset vertically (bug 10532, 10767).
 
+- Fix crash when using inset-select-all in tabular.
+
 
 * INTERNALS
 


[LyX/2.3.x] Fix drawing of labels in insets

2019-01-05 Thread Jean-Marc Lasgouttes
commit 3a4c4605e9cc06f700cdfeb43f3a91592adea99a
Author: Jean-Marc Lasgouttes 
Date:   Fri Jan 4 16:24:18 2019 +0100

Fix drawing of labels in insets

In many cases, the origin xo_ of insets was forgotten.

Also fix spacing between text and label in rtl

Fixes bug #11425.

(cherry picked from commit 5c1d65afee3a37d5befcf9eb55d8d50e1d8e4f13)
(cherry picked from commit 5fc035f99c42835da41d6eb6cf5a375382c06870)
---
 src/RowPainter.cpp |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index c6578ce..93ac63d 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -402,7 +402,7 @@ void RowPainter::paintLabel() const
double x = x_;
 
if (row_.isRTL())
-   x = tm_.width() - row_.right_margin + fm.width(layout.labelsep);
+   x = xo_ + row_.width() + fm.width(layout.labelsep);
else
x = x_ - fm.width(layout.labelsep) - fm.width(str);
 
@@ -437,10 +437,10 @@ void RowPainter::paintTopLevelLabel() const
 
double x = x_;
if (layout.labeltype == LABEL_CENTERED) {
-   x = row_.left_margin + (tm_.width() - row_.left_margin - 
row_.right_margin) / 2;
+   x += (tm_.width() - row_.left_margin - row_.right_margin) / 2;
x -= fm.width(str) / 2;
} else if (row_.isRTL()) {
-   x = tm_.width() - row_.right_margin - fm.width(str);
+   x = xo_ + tm_.width() - row_.right_margin - fm.width(str);
}
pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
 }
@@ -525,9 +525,9 @@ void RowPainter::paintLast() const
}
 
if (endlabel == END_LABEL_BOX)
-   pi_.pain.rectangle(x, y, size, size, Color_eolmarker);
+   pi_.pain.rectangle(xo_ + x, y, size, size, 
Color_eolmarker);
else
-   pi_.pain.fillRectangle(x, y, size, size, 
Color_eolmarker);
+   pi_.pain.fillRectangle(xo_ + x, y, size, size, 
Color_eolmarker);
break;
}
 


[LyX/2.3.x] forgot this

2019-01-05 Thread Jean-Marc Lasgouttes
commit ca8f6c09b664872019eb504b151e0e6cfbdfbd21
Author: Jean-Marc Lasgouttes 
Date:   Sat Jan 5 15:04:51 2019 +0100

forgot this
---
 status.23x |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/status.23x b/status.23x
index b8e5306..07e2adc 100644
--- a/status.23x
+++ b/status.23x
@@ -117,6 +117,8 @@ What's new
 
 - Fix cases where text is offset vertically (bug 10532, 10767).
 
+- Display of start/end labels of paragraphs in insets (bug 11425).
+
 - Fix crash when using inset-select-all in tabular.
 
 


[LyX/2.3.x] Allow toggling (no)limits only after mathop symbol

2019-01-05 Thread Jean-Marc Lasgouttes
commit 85e693806e206b24e9fd7d010368fba36a2b9710
Author: Jean-Marc Lasgouttes 
Date:   Mon Sep 3 17:49:54 2018 +0200

Allow toggling (no)limits only after mathop symbol

In particular, introduce the new InsetMathScript::allowLimits method
that checks for that and honor it in getStatus/ddoDispatch.

Do the same for (over|under)brace

(cherry picked from commit 7b7ed64a0e760eccad5fff7fa944b983d0bed025)
(cherry picked from commit 6cfd733dea70bf26c512dea8491f79f68cb512e6)
---
 src/mathed/InsetMathDecoration.cpp |   12 +++--
 src/mathed/InsetMathDecoration.h   |2 +
 src/mathed/InsetMathScript.cpp |   42 +++
 src/mathed/InsetMathScript.h   |2 +
 status.23x |2 +
 5 files changed, 47 insertions(+), 13 deletions(-)

diff --git a/src/mathed/InsetMathDecoration.cpp 
b/src/mathed/InsetMathDecoration.cpp
index 908a887..1262370 100644
--- a/src/mathed/InsetMathDecoration.cpp
+++ b/src/mathed/InsetMathDecoration.cpp
@@ -55,11 +55,17 @@ bool InsetMathDecoration::upper() const
 }
 
 
+MathClass InsetMathDecoration::mathClass() const
+{
+   if (key_->name == "overbrace" || key_->name == "underbrace")
+   return MC_OP;
+   return MC_ORD;
+}
+
+
 bool InsetMathDecoration::isScriptable() const
 {
-   return
-   key_->name == "overbrace" ||
-   key_->name == "underbrace";
+   return mathClass() == MC_OP;
 }
 
 
diff --git a/src/mathed/InsetMathDecoration.h b/src/mathed/InsetMathDecoration.h
index 9e58065..a5d5e9c 100644
--- a/src/mathed/InsetMathDecoration.h
+++ b/src/mathed/InsetMathDecoration.h
@@ -38,6 +38,8 @@ public:
///
void infoize(odocstream & os) const;
///
+   MathClass mathClass() const;
+   ///
bool isScriptable() const;
///
void validate(LaTeXFeatures & features) const;
diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index 57f3b87..315637c 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -381,6 +381,20 @@ void InsetMathScript::drawT(TextPainter & pain, int x, int 
y) const
 }
 
 
+// FIXME: See InsetMathSymbol::takesLimits, which seems to attempt the
+// same in a hardcoded way. takeLimits use is currently commented out in
+// InsetMathScript::metrics. It seems that the mathop test is general
+// enough, but only time will tell.
+bool InsetMathScript::allowsLimits() const
+{
+   if (nuc().empty())
+   return false;
+   // Only makes sense for insets of mathop class
+   if (nuc().back()->mathClass() != MC_OP)
+   return false;
+   return true;
+}
+
 
 bool InsetMathScript::hasLimits() const
 {
@@ -391,8 +405,9 @@ bool InsetMathScript::hasLimits() const
return false;
 
// we can only display limits if the nucleus wants some
-   if (nuc().empty())
+   if (!allowsLimits())
return false;
+   // FIXME: this is some hardcoding done in InsetMathSymbol::metrics.
if (!nuc().back()->isScriptable())
return false;
 
@@ -751,6 +766,9 @@ void InsetMathScript::doDispatch(Cursor & cur, FuncRequest 
& cmd)
//LYXERR("InsetMathScript: request: " << cmd);
 
if (cmd.action() == LFUN_MATH_LIMITS) {
+   // only when nucleus allows this
+   if (!allowsLimits())
+   return;
cur.recordUndoInset();
if (!cmd.argument().empty()) {
if (cmd.argument() == "limits")
@@ -774,15 +792,19 @@ bool InsetMathScript::getStatus(Cursor & cur, FuncRequest 
const & cmd,
FuncStatus & flag) const
 {
if (cmd.action() == LFUN_MATH_LIMITS) {
-   if (!cmd.argument().empty()) {
-   if (cmd.argument() == "limits")
-   flag.setOnOff(limits_ == 1);
-   else if (cmd.argument() == "nolimits")
-   flag.setOnOff(limits_ == -1);
-   else
-   flag.setOnOff(limits_ == 0);
-   }
-   flag.setEnabled(true);
+   // only when nucleus allows this
+   if (allowsLimits()) {
+   if (!cmd.argument().empty()) {
+   if (cmd.argument() == "limits")
+   flag.setOnOff(limits_ == 1);
+   else if (cmd.argument() == "nolimits")
+   flag.setOnOff(limits_ == -1);
+   else
+   flag.setOnOff(limits_ == 0);
+   }
+   fl

[LyX/2.3.x] Fix display of gather in lefteqn mode

2019-01-07 Thread Jean-Marc Lasgouttes
commit e8d96cb9b159c0e61c669b9a64e5deff00b4be9b
Author: Jean-Marc Lasgouttes 
Date:   Thu Oct 4 16:05:46 2018 +0200

Fix display of gather in lefteqn mode

The column is flushed when the display of equations is flushed.

Not sure what to do with RtL languages.

Fixes bug 11324.

(cherry picked from commit 7cb0284a3ffa469c4c99184725f5a3e0b4056508)
---
 src/mathed/InsetMathGrid.cpp  |8 ++--
 src/mathed/InsetMathGrid.h|7 +--
 src/mathed/InsetMathHull.cpp  |4 ++--
 src/mathed/InsetMathSplit.cpp |5 +++--
 status.23x|3 +++
 5 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index f015285..f962542 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -1843,15 +1843,19 @@ bool InsetMathGrid::getStatus(Cursor & cur, FuncRequest 
const & cmd,
 
 
 // static
-char InsetMathGrid::colAlign(HullType type, col_type col)
+char InsetMathGrid::colAlign(HullType type, col_type col, BufferParams const & 
bp)
 {
switch (type) {
case hullEqnArray:
return "rcl"[col % 3];
 
case hullMultline:
-   case hullGather:
return 'c';
+   case hullGather:
+   if (!bp.is_math_indent)
+   return 'c';
+   else
+   return 'l';
 
case hullAlign:
case hullAlignAt:
diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h
index 9cd22ea..2e48453 100644
--- a/src/mathed/InsetMathGrid.h
+++ b/src/mathed/InsetMathGrid.h
@@ -18,6 +18,8 @@
 
 namespace lyx {
 
+class BufferParams;
+
 
 /** Gridded math inset base class.
  *  This is the base to all grid-like editable math objects
@@ -267,8 +269,9 @@ protected:
 
// The following two functions are used in InsetMathHull and
// InsetMathSplit.
-   /// The value of a fixed col align for a certain hull type
-   static char colAlign(HullType type, col_type col);
+   /// The value of a fixed col align for a certain hull type (can
+   /// depend on the "indent math" setting).
+   static char colAlign(HullType type, col_type col,  BufferParams const 
&);
/// The value of a fixed col spacing for a certain hull type
static int colSpace(HullType type, col_type col);
 
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 0f7e9a8..2c2cd41 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -446,7 +446,7 @@ bool InsetMathHull::idxLast(Cursor & cur) const
 // alignment is not implemented in the LyXHTML output.
 char InsetMathHull::defaultColAlign(col_type col)
 {
-   return colAlign(type_, col);
+   return colAlign(type_, col, buffer().params());
 }
 
 
@@ -468,7 +468,7 @@ char InsetMathHull::displayColAlign(idx_type idx) const
case hullXAlignAt:
case hullXXAlignAt:
case hullFlAlign:
-   return colAlign(type_, col(idx));
+   return colAlign(type_, col(idx), buffer().params());
default:
break;
}
diff --git a/src/mathed/InsetMathSplit.cpp b/src/mathed/InsetMathSplit.cpp
index c260e2e..200a0bc 100644
--- a/src/mathed/InsetMathSplit.cpp
+++ b/src/mathed/InsetMathSplit.cpp
@@ -16,6 +16,7 @@
 #include "MathStream.h"
 #include "MathSupport.h"
 
+#include "Buffer.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "support/gettext.h"
@@ -61,7 +62,7 @@ char InsetMathSplit::defaultColAlign(col_type col)
|| name_ == "aligned"
|| name_ == "align"
|| name_ == "alignedat")
-   return colAlign(hullAlign, col);
+   return colAlign(hullAlign, col, buffer().params());
return 'l';
 }
 
@@ -78,7 +79,7 @@ char InsetMathSplit::displayColAlign(idx_type idx) const
|| name_ == "aligned"
|| name_ == "align"
|| name_ == "alignedat")
-   return colAlign(hullAlign, col(idx));
+   return colAlign(hullAlign, col(idx), buffer().params());
return InsetMathGrid::displayColAlign(idx);
 }
 
diff --git a/status.23x b/status.23x
index 1bc9f27..83beca4 100644
--- a/status.23x
+++ b/status.23x
@@ -128,6 +128,9 @@ What's new
 
 - Repair (de)activation of plural, capitalize, etc, for refstyle.
 
+- Fix display of gather environment in leqno mode (bug 11324).
+
+
 
 * INTERNALS
 


[LyX/master] use range-based for loops

2019-01-07 Thread Jean-Marc Lasgouttes
commit 4bc8e90c25c076015733c98da7743c72e3a8b757
Author: Jean-Marc Lasgouttes 
Date:   Mon Jan 7 13:50:55 2019 +0100

use range-based for loops
---
 src/RowPainter.cpp |   11 ++-
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index a924614..e547888 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -580,10 +580,7 @@ void RowPainter::paintLast() const
 
 void RowPainter::paintOnlyInsets()
 {
-   Row::const_iterator cit = row_.begin();
-   Row::const_iterator const & end = row_.end();
-   for ( ; cit != end ; ++cit) {
-   Row::Element const & e = *cit;
+   for (Row::Element const & e : row_) {
if (e.type == Row::INSET) {
paintInset(e);
// The markings of foreign languages
@@ -601,11 +598,7 @@ void RowPainter::paintOnlyInsets()
 
 void RowPainter::paintText()
 {
-   Row::const_iterator cit = row_.begin();
-   Row::const_iterator const & end = row_.end();
-   for ( ; cit != end ; ++cit) {
-   Row::Element const & e = *cit;
-
+   for (Row::Element const & e : row_) {
switch (e.type) {
case Row::STRING:
case Row::VIRTUAL:


[LyX/master] Fix alignment of rows when text width is variable

2019-01-11 Thread Jean-Marc Lasgouttes
commit edb46d2a949c2832ab3b594fd0006f092ec0421c
Author: Jean-Marc Lasgouttes 
Date:   Fri Jan 11 15:55:17 2019 +0100

Fix alignment of rows when text width is variable

When several lines of text are in the same variable-width tabular
cell, it is not possible to align properly the rows until the cell
width is known.

Therefore a parameter is added to redoParagraph to skip this
computation, so that it can be done later in TextMetrics::metrics.
Other calls to redoParagraph in the code are not affected. It is not
clear at this point whether they may create artefacts.

computeRowMetrics has been renamed to setRowAlignment to better
reflect its use.

Fixes bug #11447.
---
 src/TextMetrics.cpp   |   20 ++--
 src/TextMetrics.h |9 -
 src/insets/InsetSpace.cpp |2 +-
 3 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index a106338..29c81da 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -182,13 +182,21 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & 
dim, int min_width,
bool changed = false;
unsigned int h = 0;
for (pit_type pit = 0; pit != npar; ++pit) {
-   changed |= redoParagraph(pit);
+   // create rows, but do not set alignment yet
+   changed |= redoParagraph(pit, false);
ParagraphMetrics const & pm = par_metrics_[pit];
h += pm.height();
if (dim_.wid < pm.width())
dim_.wid = pm.width();
}
 
+   // Now set alignment for all rows (the width might not have been known 
before).
+   for (pit_type pit = 0; pit != npar; ++pit) {
+   ParagraphMetrics & pm = par_metrics_[pit];
+   for (Row & row : pm.rows())
+   setRowAlignment(row, dim_.wid);
+   }
+
dim_.asc = par_metrics_[0].ascent();
dim_.des = h - dim_.asc;
//lyxerr << "dim_.wid " << dim_.wid << endl;
@@ -354,7 +362,7 @@ bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos,
 }
 
 
-bool TextMetrics::redoParagraph(pit_type const pit)
+bool TextMetrics::redoParagraph(pit_type const pit, bool const align_rows)
 {
Paragraph & par = text_->getPar(pit);
// IMPORTANT NOTE: We pass 'false' explicitly in order to not call
@@ -474,14 +482,14 @@ bool TextMetrics::redoParagraph(pit_type const pit)
/* If there is more than one row or the row has been
 * broken by a display inset or a newline, expand the 
text
 * to the full allowable width. This setting here is
-* needed for the computeRowMetrics() below.
+* needed for the setRowAlignment() below.
 * We do nothing when inside a table cell.
 */
if (dim_.wid < max_width_)
dim_.wid = max_width_;
}
-   int const max_row_width = max(dim_.wid, row.width());
-   computeRowMetrics(row, max_row_width);
+   if (align_rows)
+   setRowAlignment(row, max(dim_.wid, row.width()));
first = row.endpos();
++row_index;
 
@@ -588,7 +596,7 @@ LyXAlignment TextMetrics::getAlign(Paragraph const & par, 
Row const & row) const
 }
 
 
-void TextMetrics::computeRowMetrics(Row & row, int width) const
+void TextMetrics::setRowAlignment(Row & row, int width) const
 {
row.label_hfill = 0;
row.separator = 0;
diff --git a/src/TextMetrics.h b/src/TextMetrics.h
index 6802488..a4a1e23 100644
--- a/src/TextMetrics.h
+++ b/src/TextMetrics.h
@@ -97,7 +97,7 @@ public:
/// Rebreaks the given paragraph.
/// \retval true if a full screen redraw is needed.
/// \retval false if a single paragraph redraw is enough.
-   bool redoParagraph(pit_type const pit);
+   bool redoParagraph(pit_type const pit, bool align_rows = true);
/// Clear cache of paragraph metrics
void clear() { par_metrics_.clear(); }
/// Is cache of paragraph metrics empty ?
@@ -145,11 +145,10 @@ private:
/// \return true when another row is required (after a newline)
bool breakRow(Row & row, int right_margin) const;
 
-   // Expand the alignment of row \param row in paragraph \param par
+   // Expands the alignment of row \param row in paragraph \param par
LyXAlignment getAlign(Paragraph const & par, Row const & row) const;
-   /** this calculates the specified parameters. needed when setting
-* the cursor and when creating a visible row */
-   void computeRowMetrics(Row & row, int width) const;
+   /// Aligns properly the row contents 

[LyX/master] Allow to type a space in front of another one

2019-01-14 Thread Jean-Marc Lasgouttes
commit 7848d3c90c0837e8e8549db37bf4bc5cd7e7dad1
Author: Jean-Marc Lasgouttes 
Date:   Mon Jan 14 16:37:10 2019 +0100

Allow to type a space in front of another one

This is a follow-up to 714b731e. This fixes the issue when the cursor
is in front of a space
  abc| def
and one inserts another space (to start a word). DEPM would eat one
space and produce
  abc |def
instead of
  abc | def

Additionally, fix the same_par boolean, wheich did not take the cell
index into account.

Related to ticket #11412.
---
 src/Text2.cpp |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index cb394c2..f505ead 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -819,8 +819,8 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
   There are still some small problems that can lead to
   double spaces stored in the document file or space at
   the beginning of paragraphs(). This happens if you have
-  the cursor between to spaces and then save. Or if you
-  cut and paste and the selection have a space at the
+  the cursor between two spaces and then save. Or if you
+  cut and paste and the selection has a space at the
   beginning and then save right after the paste. (Lgb)
*/
 
@@ -840,7 +840,8 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
// Whether a common inset is found and whether the cursor is still in
// the same paragraph (possibly nested).
-   bool const same_par = depth < cur.depth() && old.pit() == 
cur[depth].pit();
+   bool const same_par = depth < cur.depth() && old.idx() == 
cur[depth].idx()
+   && old.pit() == cur[depth].pit();
bool const same_par_pos = depth == cur.depth() - 1 && same_par
&& old.pos() == cur[depth].pos();
 
@@ -863,7 +864,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
if (from != to && from > 0 && to < oldpar.size())
++from;
 
-   if (same_par && cur.pos() > from && cur.pos() < to)
+   if (same_par && cur.pos() >= from && cur.pos() < to)
++from;
 
// Remove spaces and adapt cursor.


[LyX/2.3.x] Allow to type a space in front of another one

2019-01-16 Thread Jean-Marc Lasgouttes
commit aa2f5eb426db6d3ea307c726fe7d649d9634f92d
Author: Jean-Marc Lasgouttes 
Date:   Mon Jan 14 16:37:10 2019 +0100

Allow to type a space in front of another one

This is a follow-up to 714b731e. This fixes the issue when the cursor
is in front of a space
  abc| def
and one inserts another space (to start a word). DEPM would eat one
space and produce
  abc |def
instead of
  abc | def

Additionally, fix the same_par boolean, wheich did not take the cell
index into account.

Related to ticket #11412.

(cherry picked from commit 7848d3c90c0837e8e8549db37bf4bc5cd7e7dad1)
---
 src/Text2.cpp |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index d6f5a83..bcd38f4 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -824,8 +824,8 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
   There are still some small problems that can lead to
   double spaces stored in the document file or space at
   the beginning of paragraphs(). This happens if you have
-  the cursor between to spaces and then save. Or if you
-  cut and paste and the selection have a space at the
+  the cursor between two spaces and then save. Or if you
+  cut and paste and the selection has a space at the
   beginning and then save right after the paste. (Lgb)
*/
 
@@ -845,7 +845,8 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
// Whether a common inset is found and whether the cursor is still in
// the same paragraph (possibly nested).
-   bool const same_par = depth < cur.depth() && old.pit() == 
cur[depth].pit();
+   bool const same_par = depth < cur.depth() && old.idx() == 
cur[depth].idx()
+   && old.pit() == cur[depth].pit();
bool const same_par_pos = depth == cur.depth() - 1 && same_par
&& old.pos() == cur[depth].pos();
 
@@ -868,7 +869,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
if (from != to && from > 0 && to < oldpar.size())
++from;
 
-   if (same_par && cur.pos() > from && cur.pos() < to)
+   if (same_par && cur.pos() >= from && cur.pos() < to)
++from;
 
// Remove spaces and adapt cursor.


[LyX/master] Try to compute row height like it should be done

2019-01-16 Thread Jean-Marc Lasgouttes
commit 66a3d64346332e47252b37dbc0f80158738987dc
Author: Jean-Marc Lasgouttes 
Date:   Thu Jan 3 16:03:48 2019 +0100

Try to compute row height like it should be done

Currently, our computation of row height is not completely standard:
* we ignore completely the QFontMetrics::leading() parameter

* we add arbitrarily 2 hardcoded pixels to the height.

This patch reverses these two choices, which leads to
* slightly larger spacing for MinionPro (which has a big leading).

* an additional spacing of 20% font height that depends on dpi and zoom.

Visual inspection with LibreOffice seems to imply that it disregards
the font leading but uses a interline which is 20% larger than the
font height.
---
 src/Row.cpp  |5 -
 src/TextMetrics.cpp  |   32 +++-
 src/frontends/FontMetrics.h  |2 ++
 src/frontends/qt4/GuiFontMetrics.cpp |6 ++
 src/frontends/qt4/GuiFontMetrics.h   |1 +
 5 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/src/Row.cpp b/src/Row.cpp
index 697e526..1a12e9d 100644
--- a/src/Row.cpp
+++ b/src/Row.cpp
@@ -376,8 +376,11 @@ void Row::finalizeLast()
 
if (elt.type == STRING) {
dim_.wid -= elt.dim.wid;
-   elt.dim.wid = theFontMetrics(elt.font).width(elt.str);
+   FontMetrics const & fm = theFontMetrics(elt.font);
+   elt.dim.wid = fm.width(elt.str);
dim_.wid += elt.dim.wid;
+   dim_.asc = fm.maxAscent() + fm.leading();
+   dim_.des = fm.maxDescent();
}
 }
 
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 29c81da..094b80d 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -48,6 +48,7 @@
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/lassert.h"
+#include "support/lyxlib.h"
 
 #include 
 #include 
@@ -61,6 +62,10 @@ using frontend::FontMetrics;
 
 namespace {
 
+// the somewhat arbitrary leading added between rows. This is 20% of
+// the characters height, inluding the possible leading of the font.
+// 20% is a standard value used by LaTeX and word processors.
+double const extra_leading = 0.2;
 
 int numberOfLabelHfills(Paragraph const & par, Row const & row)
 {
@@ -1088,27 +1093,19 @@ void TextMetrics::setRowHeight(Row & row) const
// Initial value for ascent (useful if row is empty).
Font const font = displayFont(row.pit(), row.pos());
FontMetrics const & fm = theFontMetrics(font);
-   int maxasc = int(fm.maxAscent() * spacing_val);
-   int maxdes = int(fm.maxDescent() * spacing_val);
+   int maxasc = fm.maxAscent() + fm.leading();
+   int maxdes = fm.maxDescent();
 
// Find the ascent/descent of the row contents
for (Row::Element const & e : row) {
-   if (e.inset) {
-   maxasc = max(maxasc, e.dim.ascent());
-   maxdes = max(maxdes, e.dim.descent());
-   } else {
-   FontMetrics const & fm2 = theFontMetrics(e.font);
-   maxasc = max(maxasc, int(fm2.maxAscent() * 
spacing_val));
-   maxdes = max(maxdes, int(fm2.maxDescent() * 
spacing_val));
-   }
+   maxasc = max(maxasc, e.dim.ascent());
+   maxdes = max(maxdes, e.dim.descent());
}
 
-   // This is nicer with box insets
-   ++maxasc;
-   ++maxdes;
-
-   row.dimension().asc = maxasc;
-   row.dimension().des = maxdes;
+   // Add some leading (split between before and after)
+   int const leading = support::iround(extra_leading * (maxasc + maxdes));
+   row.dimension().asc = int((maxasc + leading - leading / 2) * 
spacing_val);
+   row.dimension().des = int((maxdes + leading / 2) * spacing_val);
 }
 
 
@@ -2009,7 +2006,8 @@ void TextMetrics::completionPosAndDim(Cursor const & cur, 
int & x, int & y,
 
 int defaultRowHeight()
 {
-   return int(theFontMetrics(sane_font).maxHeight() *  1.2);
+   FontMetrics const & fm = theFontMetrics(sane_font);
+   return support::iround(fm.maxHeight() * (1 + extra_leading) + 
fm.leading());
 }
 
 } // namespace lyx
diff --git a/src/frontends/FontMetrics.h b/src/frontends/FontMetrics.h
index 4472aa7..a35a26b 100644
--- a/src/frontends/FontMetrics.h
+++ b/src/frontends/FontMetrics.h
@@ -60,6 +60,8 @@ public:
virtual int maxAscent() const = 0;
/// return the maximum descent of the font
virtual int maxDescent() const = 0;
+   /// return the default leading of the font (often 0)
+   virtual int leading() const = 0;
/// return default dimension of the font.
/// \warning \c width is set to zero.
virtual Dimension const defaultDimension() const = 0;
diff --git a/src/frontends/qt4/GuiFontMetrics

[LyX/master] Fix for #11294: Wrong description for Change bars module

2019-01-19 Thread Jean-Marc Lasgouttes
commit f71723c8f333819bcaa5180fe98d9cd4c1491ba8
Author: Daniel Ramoeller 
Date:   Mon Dec 31 12:14:46 2018 +0100

Fix for #11294: Wrong description for Change bars module
---
 lib/layouts/changebars.module |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/layouts/changebars.module b/lib/layouts/changebars.module
index 8923ba1..e9a8328 100644
--- a/lib/layouts/changebars.module
+++ b/lib/layouts/changebars.module
@@ -2,7 +2,7 @@
 #
 #DescriptionBegin
 #Enables LyX to add vertical change bars in the margin of PDF output
-#when change tracking is turned on and pdflatex output format is chosen.
+#when Show Changes in Output is turned on and pdflatex output format is chosen.
 #DescriptionEnd
 #
 #Author: Paul A. Rubin (ru...@msu.edu)


[LyX/master] Take care of spaces tracked as inserted in depm

2019-01-28 Thread Jean-Marc Lasgouttes
commit 4435be026ed5a766ad73b9158e1425afedf38630
Author: Jean-Marc Lasgouttes 
Date:   Mon Jan 28 10:21:26 2019 +0100

Take care of spaces tracked as inserted in depm

When there are Change::INSERTED spaces in the range of consecutive
spaces to delete, it is better to remove them first.

Part of bug #11412.
---
 src/Text2.cpp |   67 +---
 1 files changed, 30 insertions(+), 37 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index f505ead..fe6d1fb 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -780,30 +780,6 @@ bool Text::cursorDownParagraph(Cursor & cur)
 }
 
 
-namespace {
-// fix the cursor `cur' after characters has been deleted at `where'
-// position. Called by deleteEmptyParagraphMechanism
-void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where,
- pos_type from, pos_type to)
-{
-   // Do nothing if cursor is not in the paragraph where the
-   // deletion occurred,
-   if (cur.pit() != where.pit())
-   return;
-
-   // If cursor position is after the deletion place update it
-   if (cur.pos() > from)
-   cur.pos() = max(from, cur.pos() - (to - from));
-
-   // Check also if we don't want to set the cursor on a spot behind the
-   // pagragraph because we erased the last character.
-   if (cur.pos() > cur.lastpos())
-   cur.pos() = cur.lastpos();
-}
-
-}
-
-
 bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
Cursor & old, bool & need_anchor_change)
 {
@@ -849,34 +825,51 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
// them, but only if the cursor has really moved.
if (!same_par_pos) {
// find range of spaces around cursors
-   int from = old.pos();
+   pos_type from = old.pos();
while (from > 0
   && oldpar.isLineSeparator(from - 1)
   && !oldpar.isDeleted(from - 1))
--from;
-   int to = old.pos();
+   pos_type to = old.pos();
while (to < oldpar.size() - 1
   && oldpar.isLineSeparator(to)
   && !oldpar.isDeleted(to))
++to;
 
+   int num_spaces = to - from;
+
// If we are not at the extremity of the paragraph, keep one 
space
if (from != to && from > 0 && to < oldpar.size())
-   ++from;
+   --num_spaces;
 
-   if (same_par && cur.pos() >= from && cur.pos() < to)
-   ++from;
+   // If cursor is inside range, keep one additional space
+   if (same_par && cur.pos() > from && cur.pos() < to)
+   --num_spaces;
 
// Remove spaces and adapt cursor.
-   if (from < to) {
-   oldpar.eraseChars(from, to, 
cur.buffer()->params().track_changes);
-// FIXME: This will not work anymore when we have multiple views of the same 
buffer
-// In this case, we will have to correct also the cursors held by
-// other bufferviews. It will probably be easier to do that in a more
-// automated way in CursorSlice code. (JMarc 26/09/2001)
-   // correct all cursor parts
+   if (num_spaces > 0) {
+   // delete first spaces marked as inserted
+   int pos = from;
+   int ns = num_spaces;
+   while (pos < to && ns > 0) {
+   Change const & change = 
oldpar.lookupChange(pos);
+   if (change.inserted() && 
change.currentAuthor()) {
+   oldpar.eraseChar(pos, 
cur.buffer()->params().track_changes);
+   --ns;
+   --to;
+   } else
+   ++pos;
+   }
+
+   // Then remove remaining spaces
+   oldpar.eraseChars(from, from + ns, 
cur.buffer()->params().track_changes);
+   // correct cur position
+   // FIXME: there can be other cursors pointing there, we 
should update them
if (same_par) {
-   fixCursorAfterDelete(cur[depth], old.top(), 
from, to);
+   if (cur[depth].pos() >= to)
+   cur[depth].pos() -= num_spaces;
+   else if (cur[depth].pos() > from)
+   cur[depth].pos() = min(from + 1, 
old.lastpos());
need_anchor_change = true;
}
return true;


[LyX/master] DEPM: some factorization beween both versions

2019-01-29 Thread Jean-Marc Lasgouttes
commit 5c380dcc732b1afda3c4413a56773b2e264d9ae2
Author: Jean-Marc Lasgouttes 
Date:   Tue Jan 29 14:38:17 2019 +0100

DEPM: some factorization beween both versions

Additionally, correct the cursor by an offset equal to the variation of 
paragraph size : if change tracking is on, deleting a space may mean that it is 
just marked as deleted.

Part of bug #11412.
---
 src/BufferView.cpp |2 +-
 src/Text2.cpp  |   61 +--
 2 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index af37287..7edf9e2 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2608,7 +2608,7 @@ bool BufferView::checkDepm(Cursor & cur, Cursor & old)
return false;
 
bool need_anchor_change = false;
-   bool changed = d->cursor_.text()->deleteEmptyParagraphMechanism(cur, 
old,
+   bool changed = Text::deleteEmptyParagraphMechanism(cur, old,
need_anchor_change);
 
if (need_anchor_change)
diff --git a/src/Text2.cpp b/src/Text2.cpp
index fe6d1fb..356e4e8 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -779,6 +779,32 @@ bool Text::cursorDownParagraph(Cursor & cur)
return updated;
 }
 
+namespace {
+
+void deleteSpaces(Paragraph & par, pos_type const from, pos_type to,
+ int num_spaces, bool const trackChanges)
+{
+   if (!num_spaces)
+   return;
+
+   // First, delete spaces marked as inserted
+   int pos = from;
+   while (pos < to && num_spaces > 0) {
+   Change const & change = par.lookupChange(pos);
+   if (change.inserted() && change.currentAuthor()) {
+   par.eraseChar(pos, trackChanges);
+   --num_spaces;
+   --to;
+   } else
+   ++pos;
+   }
+
+   // Then remove remaining spaces
+   par.eraseChars(from, from + num_spaces, trackChanges);
+}
+
+}
+
 
 bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
Cursor & old, bool & need_anchor_change)
@@ -848,26 +874,14 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
// Remove spaces and adapt cursor.
if (num_spaces > 0) {
-   // delete first spaces marked as inserted
-   int pos = from;
-   int ns = num_spaces;
-   while (pos < to && ns > 0) {
-   Change const & change = 
oldpar.lookupChange(pos);
-   if (change.inserted() && 
change.currentAuthor()) {
-   oldpar.eraseChar(pos, 
cur.buffer()->params().track_changes);
-   --ns;
-   --to;
-   } else
-   ++pos;
-   }
-
-   // Then remove remaining spaces
-   oldpar.eraseChars(from, from + ns, 
cur.buffer()->params().track_changes);
+   pos_type const oldsize = oldpar.size();
+   deleteSpaces(oldpar, from, to, num_spaces,
+   cur.buffer()->params().track_changes);
// correct cur position
// FIXME: there can be other cursors pointing there, we 
should update them
if (same_par) {
if (cur[depth].pos() >= to)
-   cur[depth].pos() -= num_spaces;
+   cur[depth].pos() -= oldsize - 
oldpar.size();
else if (cur[depth].pos() > from)
cur[depth].pos() = min(from + 1, 
old.lastpos());
need_anchor_change = true;
@@ -952,12 +966,15 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, 
pit_type last, bool tra
// empty? We are done
if (from == to)
break;
-   // if inside the line, keep one space
-   if (from > 0 && to < par.size())
-   ++from;
-   // remove the extra spaces
-   if (from < to)
-   par.eraseChars(from, to, trackChanges);
+
+   int num_spaces = to - from;
+
+   // If we are not at the extremity of the paragraph, 
keep one space
+   if (from != to && from > 0 && to < par.size())
+   --num_spaces;
+
+   // Remove spaces if needed
+   

[LyX/master] Fix DEPM at end of paragraph

2019-01-30 Thread Jean-Marc Lasgouttes
commit c00234503f9e07795723222e6095c022e45ad1dd
Author: Jean-Marc Lasgouttes 
Date:   Wed Jan 30 23:50:53 2019 +0100

Fix DEPM at end of paragraph

Remove special handling of spaces at end of paragraph. Now they are
handled like interword spaces by both DEPM methods.

Fix off-by-one error in loop when testing for end of paragraph.

Style: use Dociterator::lastpos() instead of Paragraph::size().

Part of bug #11412.
---
 src/Text2.cpp |   11 +--
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index 356e4e8..ae35fad 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -857,15 +857,14 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
   && !oldpar.isDeleted(from - 1))
--from;
pos_type to = old.pos();
-   while (to < oldpar.size() - 1
+   while (to < old.lastpos()
   && oldpar.isLineSeparator(to)
   && !oldpar.isDeleted(to))
++to;
 
int num_spaces = to - from;
-
-   // If we are not at the extremity of the paragraph, keep one 
space
-   if (from != to && from > 0 && to < oldpar.size())
+   // If we are not at the start of the paragraph, keep one space
+   if (from != to && from > 0)
--num_spaces;
 
// If cursor is inside range, keep one additional space
@@ -874,14 +873,14 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
// Remove spaces and adapt cursor.
if (num_spaces > 0) {
-   pos_type const oldsize = oldpar.size();
+   pos_type const oldlast = old.lastpos();
deleteSpaces(oldpar, from, to, num_spaces,
cur.buffer()->params().track_changes);
// correct cur position
// FIXME: there can be other cursors pointing there, we 
should update them
if (same_par) {
if (cur[depth].pos() >= to)
-   cur[depth].pos() -= oldsize - 
oldpar.size();
+   cur[depth].pos() -= oldlast - 
old.lastpos();
else if (cur[depth].pos() > from)
cur[depth].pos() = min(from + 1, 
old.lastpos());
need_anchor_change = true;


[LyX/master] Do not rely on x_ when painting label

2019-02-04 Thread Jean-Marc Lasgouttes
commit 051b6ce68af2b7b075e1abb89e1e960beae71379
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 4 12:13:01 2019 +0100

Do not rely on x_ when painting label

Additionally fixes a warning about unused value (from clang-analyzer).
---
 src/RowPainter.cpp  |   10 +++---
 src/TextMetrics.cpp |8 ++--
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index e547888..9534b20 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -429,14 +429,10 @@ void RowPainter::paintLabel() const
Layout const & layout = par_.layout();
FontInfo const font = labelFont(false);
FontMetrics const & fm = theFontMetrics(font);
-   double x = x_;
-
-   if (row_.isRTL())
-   x = xo_ + row_.width() + fm.width(layout.labelsep);
-   else
-   x = x_ - fm.width(layout.labelsep) - fm.width(str);
+   int const x = row_.isRTL() ? row_.width() + fm.width(layout.labelsep)
+  : row_.left_margin - 
fm.width(layout.labelsep) - fm.width(str);
 
-   pi_.pain.text(int(x), yo_, str, font);
+   pi_.pain.text(xo_ + x, yo_, str, font);
 }
 
 
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 094b80d..edc9f69 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1934,15 +1934,11 @@ void TextMetrics::drawParagraph(PainterInfo & pi, 
pit_type const pit, int const
rp.paintDepthBar();
if (row.needsChangeBar())
rp.paintChangeBar();
-   if (i == 0 && !row.isRTL())
+   if (i == 0)
rp.paintFirst();
-   if (i == nrows - 1 && row.isRTL())
+   if (i == nrows - 1)
rp.paintLast();
rp.paintText();
-   if (i == nrows - 1 && !row.isRTL())
-   rp.paintLast();
-   if (i == 0 && row.isRTL())
-   rp.paintFirst();
rp.paintTooLargeMarks(row_x + row.left_x() < 0,
  row_x + row.right_x() > bv_->workWidth());
y += row.descent();


[LyX/master] DEPM: fix infinite loop.

2019-02-05 Thread Jean-Marc Lasgouttes
commit 5e4fd6c796705ccd752b2dc26e4bd2b42bb11371
Author: Jean-Marc Lasgouttes 
Date:   Tue Feb 5 11:51:24 2019 +0100

DEPM: fix infinite loop.
---
 src/Text2.cpp |   24 +++-
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index ae35fad..2b3cb48 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -781,11 +781,14 @@ bool Text::cursorDownParagraph(Cursor & cur)
 
 namespace {
 
-void deleteSpaces(Paragraph & par, pos_type const from, pos_type to,
+/** delete num_spaces characters between from and to. Return the
+ * number of spaces that got physically deleted (not marked as
+ * deleted */
+int deleteSpaces(Paragraph & par, pos_type const from, pos_type to,
  int num_spaces, bool const trackChanges)
 {
-   if (!num_spaces)
-   return;
+   if (num_spaces <= 0)
+   return 0;
 
// First, delete spaces marked as inserted
int pos = from;
@@ -800,7 +803,9 @@ void deleteSpaces(Paragraph & par, pos_type const from, 
pos_type to,
}
 
// Then remove remaining spaces
+   int const psize = par.size();
par.eraseChars(from, from + num_spaces, trackChanges);
+   return psize - par.size();
 }
 
 }
@@ -812,6 +817,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
//LYXERR(Debug::DEBUG, "DEPM: cur:\n" << cur << "old:\n" << old);
 
Paragraph & oldpar = old.paragraph();
+   bool const trackChanges = cur.buffer()->params().track_changes;
 
// We allow all kinds of "mumbo-jumbo" when freespacing.
if (oldpar.isFreeSpacing())
@@ -873,14 +879,13 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
// Remove spaces and adapt cursor.
if (num_spaces > 0) {
-   pos_type const oldlast = old.lastpos();
-   deleteSpaces(oldpar, from, to, num_spaces,
-   cur.buffer()->params().track_changes);
+   int const deleted =
+   deleteSpaces(oldpar, from, to, num_spaces, 
trackChanges);
// correct cur position
// FIXME: there can be other cursors pointing there, we 
should update them
if (same_par) {
if (cur[depth].pos() >= to)
-   cur[depth].pos() -= oldlast - 
old.lastpos();
+   cur[depth].pos() -= deleted;
else if (cur[depth].pos() > from)
cur[depth].pos() = min(from + 1, 
old.lastpos());
need_anchor_change = true;
@@ -929,7 +934,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
return true;
}
 
-   if (oldpar.stripLeadingSpaces(cur.buffer()->params().track_changes)) {
+   if (oldpar.stripLeadingSpaces(trackChanges)) {
need_anchor_change = true;
// We return true here because the Paragraph contents changed 
and
// we need a redraw before further action is processed.
@@ -973,7 +978,8 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, 
pit_type last, bool tra
--num_spaces;
 
// Remove spaces if needed
-   deleteSpaces(par, from , to, num_spaces, trackChanges);
+   int const deleted = deleteSpaces(par, from , to, 
num_spaces, trackChanges);
+   from = to - deleted;
}
 
// don't delete anything if this is the only remaining paragraph


[LyX/master] Fix algorithm for finding localized files

2019-02-06 Thread Jean-Marc Lasgouttes
commit e203bf519b4dd69f17a2f8cabb6607d2f73dce71
Author: Jean-Marc Lasgouttes 
Date:   Wed Feb 6 15:49:53 2019 +0100

Fix algorithm for finding localized files

Now we search in priority with the GUI language, and then the
language(s) specified in the LANGUAGES environment variable.
Preoviously, the GUI language would only be considered when
LANGUAGES was not set (which was a bug).

Take this opportunity to remove old compatibility code from 2007.
---
 src/support/filetools.cpp |   35 +--
 1 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp
index 028eedf..7a2739b 100644
--- a/src/support/filetools.cpp
+++ b/src/support/filetools.cpp
@@ -356,25 +356,20 @@ FileName const libFileSearch(string const & dir, string 
const & name,
 FileName const i18nLibFileSearch(string const & dir, string const & name,
  string const & ext)
 {
-   /* The highest priority value is the `LANGUAGE' environment
-  variable. But we don't use the value if the currently
-  selected locale is the C locale. This is a GNU extension.
-
-  Otherwise, w use a trick to guess what support/gettext.has done:
-  each po file is able to tell us its name. (JMarc)
-   */
-
+   // if the LANGUAGE variable is set, use it as a fallback for searching 
for files.
string lang = getGuiMessages().language();
string const language = getEnv("LANGUAGE");
-   if (!lang.empty() && !language.empty())
-   lang = language;
+   if (!language.empty())
+   lang += ":" + language;
 
-   string l;
-   lang = split(lang, l, ':');
-   while (!l.empty()) {
+   for (auto const & l : getVectorFromString(lang, ":")) {
FileName tmp;
// First try with the full name
-   tmp = libFileSearch(addPath(dir, l), name, ext);
+   // `en' files are not in a subdirectory
+   if (l == "en")
+   tmp = libFileSearch(dir, name, ext);
+   else
+   tmp = libFileSearch(addPath(dir, l), name, ext);
if (!tmp.empty())
return tmp;
 
@@ -385,18 +380,6 @@ FileName const i18nLibFileSearch(string const & dir, 
string const & name,
if (!tmp.empty())
return tmp;
}
-
-#if 1
-   // For compatibility, to be removed later (JMarc)
-   tmp = libFileSearch(dir, token(l, '_', 0) + '_' + name,
-   ext);
-   if (!tmp.empty()) {
-   lyxerr << "i18nLibFileSearch: File `" << tmp
-  << "' has been found by the old method" <

[LyX/2.3.x] Fix algorithm for finding localized files

2019-02-07 Thread Jean-Marc Lasgouttes
commit 4c18a49c879518f763985b6171fe5f4491d0f019
Author: Jean-Marc Lasgouttes 
Date:   Wed Feb 6 15:49:53 2019 +0100

Fix algorithm for finding localized files

Now we search in priority with the GUI language, and then the
language(s) specified in the LANGUAGES environment variable.
Preoviously, the GUI language would only be considered when
LANGUAGES was not set (which was a bug).

Take this opportunity to remove old compatibility code from 2007.

(cherry picked from commit e203bf519b4dd69f17a2f8cabb6607d2f73dce71)
---
 src/support/filetools.cpp |   35 +--
 status.23x|3 +++
 2 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp
index 37fd14f..c91e5c4 100644
--- a/src/support/filetools.cpp
+++ b/src/support/filetools.cpp
@@ -357,25 +357,20 @@ FileName const libFileSearch(string const & dir, string 
const & name,
 FileName const i18nLibFileSearch(string const & dir, string const & name,
  string const & ext)
 {
-   /* The highest priority value is the `LANGUAGE' environment
-  variable. But we don't use the value if the currently
-  selected locale is the C locale. This is a GNU extension.
-
-  Otherwise, w use a trick to guess what support/gettext.has done:
-  each po file is able to tell us its name. (JMarc)
-   */
-
+   // if the LANGUAGE variable is set, use it as a fallback for searching 
for files.
string lang = getGuiMessages().language();
string const language = getEnv("LANGUAGE");
-   if (!lang.empty() && !language.empty())
-   lang = language;
+   if (!language.empty())
+   lang += ":" + language;
 
-   string l;
-   lang = split(lang, l, ':');
-   while (!l.empty()) {
+   for (auto const & l : getVectorFromString(lang, ":")) {
FileName tmp;
// First try with the full name
-   tmp = libFileSearch(addPath(dir, l), name, ext);
+   // `en' files are not in a subdirectory
+   if (l == "en")
+   tmp = libFileSearch(dir, name, ext);
+   else
+   tmp = libFileSearch(addPath(dir, l), name, ext);
if (!tmp.empty())
return tmp;
 
@@ -386,18 +381,6 @@ FileName const i18nLibFileSearch(string const & dir, 
string const & name,
if (!tmp.empty())
return tmp;
}
-
-#if 1
-   // For compatibility, to be removed later (JMarc)
-   tmp = libFileSearch(dir, token(l, '_', 0) + '_' + name,
-   ext);
-   if (!tmp.empty()) {
-   lyxerr << "i18nLibFileSearch: File `" << tmp
-  << "' has been found by the old method" <

[LyX/master] Fix Visual C++ warnning

2019-02-11 Thread Jean-Marc Lasgouttes
commit 2215f4c2b43f9c282f35984182dcd958c8a27ced
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 11 10:43:59 2019 +0100

Fix Visual C++ warnning
---
 src/RowPainter.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 9534b20..a060874 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -553,9 +553,9 @@ void RowPainter::paintLast() const
}
 
if (endlabel == END_LABEL_BOX)
-   pi_.pain.rectangle(xo_ + x, y, size, size, 
font.realColor());
+   pi_.pain.rectangle(int(xo_) + x, y, size, size, 
font.realColor());
else
-   pi_.pain.fillRectangle(xo_ + x, y, size, size, 
font.realColor());
+   pi_.pain.fillRectangle(int(xo_) + x, y, size, size, 
font.realColor());
break;
}
 


[LyX/2.3.x] Fix Visual C++ warning

2019-02-11 Thread Jean-Marc Lasgouttes
commit 96ef3d320b66e7daa73d88de548b1bb617cdc1cd
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 11 10:43:59 2019 +0100

Fix Visual C++ warning

(cherry picked from commit 2215f4c2b43f9c282f35984182dcd958c8a27ced)
---
 src/RowPainter.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 93ac63d..f27eae6 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -525,9 +525,9 @@ void RowPainter::paintLast() const
}
 
if (endlabel == END_LABEL_BOX)
-   pi_.pain.rectangle(xo_ + x, y, size, size, 
Color_eolmarker);
+   pi_.pain.rectangle(int(xo_) + x, y, size, size, 
Color_eolmarker);
else
-   pi_.pain.fillRectangle(xo_ + x, y, size, size, 
Color_eolmarker);
+   pi_.pain.fillRectangle(int(xo_) + x, y, size, size, 
Color_eolmarker);
break;
}
 


[LyX/2.3.x] Fix position of cursor when DEPM is used in change tracking mode

2019-02-15 Thread Jean-Marc Lasgouttes
commit 484128d05b95a014b4511bff891bf90c17f69d72
Author: Jean-Marc Lasgouttes 
Date:   Tue Jan 29 10:55:12 2019 +0100

Fix position of cursor when DEPM is used in change tracking mode

When change tracking is active, it may happen that spaces are marked
as deleted instead of being removed. Therefore it is better to measure
the change of size of the paragraph to know how to offset the cursor.

Moreover, it the cursor was strictly after the start of the sequence
of spaces, we ensure that it is still the case.

This commit is _not_ a backport from master, which has diverged.

Part of bug #11412/
---
 src/Text2.cpp |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index 34fe1ca..e73d1cc 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -789,7 +789,7 @@ namespace {
 // fix the cursor `cur' after characters has been deleted at `where'
 // position. Called by deleteEmptyParagraphMechanism
 void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where,
- pos_type from, pos_type to)
+  pos_type from, int num_chars)
 {
// Do nothing if cursor is not in the paragraph where the
// deletion occurred,
@@ -798,7 +798,7 @@ void fixCursorAfterDelete(CursorSlice & cur, CursorSlice 
const & where,
 
// If cursor position is after the deletion place update it
if (cur.pos() > from)
-   cur.pos() = max(from, cur.pos() - (to - from));
+   cur.pos() = max(from + 1, cur.pos() - num_chars);
 
// Check also if we don't want to set the cursor on a spot behind the
// pagragraph because we erased the last character.
@@ -874,6 +874,10 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
// Remove spaces and adapt cursor.
if (from < to) {
+   // we need to remember what the size was because
+   // eraseChars might mark spaces as deleted instead of
+   // removing them.
+   int const oldsize = oldpar.size();
oldpar.eraseChars(from, to, 
cur.buffer()->params().track_changes);
 // FIXME: This will not work anymore when we have multiple views of the same 
buffer
 // In this case, we will have to correct also the cursors held by
@@ -881,7 +885,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 // automated way in CursorSlice code. (JMarc 26/09/2001)
// correct all cursor parts
if (same_par) {
-   fixCursorAfterDelete(cur[depth], old.top(), 
from, to);
+   fixCursorAfterDelete(cur[depth], old.top(), 
from, oldsize - oldpar.size());
need_anchor_change = true;
}
return true;


[LyX/2.3.x] Fix DEPM at end of paragraph

2019-02-15 Thread Jean-Marc Lasgouttes
commit c44dc071a5658380a1d6bdfcb6f138b70c17d2a5
Author: Jean-Marc Lasgouttes 
Date:   Wed Jan 30 23:50:53 2019 +0100

Fix DEPM at end of paragraph

Remove special handling of spaces at end of paragraph. Now they are
handled like interword spaces by both DEPM methods.

Fix off-by-one error in loop when testing for end of paragraph.

Part of bug #11412.

(adapted from commit c00234503f9e07795723222e6095c022e45ad1dd)
---
 src/Text2.cpp |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index bcd38f4..34fe1ca 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -860,13 +860,13 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
   && !oldpar.isDeleted(from - 1))
--from;
int to = old.pos();
-   while (to < oldpar.size() - 1
+   while (to < oldpar.size()
   && oldpar.isLineSeparator(to)
   && !oldpar.isDeleted(to))
++to;
 
-   // If we are not at the extremity of the paragraph, keep one 
space
-   if (from != to && from > 0 && to < oldpar.size())
+   // If we are not at the start of the paragraph, keep one space
+   if (from != to && from > 0)
++from;
 
if (same_par && cur.pos() >= from && cur.pos() < to)


[LyX/2.3.x] Improve DEPM when change tracking is on

2019-02-15 Thread Jean-Marc Lasgouttes
commit 7f177d8d4a88d84142bdd2939d4c65abe4b50a11
Author: Jean-Marc Lasgouttes 
Date:   Tue Jan 29 11:20:22 2019 +0100

Improve DEPM when change tracking is on

A typical problem when change tracking is on is:
1/ insert a new space between two words (as if you want to insert a new one)
2/ move the cursor
3/ see how one has one inserted and one deleted space, whereas one would 
expect nothing.

The problem is fixed in a general way in master, but here we propose
a simpler one, where the spaces that we keep are the ones at the end
of the sequence of spaces.

Part of #11412.
---
 src/Text2.cpp |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index e73d1cc..ce52598 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -866,11 +866,12 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
++to;
 
// If we are not at the start of the paragraph, keep one space
-   if (from != to && from > 0)
-   ++from;
-
-   if (same_par && cur.pos() >= from && cur.pos() < to)
-   ++from;
+   if (from != to && from > 0) {
+   --to;
+   // if the new cursor is inside the sequence of spaces, 
keep one more space
+   if (same_par && cur.pos() > from && cur.pos() <= to)
+   --to;
+   }
 
// Remove spaces and adapt cursor.
if (from < to) {


[LyX/master] Initialize member

2019-02-18 Thread Jean-Marc Lasgouttes
commit c521e3e1de960ba3c45c0e83d04d86f5e7c68d58
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 18 15:10:05 2019 +0100

Initialize member

Spotted by coverity
---
 src/insets/InsetLayout.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index acef3d1..5d9427d 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -44,7 +44,8 @@ InsetLayout::InsetLayout() :
freespacing_(false), keepempty_(false), forceltr_(false),
forceownlines_(false), needprotect_(false), needcprotect_(false),
intoc_(false), spellcheck_(true), resetsfont_(false), display_(true),
-   forcelocalfontswitch_(false), add_to_toc_(false), is_toc_caption_(false)
+   forcelocalfontswitch_(false), add_to_toc_(false), 
is_toc_caption_(false),
+   edit_external_(false)
 {
labelfont_.setColor(Color_error);
 }


[LyX/master] DEPM: allow to delete empty paragraphs after deleting extra spaces

2019-02-18 Thread Jean-Marc Lasgouttes
commit 386a347484669d9b498699c7cc42be400ad8ba81
Author: Jean-Marc Lasgouttes 
Date:   Fri Feb 15 16:23:46 2019 +0100

DEPM: allow to delete empty paragraphs after deleting extra spaces

Remove return statement when spaces have been deleted.

Add an early return in part 2 when current paragraph is not empty.

Remove some comments that concern things that are OK now.
---
 src/Text2.cpp |   75 +---
 1 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index b5c341c..b917dba 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -818,6 +818,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
Paragraph & oldpar = old.paragraph();
bool const trackChanges = cur.buffer()->params().track_changes;
+   bool result = false;
 
// We do nothing if cursor did not move
if (cur.top() == old.top())
@@ -842,8 +843,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 * them, but only if the cursor has really moved.
 */
 
-   /* Ok I'll put some comments here about what is missing.
-  There are still some small problems that can lead to
+   /* There are still some small problems that can lead to
   double spaces stored in the document file or space at
   the beginning of paragraphs(). This happens if you have
   the cursor between two spaces and then save. Or if you
@@ -851,14 +851,6 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
   beginning and then save right after the paste. (Lgb)
*/
 
-   // If old.pos() == 0 and old.pos()(1) == LineSeparator
-   // delete the LineSeparator.
-   // MISSING
-
-   // If old.pos() == 1 and old.pos()(0) == LineSeparator
-   // delete the LineSeparator.
-   // MISSING
-
// find range of spaces around cursors
pos_type from = old.pos();
while (from > 0
@@ -894,7 +886,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
cur[depth].pos() = min(from + 1, old.lastpos());
need_anchor_change = true;
}
-   return true;
+   result = true;
}
 
/*
@@ -903,45 +895,46 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
// only do our other magic if we changed paragraph
if (same_par)
-   return false;
+   return result;
+
+   // only do our magic if the paragraph is empty
+   if (!oldpar.empty())
+   return result;
 
// don't delete anything if this is the ONLY paragraph!
if (old.lastpit() == 0)
-   return false;
+   return result;
 
// Do not delete empty paragraphs with keepempty set.
if (oldpar.allowEmpty())
-   return false;
-
-   if (oldpar.empty() || (oldpar.size() == 1 && 
oldpar.isLineSeparator(0))) {
-   // Delete old par.
-   old.recordUndo(max(old.pit() - 1, pit_type(0)),
-  min(old.pit() + 1, old.lastpit()));
-   ParagraphList & plist = old.text()->paragraphs();
-   bool const soa = oldpar.params().startOfAppendix();
-   plist.erase(lyx::next(plist.begin(), old.pit()));
-   // do not lose start of appendix marker (bug 4212)
-   if (soa && old.pit() < pit_type(plist.size()))
-   plist[old.pit()].params().startOfAppendix(true);
-
-   // see #warning (FIXME?) above
-   if (cur.depth() >= old.depth()) {
-   CursorSlice & curslice = cur[old.depth() - 1];
-   if (&curslice.inset() == &old.inset()
-   && curslice.pit() > old.pit()) {
-   --curslice.pit();
-   // since a paragraph has been deleted, all the
-   // insets after `old' have been copied and
-   // their address has changed. Therefore we
-   // need to `regenerate' cur. (JMarc)
-   cur.updateInsets(&(cur.bottom().inset()));
-   need_anchor_change = true;
-   }
+   return result;
+
+   // Delete old par.
+   old.recordUndo(max(old.pit() - 1, pit_type(0)),
+  min(old.pit() + 1, old.lastpit()));
+   ParagraphList & plist = old.text()->paragraphs();
+   bool const soa = oldpar.params().startOfAppendix();
+   plist.erase(lyx::next(plist.begin(), old.pit()));
+   // do not lose start of appendix marker (bug 4212)
+   if (soa && old.pit() < pit_type(plist.size()))
+   pl

[LyX/master] DEPM: handle undo when deleting spaces

2019-02-18 Thread Jean-Marc Lasgouttes
commit 2dc62d0405e1ea1722cee933e02e528bea5e0f8e
Author: Jean-Marc Lasgouttes 
Date:   Fri Feb 15 15:33:23 2019 +0100

DEPM: handle undo when deleting spaces

Also, do not do any DEPM when the buffer is read-only.
---
 src/Text.h|4 ++--
 src/Text2.cpp |5 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/Text.h b/src/Text.h
index 054b6f6..a177a83 100644
--- a/src/Text.h
+++ b/src/Text.h
@@ -301,13 +301,13 @@ public:
 
/// delete double spaces, leading spaces, and empty paragraphs around 
old cursor.
/// \retval true if a change has happened and we need a redraw.
-   /// FIXME: replace Cursor with DocIterator. This is not possible right
-   /// now because recordUndo() is called which needs a Cursor.
+   /// Handles undo.
static bool deleteEmptyParagraphMechanism(Cursor & cur,
Cursor & old, bool & need_anchor_change);
 
/// delete double spaces, leading spaces, and empty paragraphs
/// from \first to \last paragraph
+   /// Does NOT handle undo (responsibility of the caller)
void deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool 
trackChanges);
 
/// To resolve macros properly the texts get their DocIterator.
diff --git a/src/Text2.cpp b/src/Text2.cpp
index 6ce41a6..d70dfc1 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -819,6 +819,10 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
Paragraph & oldpar = old.paragraph();
bool const trackChanges = cur.buffer()->params().track_changes;
 
+   // We do not do anything on read-only documents
+   if (cur.buffer()->isReadonly())
+   return false;
+
// We allow all kinds of "mumbo-jumbo" when freespacing.
if (oldpar.isFreeSpacing())
return false;
@@ -879,6 +883,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
// Remove spaces and adapt cursor.
if (num_spaces > 0) {
+   old.recordUndo();
int const deleted =
deleteSpaces(oldpar, from, to, num_spaces, 
trackChanges);
// correct cur position


[LyX/master] DEPM: do not strip explicitly leading spaces

2019-02-18 Thread Jean-Marc Lasgouttes
commit aaab1ad65d38c1ddaf68dfd1c4891ded26013ae0
Author: Jean-Marc Lasgouttes 
Date:   Fri Feb 15 16:07:00 2019 +0100

DEPM: do not strip explicitly leading spaces

For the local version of DEPM, only what was around old cursor should change

For the global version, leading spaces are already handled.
---
 src/Text2.cpp |9 -
 1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index c7824bb..b5c341c 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -941,13 +941,6 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
return true;
}
 
-   if (oldpar.stripLeadingSpaces(trackChanges)) {
-   need_anchor_change = true;
-   // We return true here because the Paragraph contents changed 
and
-   // we need a redraw before further action is processed.
-   return true;
-   }
-
return false;
 }
 
@@ -1005,8 +998,6 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, 
pit_type last, bool tra
--last;
continue;
}
-
-   par.stripLeadingSpaces(trackChanges);
}
 }
 


[LyX/master] Do a round of DEPM after changing layout

2019-02-18 Thread Jean-Marc Lasgouttes
commit 26ad2c6a67239b328266b355132664666a8af728
Author: Jean-Marc Lasgouttes 
Date:   Fri Feb 15 17:17:56 2019 +0100

Do a round of DEPM after changing layout
---
 src/Text2.cpp |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index b917dba..f1decc5 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -186,6 +186,8 @@ void Text::setLayout(pit_type start, pit_type end,
if (lyxlayout.margintype == MARGIN_MANUAL)
par.setLabelWidthString(par.expandLabel(lyxlayout, bp));
}
+
+   deleteEmptyParagraphMechanism(start, end - 1, bp.track_changes);
 }
 
 
@@ -198,6 +200,7 @@ void Text::setLayout(Cursor & cur, docstring const & layout)
pit_type end = cur.selEnd().pit() + 1;
cur.recordUndoSelection();
setLayout(start, end, layout);
+   cur.fixIfBroken();
cur.setCurrentFont();
cur.forceBufferUpdate();
 }


[LyX/master] DEPM: document that Freespacing implies KeepEmpty.

2019-02-18 Thread Jean-Marc Lasgouttes
commit 6293bdbb5a5d42f3834c10e3a9689bc346550976
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 18 12:42:36 2019 +0100

DEPM: document that Freespacing implies KeepEmpty.
---
 lib/doc/Customization.lyx |   57 +---
 1 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index 1fefdd5..8d045ae 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 565
+\lyxformat 566
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -130,6 +130,7 @@ logicalmkup
 \html_css_as_file 0
 \html_be_strict true
 \author -712698321 "Jürgen Spitzmüller"
+\author -495245474 "Jean-Marc Lasgouttes"
 \author 731793113 "Richard Kimberly Heck" rikih...@lyx.org
 \end_header
 
@@ -13080,10 +13081,58 @@ FreeSpacing
 \end_inset
 
  can be enabled.
- Note that \SpecialChar LyX
- will create protected blanks for the additional blanks when
- in another mode than \SpecialChar LaTeX
+ 
+\change_deleted -495245474 1550490105
+Note that 
+\change_unchanged
+\SpecialChar LyX
+ will create protected blanks for the additional blanks when in 
+\change_inserted -495245474 1550490096
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1550490089
+Passthru 1
+\end_layout
+
+\end_inset
+
+ is not specified.
+\change_deleted -495245474 1550490116
+another mode than \SpecialChar LaTeX
 -mode.
+
+\change_inserted -495245474 1550247760
+ Note that 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1550247736
+FreeSpacing
+\end_layout
+
+\end_inset
+
+ implies 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1550247755
+KeepEmpty
+\end_layout
+
+\end_inset
+
+.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description


[LyX/master] DEPM: reorganize a bit (no change intended)

2019-02-18 Thread Jean-Marc Lasgouttes
commit b59b968c3eae5cc0d5ea40444f85cd693751c688
Author: Jean-Marc Lasgouttes 
Date:   Fri Feb 15 15:49:53 2019 +0100

DEPM: reorganize a bit (no change intended)

Exit early if the cursor has not moved.

Place comments where they belong.
---
 src/Text2.cpp |  111 ++--
 1 files changed, 59 insertions(+), 52 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index d70dfc1..e4c0c26 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -819,6 +819,10 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
Paragraph & oldpar = old.paragraph();
bool const trackChanges = cur.buffer()->params().track_changes;
 
+   // We do nothing if cursor did not move
+   if (cur.top() == old.top())
+   return false;
+
// We do not do anything on read-only documents
if (cur.buffer()->isReadonly())
return false;
@@ -827,6 +831,22 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
if (oldpar.isFreeSpacing())
return false;
 
+   // Find a common inset and the corresponding depth.
+   size_t depth = 0;
+   for (; depth < cur.depth(); ++depth)
+   if (&old.inset() == &cur[depth].inset())
+   break;
+
+   // Whether a common inset is found and whether the cursor is still in
+   // the same paragraph (possibly nested).
+   bool const same_par = depth < cur.depth() && old.idx() == 
cur[depth].idx()
+   && old.pit() == cur[depth].pit();
+
+   /*
+* (1) If the chars around the old cursor were spaces, delete some of
+* them, but only if the cursor has really moved.
+*/
+
/* Ok I'll put some comments here about what is missing.
   There are still some small problems that can lead to
   double spaces stored in the document file or space at
@@ -844,61 +864,48 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
// delete the LineSeparator.
// MISSING
 
-   // Find a common inset and the corresponding depth.
-   size_t depth = 0;
-   for (; depth < cur.depth(); ++depth)
-   if (&old.inset() == &cur[depth].inset())
-   break;
-
-   // Whether a common inset is found and whether the cursor is still in
-   // the same paragraph (possibly nested).
-   bool const same_par = depth < cur.depth() && old.idx() == 
cur[depth].idx()
-   && old.pit() == cur[depth].pit();
-   bool const same_par_pos = depth == cur.depth() - 1 && same_par
-   && old.pos() == cur[depth].pos();
-
-   // If the chars around the old cursor were spaces, delete some of
-   // them, but only if the cursor has really moved.
-   if (!same_par_pos) {
-   // find range of spaces around cursors
-   pos_type from = old.pos();
-   while (from > 0
-  && oldpar.isLineSeparator(from - 1)
-  && !oldpar.isDeleted(from - 1))
-   --from;
-   pos_type to = old.pos();
-   while (to < old.lastpos()
-  && oldpar.isLineSeparator(to)
-  && !oldpar.isDeleted(to))
-   ++to;
-
-   int num_spaces = to - from;
-   // If we are not at the start of the paragraph, keep one space
-   if (from != to && from > 0)
-   --num_spaces;
-
-   // If cursor is inside range, keep one additional space
-   if (same_par && cur.pos() > from && cur.pos() < to)
-   --num_spaces;
-
-   // Remove spaces and adapt cursor.
-   if (num_spaces > 0) {
-   old.recordUndo();
-   int const deleted =
-   deleteSpaces(oldpar, from, to, num_spaces, 
trackChanges);
-   // correct cur position
-   // FIXME: there can be other cursors pointing there, we 
should update them
-   if (same_par) {
-   if (cur[depth].pos() >= to)
-   cur[depth].pos() -= deleted;
-   else if (cur[depth].pos() > from)
-   cur[depth].pos() = min(from + 1, 
old.lastpos());
-   need_anchor_change = true;
-   }
-   return true;
+   // find range of spaces around cursors
+   pos_type from = old.pos();
+   while (from > 0
+  && oldpar.isLineSeparator(from - 1)
+  && !oldpar.isDeleted(from - 1))
+  

[LyX/master] DEPM: replace loop by existing method

2019-02-18 Thread Jean-Marc Lasgouttes
commit 1f1a1b0dc7fa31ef167bedd8f00c0e83ae56717e
Author: Jean-Marc Lasgouttes 
Date:   Fri Feb 15 16:02:49 2019 +0100

DEPM: replace loop by existing method
---
 src/Text2.cpp |9 ++---
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index e4c0c26..c7824bb 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -831,15 +831,10 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
if (oldpar.isFreeSpacing())
return false;
 
-   // Find a common inset and the corresponding depth.
-   size_t depth = 0;
-   for (; depth < cur.depth(); ++depth)
-   if (&old.inset() == &cur[depth].inset())
-   break;
-
// Whether a common inset is found and whether the cursor is still in
// the same paragraph (possibly nested).
-   bool const same_par = depth < cur.depth() && old.idx() == 
cur[depth].idx()
+   int const depth = cur.find(&old.inset());
+   bool const same_par = depth != -1 && old.idx() == cur[depth].idx()
&& old.pit() == cur[depth].pit();
 
/*


[LyX/master] Rename Row::dimension() to dim()

2019-02-18 Thread Jean-Marc Lasgouttes
commit a04b5c3965faf79d534f0090712d3e47cebc46ab
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 18 15:46:42 2019 +0100

Rename Row::dimension() to dim()

This is what is done elsewhere.
---
 src/BufferView.cpp  |4 ++--
 src/Row.h   |4 ++--
 src/TextMetrics.cpp |   28 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 7edf9e2..35a126b 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -956,7 +956,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, 
bool const recenter)
int offset = coordOffset(dit).y_;
int ypos = pm.position() + offset;
Dimension const & row_dim =
-   pm.getRow(cs.pos(), dit.boundary()).dimension();
+   pm.getRow(cs.pos(), dit.boundary()).dim();
int scrolled = 0;
if (recenter)
scrolled = scroll(ypos - height_/2);
@@ -1000,7 +1000,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, 
bool const recenter)
d->anchor_pit_ = bot_pit;
CursorSlice const & cs = dit.innerTextSlice();
Dimension const & row_dim =
-   pm.getRow(cs.pos(), dit.boundary()).dimension();
+   pm.getRow(cs.pos(), dit.boundary()).dim();
 
if (recenter)
d->anchor_ypos_ = height_/2;
diff --git a/src/Row.h b/src/Row.h
index a42d91d..01c62cf 100644
--- a/src/Row.h
+++ b/src/Row.h
@@ -198,9 +198,9 @@ public:
bool flushed() const { return flushed_; }
 
///
-   Dimension const & dimension() const { return dim_; }
+   Dimension const & dim() const { return dim_; }
///
-   Dimension & dimension() { return dim_; }
+   Dimension & dim() { return dim_; }
///
int height() const { return dim_.height(); }
/// The width of the row, including the left margin, but not the right 
one.
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index edc9f69..89f8d92 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -512,7 +512,7 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool 
const align_rows)
// original value was 20px, which is 0.2in at 100dpi
int const margin = bv_->zoomedPixels(20);
if (pit == 0) {
-   pm.rows().front().dimension().asc += margin;
+   pm.rows().front().dim().asc += margin;
/* coverity thinks that we should update pm.dim().asc
 * below, but all the rows heights are actually counted 
as
 * part of the paragraph metric descent see loop above).
@@ -522,16 +522,16 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool 
const align_rows)
}
ParagraphList const & pars = text_->paragraphs();
if (pit + 1 == pit_type(pars.size())) {
-   pm.rows().back().dimension().des += margin;
+   pm.rows().back().dim().des += margin;
pm.dim().des += margin;
}
}
 
// The space above and below the paragraph.
int const top = parTopSpacing(pit);
-   pm.rows().front().dimension().asc += top;
+   pm.rows().front().dim().asc += top;
int const bottom = parBottomSpacing(pit);
-   pm.rows().back().dimension().des += bottom;
+   pm.rows().back().dim().des += bottom;
pm.dim().des += top + bottom;
 
pm.dim().asc += pm.rows()[0].ascent();
@@ -654,28 +654,28 @@ void TextMetrics::setRowAlignment(Row & row, int width) 
const
if (!row.setExtraWidth(w) && row.isRTL()) {
// Justification failed and the text is RTL: 
align to the right
row.left_margin += w;
-   row.dimension().wid += w;
+   row.dim().wid += w;
}
break;
case LYX_ALIGN_LEFT:
// a displayed inset that is flushed
if (Inset const * inset = par.getInset(row.pos())) {
row.left_margin += inset->indent(*bv_);
-   row.dimension().wid += inset->indent(*bv_);
+   row.dim().wid += inset->indent(*bv_);
}
break;
case LYX_ALIGN_RIGHT:
if (Inset const * inset = par.getInset(row.pos())) {
int const new_w = max(w - inset->indent(*bv_), 
0);
row.left_margin += new_w;
-   row.dimension().wid += new_w;
+ 

[LyX/master] Let tm be a reference here as elsewhere

2019-02-18 Thread Jean-Marc Lasgouttes
commit 10e2c658351c237d3b35566857a533a9d08f7f65
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 18 15:41:00 2019 +0100

Let tm be a reference here as elsewhere
---
 src/Text3.cpp |   24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/Text3.cpp b/src/Text3.cpp
index 6db9c2b..b78c8d1 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -639,10 +639,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
}
 
BufferView * bv = &cur.bv();
-   TextMetrics * tm = &bv->textMetrics(this);
-   if (!tm->contains(cur.pit())) {
+   TextMetrics & tm = bv->textMetrics(this);
+   if (!tm.contains(cur.pit())) {
lyx::dispatch(FuncRequest(LFUN_SCREEN_SHOW_CURSOR));
-   tm = &bv->textMetrics(this);
+   tm = bv->textMetrics(this);
}
 
// FIXME: We use the update flag to indicates wether a singlePar or a
@@ -735,7 +735,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
if (cur.selection())
cutSelection(cur, false);
else
-   tm->deleteLineForward(cur);
+   tm.deleteLineForward(cur);
finishChange(cur, false);
break;
 
@@ -941,13 +941,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_LINE_BEGIN:
case LFUN_LINE_BEGIN_SELECT:
needsUpdate |= cur.selHandle(cmd.action() == 
LFUN_LINE_BEGIN_SELECT);
-   needsUpdate |= tm->cursorHome(cur);
+   needsUpdate |= tm.cursorHome(cur);
break;
 
case LFUN_LINE_END:
case LFUN_LINE_END_SELECT:
needsUpdate |= cur.selHandle(cmd.action() == 
LFUN_LINE_END_SELECT);
-   needsUpdate |= tm->cursorEnd(cur);
+   needsUpdate |= tm.cursorEnd(cur);
break;
 
case LFUN_SECTION_SELECT: {
@@ -1530,8 +1530,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
case LFUN_SERVER_GET_XY:
cur.message(from_utf8(
-   convert(tm->cursorX(cur.top(), cur.boundary()))
-   + ' ' + convert(tm->cursorY(cur.top(), 
cur.boundary();
+   convert(tm.cursorX(cur.top(), cur.boundary()))
+   + ' ' + convert(tm.cursorY(cur.top(), 
cur.boundary();
break;
 
case LFUN_SERVER_SET_XY: {
@@ -1543,7 +1543,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
lyxerr << "SETXY: Could not parse coordinates in '"
   << to_utf8(cmd.argument()) << endl;
else
-   tm->setCursorFromCoordinates(cur, x, y);
+   tm.setCursorFromCoordinates(cur, x, y);
break;
}
 
@@ -1761,9 +1761,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
case LFUN_MOUSE_TRIPLE:
if (cmd.button() == mouse_button::button1) {
-   tm->cursorHome(cur);
+   tm.cursorHome(cur);
cur.resetAnchor();
-   tm->cursorEnd(cur);
+   tm.cursorEnd(cur);
cur.setSelection();
bv->cursor() = cur;
}
@@ -1838,7 +1838,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
int const wh = bv->workHeight();
int const y = max(0, min(wh - 1, cmd.y()));
 
-   tm->setCursorFromCoordinates(cur, cmd.x(), y);
+   tm.setCursorFromCoordinates(cur, cmd.x(), y);
cur.setTargetX(cmd.x());
// Don't allow selecting a separator inset
if (cur.pos() && cur.paragraph().isEnvSeparator(cur.pos() - 1))


[LyX/master] Remove unused method

2019-02-18 Thread Jean-Marc Lasgouttes
commit 4c90183e4d476730ea297438782cf0d8f47dc149
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 18 16:03:38 2019 +0100

Remove unused method
---
 src/insets/RenderBase.h |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/insets/RenderBase.h b/src/insets/RenderBase.h
index cc1973e..4fb3f84 100644
--- a/src/insets/RenderBase.h
+++ b/src/insets/RenderBase.h
@@ -37,8 +37,6 @@ public:
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
/// draw inset and update (xo, yo)-cache
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
-   ///
-   Dimension const & dimension() const { return dim_; }
 
/// render state, exact meaning of state is render-specific
void setRenderState(bool state) { state_ = state; }


[LyX/master] Do not use trailing underscore for local variable

2019-02-18 Thread Jean-Marc Lasgouttes
commit 91fc45ed359413432190a4a323fd7ca73e0238b6
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 18 16:04:15 2019 +0100

Do not use trailing underscore for local variable
---
 src/frontends/qt4/GuiApplication.cpp |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 3a5fd12..28b4da4 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -2920,13 +2920,13 @@ void GuiApplication::hideDialogs(string const & name, 
Inset * inset) const
 
 Buffer const * GuiApplication::updateInset(Inset const * inset) const
 {
-   Buffer const * buffer_ = 0;
+   Buffer const * buf = 0;
QHash::const_iterator end = d->views_.end();
for (QHash::iterator it = d->views_.begin(); it != end; 
++it) {
if (Buffer const * ptr = (*it)->updateInset(inset))
-   buffer_ = ptr;
+   buf = ptr;
}
-   return buffer_;
+   return buf;
 }
 
 


[LyX/master] Rename TextMetrics::dimension() to dim()

2019-02-19 Thread Jean-Marc Lasgouttes
commit 2ae51b947b061dab057aae3c7d43ed5cdc11bd79
Author: Jean-Marc Lasgouttes 
Date:   Tue Feb 19 18:04:43 2019 +0100

Rename TextMetrics::dimension() to dim()
---
 src/TextMetrics.h|2 +-
 src/insets/InsetText.cpp |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/TextMetrics.h b/src/TextMetrics.h
index a4a1e23..1a3ce0e 100644
--- a/src/TextMetrics.h
+++ b/src/TextMetrics.h
@@ -49,7 +49,7 @@ public:
std::pair last() const;
 
///
-   Dimension const & dimension() const { return dim_; }
+   Dimension const & dim() const { return dim_; }
///
Point const & origin() const { return origin_; }
 
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 107753e..de6da62 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -140,7 +140,7 @@ void InsetText::clear()
 Dimension const InsetText::dimensionHelper(BufferView const & bv) const
 {
TextMetrics const & tm = bv.textMetrics(&text_);
-   Dimension dim = tm.dimension();
+   Dimension dim = tm.dim();
dim.wid += 2 * TEXT_TO_INSET_OFFSET;
dim.des += TEXT_TO_INSET_OFFSET;
dim.asc += TEXT_TO_INSET_OFFSET;


[LyX/master] Honor Update::SinglePar properly

2019-02-20 Thread Jean-Marc Lasgouttes
commit 9bdc0dab31337fd6788d587127842eb3558881ae
Author: Jean-Marc Lasgouttes 
Date:   Wed Feb 20 12:01:44 2019 +0100

Honor Update::SinglePar properly

The SinglePar update flags has been a no-op for a long time without
naybody noticing. This means that the current paragraph was
always rebroken and redrawn, even when only moving the cursor around.

Now we only do that when Update::SinglePar has been specified. This
means that there may be cases where update will not be correct
anymore, because this flag has not been specified. These places will
have to be found and fixed.

Update PAINTING_ANALYSIS.
---
 development/PAINTING_ANALYSIS |   28 
 src/BufferView.cpp|   18 ++
 2 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/development/PAINTING_ANALYSIS b/development/PAINTING_ANALYSIS
index 32bc93a..a52a036 100644
--- a/development/PAINTING_ANALYSIS
+++ b/development/PAINTING_ANALYSIS
@@ -20,15 +20,9 @@ following section. Some actions are proposed.
 
 ** SinglePar update
 
-The flag Update::SinglePar is set in many places but never acted on.
-Instead, metrics update is skipped whenever the recorded height of
-current paragraph did not change and Update::Force was not specified.
-Is it better to keep that (which incurs extra work) or to condition it
-on Update::SinglePar? If the first solution is kept, the flag
-SingleParUpdate shall be removed.
-
-Moreover, I fail to see (yet) where the 'single' part of the program
-is acted on.
+This flag only has an effect in the current BufferView, but I think it
+is useful in other views too. Doing this will require some work on the
+update pipeline, though.
 
 ** Buffer::change issues
 
@@ -40,6 +34,7 @@ a good value? NoScreenUpdate?
 On a related note, what is the semantics of a call to
 Buffer::changed(false)? What does the caller mean?
 
+
 ** How to avoid redraw with FitCursor when the cursor is already OK?
 
 In this case, we invoke Buffer::change(false) with drawing disabled
@@ -60,12 +55,6 @@ cursor.
 
 * Clean-up of drawing code
 
-** Make SinglePar update flag useful again. 
-
-The current code can be very expensive when moving cursor inside a
-huge table, for example. We should test the flag again, although this
-will probably lead to some glitches here and there.
-
 ** Set Row::changed() in a finer way
 
 *** singleParUpdate
@@ -139,15 +128,14 @@ DecorationUpdate). It triggers a recomputation of the 
metrics when either:
  + Update::Force has been specified
  + Update::FitCursor has been specified and there is a need to scroll
the display.
- + the current paragraph, after rebreak, does not have the same height as in
-   existing metrics. Note that the Update::SinglePar flag is *never*
-   taken into account.
+ + Update::SinglePar has been specified and the current paragraph has
+   not changed height.
 
 If a computation of metrics has taken place, Force is removed from the
 flags and ForceDraw is added instead.
 
-It is OK to call processUptateFlags several times before an update. In
-this case, the effects are cumulative.processUpdateFlags execute the
+It is OK to call processUpateFlags several times before an update. In
+this case, the effects are cumulative. processUpdateFlags executes the
 metrics-related actions, but defers the actual drawing to the next
 paint event.
 
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 35a126b..a46420e 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -500,11 +500,6 @@ void BufferView::processUpdateFlags(Update::flags flags)
 */
buffer_.updateMacros();
 
-   // SinglePar is ignored for now (this should probably change). We
-   // set it ourselves below, at the price of always rebreaking the
-   // paragraph at cursor. This can be expensive for large tables.
-   flags = flags & ~Update::SinglePar;
-
// First check whether the metrics and inset positions should be updated
if (flags & Update::Force) {
// This will update the CoordCache items and replace Force
@@ -512,15 +507,14 @@ void BufferView::processUpdateFlags(Update::flags flags)
updateMetrics(flags);
}
 
-   // Detect whether we can only repaint a single paragraph.
+   // Detect whether we can only repaint a single paragraph (if we
+   // are not already redrawing all).
// We handle this before FitCursor because the later will require
// correct metrics at cursor position.
-   if (!(flags & Update::ForceDraw)) {
-   if (singleParUpdate())
-   flags = flags | Update::SinglePar;
-   else
+   if (!(flags & Update::ForceDraw)
+   && (flags & Update::SinglePar)
+   && !singleParUpdate())
updateMetrics(flags);
-   }
 
// Then make sure that the screen contains t

[LyX/master] Move some TextMetrics code around.

2019-02-25 Thread Jean-Marc Lasgouttes
commit ab02a907f0de3d638e024dbe65566b85578f12fb
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 25 11:58:50 2019 +0100

Move some TextMetrics code around.

No change intended.
---
 src/TextMetrics.cpp |  100 +-
 src/TextMetrics.h   |   21 +--
 2 files changed, 60 insertions(+), 61 deletions(-)

diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 89f8d92..28d0d87 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -130,13 +130,6 @@ bool TextMetrics::contains(pit_type pit) const
 }
 
 
-ParagraphMetrics const & TextMetrics::parMetrics(pit_type pit) const
-{
-   return const_cast(this)->parMetrics(pit, true);
-}
-
-
-
 pair TextMetrics::first() const
 {
ParMetricsCache::const_iterator it = par_metrics_.begin();
@@ -152,6 +145,20 @@ pair 
TextMetrics::last() const
 }
 
 
+bool TextMetrics::isLastRow(Row const & row) const
+{
+   ParagraphList const & pars = text_->paragraphs();
+   return row.endpos() >= pars[row.pit()].size()
+   && row.pit() + 1 == pit_type(pars.size());
+}
+
+
+bool TextMetrics::isFirstRow(Row const & row) const
+{
+   return row.pos() == 0 && row.pit() == 0;
+}
+
+
 ParagraphMetrics & TextMetrics::parMetrics(pit_type pit, bool redo)
 {
ParMetricsCache::iterator pmc_it = par_metrics_.find(pit);
@@ -165,6 +172,42 @@ ParagraphMetrics & TextMetrics::parMetrics(pit_type pit, 
bool redo)
 }
 
 
+ParagraphMetrics const & TextMetrics::parMetrics(pit_type pit) const
+{
+   return const_cast(this)->parMetrics(pit, true);
+}
+
+
+void TextMetrics::newParMetricsDown()
+{
+   pair const & last = *par_metrics_.rbegin();
+   pit_type const pit = last.first + 1;
+   if (pit == int(text_->paragraphs().size()))
+   return;
+
+   // do it and update its position.
+   redoParagraph(pit);
+   par_metrics_[pit].setPosition(last.second.position()
+   + last.second.descent() + par_metrics_[pit].ascent());
+   updatePosCache(pit);
+}
+
+
+void TextMetrics::newParMetricsUp()
+{
+   pair const & first = *par_metrics_.begin();
+   if (first.first == 0)
+   return;
+
+   pit_type const pit = first.first - 1;
+   // do it and update its position.
+   redoParagraph(pit);
+   par_metrics_[pit].setPosition(first.second.position()
+   - first.second.ascent() - par_metrics_[pit].descent());
+   updatePosCache(pit);
+}
+
+
 bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width,
  bool const expand_on_multipars)
 {
@@ -1204,35 +1247,6 @@ pos_type TextMetrics::x2pos(pit_type pit, int row, int 
x) const
 }
 
 
-void TextMetrics::newParMetricsDown()
-{
-   pair const & last = *par_metrics_.rbegin();
-   pit_type const pit = last.first + 1;
-   if (pit == int(text_->paragraphs().size()))
-   return;
-
-   // do it and update its position.
-   redoParagraph(pit);
-   par_metrics_[pit].setPosition(last.second.position()
-   + last.second.descent() + par_metrics_[pit].ascent());
-   updatePosCache(pit);
-}
-
-
-void TextMetrics::newParMetricsUp()
-{
-   pair const & first = *par_metrics_.begin();
-   if (first.first == 0)
-   return;
-
-   pit_type const pit = first.first - 1;
-   // do it and update its position.
-   redoParagraph(pit);
-   par_metrics_[pit].setPosition(first.second.position()
-   - first.second.ascent() - par_metrics_[pit].descent());
-   updatePosCache(pit);
-}
-
 // y is screen coordinate
 pit_type TextMetrics::getPitNearY(int y)
 {
@@ -1566,20 +1580,6 @@ void TextMetrics::deleteLineForward(Cursor & cur)
 }
 
 
-bool TextMetrics::isLastRow(Row const & row) const
-{
-   ParagraphList const & pars = text_->paragraphs();
-   return row.endpos() >= pars[row.pit()].size()
-   && row.pit() + 1 == pit_type(pars.size());
-}
-
-
-bool TextMetrics::isFirstRow(Row const & row) const
-{
-   return row.pos() == 0 && row.pit() == 0;
-}
-
-
 int TextMetrics::leftMargin(pit_type pit) const
 {
return leftMargin(pit, text_->paragraphs()[pit].size());
diff --git a/src/TextMetrics.h b/src/TextMetrics.h
index 1a3ce0e..ba1371f 100644
--- a/src/TextMetrics.h
+++ b/src/TextMetrics.h
@@ -42,11 +42,13 @@ public:
///
bool contains(pit_type pit) const;
///
-   ParagraphMetrics const & parMetrics(pit_type) const;
-   ///
std::pair first() const;
///
std::pair last() const;
+   /// is this row the last in the text?
+   bool isLastRow(Row const & row) const;
+   /// is this row the first in the text?
+   bool isFirstRow(Row const & row) const;
 
///
Dimension const & dim() const { return dim_; }

[LyX/master] Use range-based loops in BufferList

2019-02-25 Thread Jean-Marc Lasgouttes
commit bc128e7bf897a2fc7ed376eeaffed487068ab33e
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 25 15:14:58 2019 +0100

Use range-based loops in BufferList
---
 src/BufferList.cpp |   83 ++-
 src/BufferList.h   |2 +-
 2 files changed, 30 insertions(+), 55 deletions(-)

diff --git a/src/BufferList.cpp b/src/BufferList.cpp
index 538df77..3865c72 100644
--- a/src/BufferList.cpp
+++ b/src/BufferList.cpp
@@ -51,10 +51,8 @@ BufferList::BufferList()
 
 BufferList::~BufferList()
 {
-   BufferStorage::iterator it = binternal.begin();
-   BufferStorage::iterator end = binternal.end();
-   for (; it != end; ++it)
-   delete (*it);
+   for (Buffer * buf : binternal)
+   delete buf;
 }
 
 
@@ -160,12 +158,8 @@ void BufferList::closeAll()
 FileNameList BufferList::fileNames() const
 {
FileNameList nvec;
-   BufferStorage::const_iterator it = bstore.begin();
-   BufferStorage::const_iterator end = bstore.end();
-   for (; it != end; ++it) {
-   Buffer * buf = *it;
+   for (Buffer const * buf : bstore)
nvec.push_back(buf->fileName());
-   }
return nvec;
 }
 
@@ -231,14 +225,12 @@ void BufferList::updateIncludedTeXfiles(string const & 
masterTmpDir,
 {
OutputParams runparams = runparams_in;
runparams.is_child = true;
-   BufferStorage::iterator it = bstore.begin();
-   BufferStorage::iterator end = bstore.end();
-   for (; it != end; ++it) {
-   if (!(*it)->isDepClean(masterTmpDir)) {
-   string writefile = addName(masterTmpDir, 
(*it)->latexName());
-   (*it)->makeLaTeXFile(FileName(writefile), masterTmpDir,
+   for (Buffer * buf : bstore) {
+   if (!buf->isDepClean(masterTmpDir)) {
+   string writefile = addName(masterTmpDir, 
buf->latexName());
+   buf->makeLaTeXFile(FileName(writefile), masterTmpDir,
 runparams, Buffer::OnlyBody);
-   (*it)->markDepClean(masterTmpDir);
+   buf->markDepClean(masterTmpDir);
}
}
 }
@@ -246,19 +238,15 @@ void BufferList::updateIncludedTeXfiles(string const & 
masterTmpDir,
 
 void BufferList::emergencyWriteAll()
 {
-   BufferStorage::const_iterator it = bstore.begin();
-   BufferStorage::const_iterator const en = bstore.end();
-   for (; it != en; ++it)
-(*it)->emergencyWrite();
+   for (Buffer * buf : bstore)
+buf->emergencyWrite();
 }
 
 
 void BufferList::invalidateConverterCache() const
 {
-   BufferStorage::const_iterator it = bstore.begin();
-   BufferStorage::const_iterator const en = bstore.end();
-   for (; it != en; ++it)
-   (*it)->params().invalidateConverterCache();
+   for (Buffer const * buf : bstore)
+   buf->params().invalidateConverterCache();
 }
 
 
@@ -288,7 +276,7 @@ bool BufferList::isInternal(Buffer const * b) const
 }
 
 
-bool BufferList::isOthersChild(Buffer * parent, Buffer * child)
+bool BufferList::isOthersChild(Buffer * parent, Buffer * child) const
 {
LASSERT(parent, return false);
LASSERT(child, return false);
@@ -299,7 +287,7 @@ bool BufferList::isOthersChild(Buffer * parent, Buffer * 
child)
if (parent_ && parent_ != parent)
return true;
 
-   for(Buffer * buf : bstore)
+   for(Buffer const * buf : bstore)
if (buf != parent && buf->isChild(child))
return true;
return false;
@@ -332,24 +320,19 @@ Buffer * BufferList::getBuffer(support::FileName const & 
fname, bool internal) c
 
 Buffer * BufferList::getBufferFromTmp(string const & s)
 {
-   BufferStorage::iterator it = bstore.begin();
-   BufferStorage::iterator end = bstore.end();
-   for (; it < end; ++it) {
-   if (prefixIs(s, (*it)->temppath())) {
+   for (Buffer * buf : bstore) {
+   if (prefixIs(s, buf->temppath())) {
// check whether the filename matches the master
-   string const master_name = (*it)->latexName();
+   string const master_name = buf->latexName();
if (suffixIs(s, master_name))
-   return *it;
+   return buf;
// if not, try with the children
-   ListOfBuffers clist = (*it)->getDescendents();
-   ListOfBuffers::const_iterator cit = clist.begin();
-   ListOfBuffers::const_iterator cend = clist.end();
-   for (; cit != cend; ++cit) {
+   for (Buffer * child : buf->ge

[LyX/master] Change the way scrolled rows are tracked

2019-02-25 Thread Jean-Marc Lasgouttes
commit 7f0525e9e09459e5bccc8442d889a1aafffa071f
Author: Jean-Marc Lasgouttes 
Date:   Thu Feb 21 17:52:36 2019 +0100

Change the way scrolled rows are tracked

The goal of this commit is to simplify the logic in TextMetrics::draw.
Now, rows are repainted depending on their changed() status.

Instead of checking whether rows have been scrolled horizontally at
draw time, the code marks the row as changed when testing for
horizontal scrolling.

To this end a new method TestMetrics::setRowChanged is added, that
searches a row in the text metrics cache and marks it changed if
found.

The old code that remembered the previously scrolled row can now be
removed.
---
 src/BufferView.cpp  |   34 --
 src/BufferView.h|5 -
 src/TextMetrics.cpp |   24 +++-
 src/TextMetrics.h   |2 ++
 4 files changed, 29 insertions(+), 36 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index a46420e..50df1aa 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -316,9 +316,6 @@ struct BufferView::Private
/// a slice pointing to the start of the row where the cursor
/// is (at last draw time)
CursorSlice current_row_slice_;
-   /// a slice pointing to the start of the row where cursor was
-   /// at previous draw event
-   CursorSlice last_row_slice_;
 
// The vertical size of the blinking caret. Only used for math
// Using it for text could be bad when undo restores the cursor
@@ -3066,30 +3063,24 @@ int BufferView::horizScrollOffset(Text const * text,
 }
 
 
-bool BufferView::hadHorizScrollOffset(Text const * text,
-  pit_type pit, pos_type pos) const
-{
-   return !d->last_row_slice_.empty()
-  && &text->inset() == d->last_row_slice_.inset().asInsetText()
-  && pit ==  d->last_row_slice_.pit()
-  && pos ==  d->last_row_slice_.pos();
-}
-
-
 void BufferView::setCurrentRowSlice(CursorSlice const & rowSlice)
 {
// nothing to do if the cursor was already on this row
-   if (d->current_row_slice_ == rowSlice) {
-   d->last_row_slice_ = CursorSlice();
+   if (d->current_row_slice_ == rowSlice)
return;
-   }
 
// if the (previous) current row was scrolled, we have to
// remember it in order to repaint it next time.
-   if (d->horiz_scroll_offset_ != 0)
-   d->last_row_slice_ = d->current_row_slice_;
-   else
-   d->last_row_slice_ = CursorSlice();
+   if (d->horiz_scroll_offset_ != 0) {
+   // search the old row in cache and mark it changed
+   for (auto & tm_pair : d->text_metrics_) {
+   if (&tm_pair.first->inset() == 
rowSlice.inset().asInsetText()) {
+   tm_pair.second.setRowChanged(rowSlice.pit(), 
rowSlice.pos());
+   // We found it, no need to continue.
+   break;
+   }
+   }
+   }
 
// Since we changed row, the scroll offset is not valid anymore
d->horiz_scroll_offset_ = 0;
@@ -3146,8 +3137,7 @@ void BufferView::checkCursorScrollOffset()
   << d->horiz_scroll_offset_ << " to " << offset);
 
if (d->update_strategy_ == NoScreenUpdate
-   && (offset != d->horiz_scroll_offset_
-   || !d->last_row_slice_.empty())) {
+   && offset != d->horiz_scroll_offset_) {
// FIXME: if one uses SingleParUpdate, then home/end
// will not work on long rows. Why?
d->update_strategy_ = FullScreenUpdate;
diff --git a/src/BufferView.h b/src/BufferView.h
index 2478e60..5bad57c 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -146,11 +146,6 @@ public:
int horizScrollOffset(Text const * text,
  pit_type pit, pos_type pos) const;
 
-   // Returns true if the row of text starting at (pit, pos) was scrolled
-   // at the last draw event.
-   bool hadHorizScrollOffset(Text const * text,
-  pit_type pit, pos_type pos) const;
-
/// reset the scrollbar to reflect current view position.
void updateScrollbar();
/// return the Scrollbar Parameters.
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 28d0d87..88ffa6f 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -159,6 +159,16 @@ bool TextMetrics::isFirstRow(Row const & row) const
 }
 
 
+void TextMetrics::setRowChanged(pit_type pit, pos_type pos)
+{
+   for (auto & pm_pair : par_metrics_)
+   if (pm_pair.first == pit)
+   for (Row & row 

[LyX/master] Fix help message for --disable-qt5

2019-02-25 Thread Jean-Marc Lasgouttes
commit e78a5bd1a8793addd51b70d4f472fa380b9d6900
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 25 16:24:30 2019 +0100

Fix help message for --disable-qt5
---
 config/lyxinclude.m4 |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index b5ecb09..cf49495 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -68,7 +68,7 @@ dnl
 AC_DEFUN([LYX_CHECK_QT5],[
 AC_MSG_CHECKING([whether Qt5 is disabled])
 AC_ARG_ENABLE([qt5],
-  [  --disable-qt5   don't use Qt5 for building],
+  [AC_HELP_STRING([--disable-qt5],[do not use Qt5 for building])],
   USE_QT5=$enableval, USE_QT5=yes)
 if test x$USE_QT5 != xno ; then
   AC_MSG_RESULT([no])


[LyX/master] Make callstack printing useful and optional

2019-02-25 Thread Jean-Marc Lasgouttes
commit 4028eefe6190551c8be96cd451337dea2808742b
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 25 17:37:06 2019 +0100

Make callstack printing useful and optional

When callback printing is enabled, link lyx with -rdynamic, so that
stacks have LyX symbols available.

Add option --disable-callstack-printing to configure.

Running "size" on binary:
 * with callstack printing support
   textdata bss dec hex filename
20891684  34680  107796 21034160140f4b0 src/lyx

 * without callstack printing support
text   data bss dec hex filename
17953640  34648  107796 180960841141fd4 src/lyx
---
 config/lyxinclude.m4 |   33 -
 src/Makefile.am  |5 +++--
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index cf49495..8e1d279 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -609,22 +609,29 @@ dnl prevent clash with system zlib that might be dragged 
in by other libs
 dnl Usage: LYX_CHECK_CALLSTACK_PRINTING: define LYX_CALLSTACK_PRINTING if the
 dnlnecessary APIs are available to print callstacks.
 AC_DEFUN([LYX_CHECK_CALLSTACK_PRINTING],
-[AC_CACHE_CHECK([whether printing callstack is possible],
-   [lyx_cv_callstack_printing],
-[AC_TRY_COMPILE([
-#include 
-#include 
-], [
-   void* array[200];
-   size_t size = backtrace(array, 200);
-   backtrace_symbols(array, size);
-   int status = 0;
-   abi::__cxa_demangle("abcd", 0, 0, &status);
-],
-[lyx_cv_callstack_printing=yes], [lyx_cv_callstack_printing=no])])
+[AC_ARG_ENABLE([callstack-printing],
+   [AC_HELP_STRING([--disable-callstack-printing],[do not print a 
callstack when crashing])],
+   lyx_cv_callstack_printing=$enableval, 
lyx_cv_callstack_printing=yes)
+
+if test x"$lyx_cv_callstack_printing" = xyes; then
+  AC_CACHE_CHECK([whether printing callstack is possible],
+[lyx_cv_callstack_printing],
+  [AC_TRY_COMPILE([
+  #include 
+  #include 
+  ], [
+ void* array[200];
+ size_t size = backtrace(array, 200);
+ backtrace_symbols(array, size);
+ int status = 0;
+ abi::__cxa_demangle("abcd", 0, 0, &status);
+  ],, [lyx_cv_callstack_printing=no])])
+fi
 if test x"$lyx_cv_callstack_printing" = xyes; then
   AC_DEFINE([LYX_CALLSTACK_PRINTING], 1,
 [Define if callstack can be printed])
+  lyx_flags="$lyx_flags callback-printing"
+  AM_LDFLAGS="${AM_LDFLAGS} -rdynamic"
 fi
 ])
 
diff --git a/src/Makefile.am b/src/Makefile.am
index d924a5e..ef18959 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,6 +27,8 @@ OTHERLIBS = $(BOOST_LIBS) $(MYTHES_LIBS) $(ENCHANT_LIBS) 
$(HUNSPELL_LIBS) \
 noinst_LIBRARIES = liblyxcore.a
 bin_PROGRAMS = lyx
 
+lyx_LDFLAGS = $(AM_LDFLAGS) $(QT_LDFLAGS)
+
 lyx_LDADD = \
liblyxcore.a \
liblyxmathed.a \
@@ -36,7 +38,6 @@ lyx_LDADD = \
liblyxgraphics.a \
support/liblyxsupport.a \
$(OTHERLIBS) \
-   $(QT_LDFLAGS) \
$(QT_LIB)
 
 if LYX_WIN_RESOURCE
@@ -46,7 +47,7 @@ if LYX_WIN_RESOURCE
 endif
 
 if INSTALL_MACOSX
-lyx_LDFLAGS = -framework AppKit -framework ApplicationServices \
+lyx_LDFLAGS += -framework AppKit -framework ApplicationServices \
-Wl,-rpath,@loader_path/../Frameworks \
-Wl,-rpath,@executable_path/../Frameworks \
-Wl,-headerpad_max_install_names


[LyX/master] Update screen as needed when preferences are changed

2019-02-26 Thread Jean-Marc Lasgouttes
commit 954531f247adee029c12713634a81717f87a2bcf
Author: Jean-Marc Lasgouttes 
Date:   Tue Feb 26 16:37:41 2019 +0100

Update screen as needed when preferences are changed

This commit removes the adhoc code in GuiPrefs and moves it to LyXRC,
so that it triggers in every preference change.

The code has also been updated to trigger on more variables, e.g.
font_*_foundry.

Note that the actual function that are called have not been changed
(addPreviews and LFUN_SCREEN_FONT_UPDATE), although there are doubts
that they behave as needed (see FIXMEs).

Fixes bug #11498.
---
 src/LyXRC.cpp|   25 +++-
 src/frontends/qt4/GuiApplication.cpp |3 ++
 src/frontends/qt4/GuiPrefs.cpp   |   54 +++--
 src/frontends/qt4/GuiPrefs.h |9 -
 4 files changed, 32 insertions(+), 59 deletions(-)

diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index 46d23f2..b1936f0 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -23,6 +23,8 @@
 #include "Converter.h"
 #include "FontEnums.h"
 #include "Format.h"
+#include "FuncCode.h"
+#include "FuncRequest.h"
 #include "Lexer.h"
 #include "LyX.h"
 #include "Mover.h"
@@ -2942,6 +2944,14 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC 
const & lyxrc_new)
}
// fall through
case LyXRC::RC_PREVIEW:
+   if (lyxrc_orig.preview != lyxrc_new.preview) {
+   // Update all previews of all documents.
+   /* FIXME: this can be very expensive. It would be 
cheaper
+* to kill all existing previews and update visible
+* previews.*/
+   theBufferList().updatePreviews();
+   }
+   // fall through
case LyXRC::RC_PREVIEW_HASHED_LABELS:
case LyXRC::RC_PREVIEW_SCALE_FACTOR:
case LyXRC::RC_PRINTLANDSCAPEFLAG:
@@ -2950,6 +2960,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC 
const & lyxrc_new)
case LyXRC::RC_SAVE_COMPRESSED:
case LyXRC::RC_SAVE_ORIGIN:
case LyXRC::RC_SCREEN_DPI:
+
case LyXRC::RC_SCREEN_FONT_ROMAN:
case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
case LyXRC::RC_SCREEN_FONT_SANS:
@@ -2958,8 +2969,20 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC 
const & lyxrc_new)
case LyXRC::RC_SCREEN_FONT_SIZES:
case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
-   case LyXRC::RC_GEOMETRY_SESSION:
case LyXRC::RC_SCREEN_ZOOM:
+   if (lyxrc_orig.roman_font_name != lyxrc_new.roman_font_name
+   || lyxrc_orig.sans_font_name != lyxrc_new.sans_font_name
+   || lyxrc_orig.typewriter_font_name != 
lyxrc_new.typewriter_font_name
+   || lyxrc_orig.roman_font_foundry != lyxrc_new.roman_font_foundry
+   || lyxrc_orig.sans_font_foundry != lyxrc_new.sans_font_foundry
+   || lyxrc_orig.use_scalable_fonts != lyxrc_new.use_scalable_fonts
+   || lyxrc_orig.font_sizes != lyxrc_new.font_sizes
+   || lyxrc_orig.typewriter_font_foundry != 
lyxrc_new.typewriter_font_foundry
+   || lyxrc_orig.defaultZoom != lyxrc_new.defaultZoom) {
+   dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
+   }
+
+   case LyXRC::RC_GEOMETRY_SESSION:
case LyXRC::RC_SERVERPIPE:
case LyXRC::RC_SET_COLOR:
case LyXRC::RC_SHOW_BANNER:
diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 28b4da4..ac3e4e8 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -1642,6 +1642,9 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
 
case LFUN_SCREEN_FONT_UPDATE: {
// handle the screen font changes.
+   /* FIXME: this only updates the current document, whereas all
+* documents should see their metrics updated.
+*/
d->font_loader_.update();
dr.screenUpdate(Update::Force | Update::FitCursor);
break;
diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp
index 82cfd0a..be9e981 100644
--- a/src/frontends/qt4/GuiPrefs.cpp
+++ b/src/frontends/qt4/GuiPrefs.cpp
@@ -1030,15 +1030,6 @@ void PrefScreenFonts::applyRC(LyXRC & rc) const
rc.font_sizes[FONT_SIZE_LARGEST] = widgetToDoubleStr(screenLargestED);
rc.font_sizes[FONT_SIZE_HUGE] = widgetToDoubleStr(screenHugeED);
rc.font_sizes[FONT_SIZE_HUGER] = widgetToDoubleStr(screenHugerED);
-
-   if (rc.font_sizes != oldrc.font_sizes
-   || rc.roman_font_name != oldrc.roman_font_name
- 

[LyX/2.3.x] Update screen as needed when preferences are changed

2019-02-27 Thread Jean-Marc Lasgouttes
commit ee8a336cbc407e7fb587e2c155fee8c7a5d76e1e
Author: Jean-Marc Lasgouttes 
Date:   Tue Feb 26 16:37:41 2019 +0100

Update screen as needed when preferences are changed

This commit removes the adhoc code in GuiPrefs and moves it to LyXRC,
so that it triggers in every preference change.

The code has also been updated to trigger on more variables, e.g.
font_*_foundry.

Note that the actual function that are called have not been changed
(addPreviews and LFUN_SCREEN_FONT_UPDATE), although there are doubts
that they behave as needed (see FIXMEs).

Fixes bug #11498.

(cherry picked from commit 954531f247adee029c12713634a81717f87a2bcf)
---
 src/LyXRC.cpp|   25 ++-
 src/frontends/qt4/GuiApplication.cpp |3 ++
 src/frontends/qt4/GuiPrefs.cpp   |   58 +++---
 src/frontends/qt4/GuiPrefs.h |9 -
 status.23x   |6 ++-
 5 files changed, 36 insertions(+), 65 deletions(-)

diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index 71f184d..67530bd 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -23,6 +23,8 @@
 #include "Converter.h"
 #include "FontEnums.h"
 #include "Format.h"
+#include "FuncCode.h"
+#include "FuncRequest.h"
 #include "Lexer.h"
 #include "LyX.h"
 #include "Mover.h"
@@ -3003,6 +3005,14 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC 
const & lyxrc_new)
}
// fall through
case LyXRC::RC_PREVIEW:
+   if (lyxrc_orig.preview != lyxrc_new.preview) {
+   // Update all previews of all documents.
+   /* FIXME: this can be very expensive. It would be 
cheaper
+* to kill all existing previews and update visible
+* previews.*/
+   theBufferList().updatePreviews();
+   }
+   // fall through
case LyXRC::RC_PREVIEW_HASHED_LABELS:
case LyXRC::RC_PREVIEW_SCALE_FACTOR:
case LyXRC::RC_PRINTLANDSCAPEFLAG:
@@ -3011,6 +3021,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC 
const & lyxrc_new)
case LyXRC::RC_SAVE_COMPRESSED:
case LyXRC::RC_SAVE_ORIGIN:
case LyXRC::RC_SCREEN_DPI:
+
case LyXRC::RC_SCREEN_FONT_ROMAN:
case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
case LyXRC::RC_SCREEN_FONT_SANS:
@@ -3019,8 +3030,20 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC 
const & lyxrc_new)
case LyXRC::RC_SCREEN_FONT_SIZES:
case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
-   case LyXRC::RC_GEOMETRY_SESSION:
case LyXRC::RC_SCREEN_ZOOM:
+   if (lyxrc_orig.roman_font_name != lyxrc_new.roman_font_name
+   || lyxrc_orig.sans_font_name != lyxrc_new.sans_font_name
+   || lyxrc_orig.typewriter_font_name != 
lyxrc_new.typewriter_font_name
+   || lyxrc_orig.roman_font_foundry != lyxrc_new.roman_font_foundry
+   || lyxrc_orig.sans_font_foundry != lyxrc_new.sans_font_foundry
+   || lyxrc_orig.use_scalable_fonts != lyxrc_new.use_scalable_fonts
+   || lyxrc_orig.font_sizes != lyxrc_new.font_sizes
+   || lyxrc_orig.typewriter_font_foundry != 
lyxrc_new.typewriter_font_foundry
+   || lyxrc_orig.defaultZoom != lyxrc_new.defaultZoom) {
+   dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
+   }
+
+   case LyXRC::RC_GEOMETRY_SESSION:
case LyXRC::RC_SERVERPIPE:
case LyXRC::RC_SET_COLOR:
case LyXRC::RC_SHOW_BANNER:
diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 3c6e137..3d88764 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -1632,6 +1632,9 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
 
case LFUN_SCREEN_FONT_UPDATE: {
// handle the screen font changes.
+   /* FIXME: this only updates the current document, whereas all
+* documents should see their metrics updated.
+*/
d->font_loader_.update();
dr.screenUpdate(Update::Force | Update::FitCursor);
break;
diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp
index 58810df..ae0986e 100644
--- a/src/frontends/qt4/GuiPrefs.cpp
+++ b/src/frontends/qt4/GuiPrefs.cpp
@@ -1101,19 +1101,6 @@ void PrefScreenFonts::applyRC(LyXRC & rc) const
rc.font_sizes[FONT_SIZE_HUGE] = widgetToDoubleStr(screenHugeED);
rc.font_sizes[FONT_SIZE_HUGER] = widgetToDoubleStr(screenHugerED);
rc.use_pixmap_cache = pixmapCacheCB->isChecked();
-
-   if (rc.font_siz

[LyX/master] Use || instead of or operator

2019-02-28 Thread Jean-Marc Lasgouttes
commit 32d6396f88da6e8537e45a2acaa42cdf361df488
Author: Jean-Marc Lasgouttes 
Date:   Thu Feb 28 12:03:34 2019 +0100

Use || instead of or operator

It is more consistent and visual studio seems to dislike it anyway.
---
 src/BufferParams.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 60bfa3a..fc4ac4a 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -3290,7 +3290,7 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
break;
}
}
-   if (inputenc == "default" or features.isRequired("japanese")) {
+   if (inputenc == "default" || features.isRequired("japanese")) {
// don't default to [utf8]{inputenc} with TeXLive >= 18
os << "\\ifdefined\\UseRawInputEncoding\n";
os << "  \\UseRawInputEncoding\\fi\n";


[LyX/master] Make TextMetrics noncopyable

2019-03-12 Thread Jean-Marc Lasgouttes
commit 63bfaa14beef2521759571ca077834a412d12bbc
Author: Jean-Marc Lasgouttes 
Date:   Tue Mar 12 12:40:32 2019 +0100

Make TextMetrics noncopyable

This is done by declaring unimplemented private copy constructor and
assignment operator.

This breaks compilation in BufferView::textMetrics, which does a copy when
inserting a TextMetrics object in the cache. Some C++11 wizardry I will not
pretend to completely understand saves the day.

See the following page for details:
  https://en.cppreference.com/w/cpp/container/map/emplace

This avoids real world bugs like #11512.
---
 src/BufferView.cpp |5 +++--
 src/TextMetrics.h  |3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 50df1aa..900207c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2542,8 +2542,9 @@ TextMetrics & BufferView::textMetrics(Text const * t)
LBUFERR(t);
TextMetricsCache::iterator tmc_it  = d->text_metrics_.find(t);
if (tmc_it == d->text_metrics_.end()) {
-   tmc_it = d->text_metrics_.insert(
-   make_pair(t, TextMetrics(this, const_cast(t.first;
+   tmc_it = d->text_metrics_.emplace(std::piecewise_construct,
+   std::forward_as_tuple(t),
+   std::forward_as_tuple(this, const_cast(t))).first;
}
return tmc_it->second;
 }
diff --git a/src/TextMetrics.h b/src/TextMetrics.h
index 26156fa..006836f 100644
--- a/src/TextMetrics.h
+++ b/src/TextMetrics.h
@@ -33,6 +33,9 @@ class Text;
 /// A map from a Text to the map of paragraphs metrics
 class TextMetrics
 {
+   /// noncopyable
+   TextMetrics(TextMetrics const &);
+   void operator=(TextMetrics const &);
 public:
/// Default constructor (only here for STL containers).
TextMetrics() : bv_(0), text_(0), max_width_(0) {}


[LyX/master] Revert "Let tm be a reference here as elsewhere"

2019-03-12 Thread Jean-Marc Lasgouttes
commit f659af339efad6ed8e35d59404746c343fe9fcbd
Author: Jean-Marc Lasgouttes 
Date:   Tue Mar 12 12:44:08 2019 +0100

Revert "Let tm be a reference here as elsewhere"

This commit was wrong because a reference variable can never be
re-assigned (it would change the original variable). I learn C++
pitfalls every day.

Fixes bug #11512.

This reverts commit 10e2c658351c237d3b35566857a533a9d08f7f65.
---
 src/Text3.cpp |   24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/Text3.cpp b/src/Text3.cpp
index b78c8d1..6db9c2b 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -639,10 +639,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
}
 
BufferView * bv = &cur.bv();
-   TextMetrics & tm = bv->textMetrics(this);
-   if (!tm.contains(cur.pit())) {
+   TextMetrics * tm = &bv->textMetrics(this);
+   if (!tm->contains(cur.pit())) {
lyx::dispatch(FuncRequest(LFUN_SCREEN_SHOW_CURSOR));
-   tm = bv->textMetrics(this);
+   tm = &bv->textMetrics(this);
}
 
// FIXME: We use the update flag to indicates wether a singlePar or a
@@ -735,7 +735,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
if (cur.selection())
cutSelection(cur, false);
else
-   tm.deleteLineForward(cur);
+   tm->deleteLineForward(cur);
finishChange(cur, false);
break;
 
@@ -941,13 +941,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_LINE_BEGIN:
case LFUN_LINE_BEGIN_SELECT:
needsUpdate |= cur.selHandle(cmd.action() == 
LFUN_LINE_BEGIN_SELECT);
-   needsUpdate |= tm.cursorHome(cur);
+   needsUpdate |= tm->cursorHome(cur);
break;
 
case LFUN_LINE_END:
case LFUN_LINE_END_SELECT:
needsUpdate |= cur.selHandle(cmd.action() == 
LFUN_LINE_END_SELECT);
-   needsUpdate |= tm.cursorEnd(cur);
+   needsUpdate |= tm->cursorEnd(cur);
break;
 
case LFUN_SECTION_SELECT: {
@@ -1530,8 +1530,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
case LFUN_SERVER_GET_XY:
cur.message(from_utf8(
-   convert(tm.cursorX(cur.top(), cur.boundary()))
-   + ' ' + convert(tm.cursorY(cur.top(), 
cur.boundary();
+   convert(tm->cursorX(cur.top(), cur.boundary()))
+   + ' ' + convert(tm->cursorY(cur.top(), 
cur.boundary();
break;
 
case LFUN_SERVER_SET_XY: {
@@ -1543,7 +1543,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
lyxerr << "SETXY: Could not parse coordinates in '"
   << to_utf8(cmd.argument()) << endl;
else
-   tm.setCursorFromCoordinates(cur, x, y);
+   tm->setCursorFromCoordinates(cur, x, y);
break;
}
 
@@ -1761,9 +1761,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
case LFUN_MOUSE_TRIPLE:
if (cmd.button() == mouse_button::button1) {
-   tm.cursorHome(cur);
+   tm->cursorHome(cur);
cur.resetAnchor();
-   tm.cursorEnd(cur);
+   tm->cursorEnd(cur);
cur.setSelection();
bv->cursor() = cur;
}
@@ -1838,7 +1838,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
int const wh = bv->workHeight();
int const y = max(0, min(wh - 1, cmd.y()));
 
-   tm.setCursorFromCoordinates(cur, cmd.x(), y);
+   tm->setCursorFromCoordinates(cur, cmd.x(), y);
cur.setTargetX(cmd.x());
// Don't allow selecting a separator inset
if (cur.pos() && cur.paragraph().isEnvSeparator(cur.pos() - 1))


[LyX/master] Update poor man's profiler to use C++11 std::chrono

2019-03-17 Thread Jean-Marc Lasgouttes
commit bdf3924fc78d0495b241e2202a9633cded6aca45
Author: Jean-Marc Lasgouttes 
Date:   Sun Mar 17 13:57:44 2019 +0100

Update poor man's profiler to use C++11 std::chrono

This is more portable, and the old code prevented in windows to use
instrument several classes at the same time (several .obj files,
actually).

No new feature here, bu the code is nicely slower. It might be less
efficient, I am not really at ease with how std::chrono works.
---
 src/support/pmprof.h |   79 --
 1 files changed, 25 insertions(+), 54 deletions(-)

diff --git a/src/support/pmprof.h b/src/support/pmprof.h
index 8f91125..fb92670 100644
--- a/src/support/pmprof.h
+++ b/src/support/pmprof.h
@@ -112,52 +112,30 @@
 
 #else
 
-#ifdef _WIN32
-#include 
-#else
-#include 
-#endif
-
+#include 
 #include 
 #include 
 
 
-#if defined(__GNUG__) && defined(_GLIBCXX_DEBUG)
-#error Profiling is not usable when run-time debugging is in effect
-#endif
-
-#ifdef _WIN32
-/* This function does not really returns the "time of day",
- * but it will suffice to evaluate elapsed times.
- */
-int gettimeofday(struct timeval * tv, struct timezone * /*tz*/)
-{
-   LARGE_INTEGER frequency, t;
-   QueryPerformanceFrequency(&frequency);
-   QueryPerformanceCounter(&t);
-
-   tv->tv_sec = long(t.QuadPart / frequency.QuadPart);
-   tv->tv_usec = long((100.0 * (t.QuadPart % frequency.QuadPart)) / 
frequency.QuadPart);
-   return 0;
-}
-
-#endif // _WIN32
+//#if defined(__GNUG__) && defined(_GLIBCXX_DEBUG)
+//#error Profiling is not usable when run-time debugging is in effect
+//#endif
 
 namespace {
 
-void dumpTime(long long value)
+void dumpTime(std::chrono::duration value)
 {
+   double const val = value.count();
std::cerr << std::fixed << std::setprecision(2);
-   if (value >= 100)
-   std::cerr << value / 100 << "sec";
-   else if (value >= 1000)
-   std::cerr << value / 1000 << "msec";
+   if (val >= 1.0)
+   std::cerr << val << " s";
+   else if (val >= 0.001)
+   std::cerr << val * 1000 << " ms";
else
-   std::cerr << value << "usec";
+   std::cerr << val * 100 << " us";
 }
 
-void dump(long long sec, long long usec, unsigned long long count) {
-   double const total = sec * 100 + usec;
+void dump(std::chrono::duration total, unsigned long long count) {
dumpTime(total / count);
std::cerr << ", count=" << count
  << ", total=";
@@ -176,44 +154,39 @@ void dump(long long sec, long long usec, unsigned long 
long count) {
 
 class PMProfStat {
 public:
-   PMProfStat(char const * name) : name_(name), sec_(0), usec_(0), 
count_(0),
-miss_sec_(0), miss_usec_(0), 
miss_count_(0) {}
+   PMProfStat(char const * name) : name_(name), count_(0), miss_count_(0) 
{}
 
~PMProfStat() {
if (count_>0) {
if (miss_count_ == 0) {
std::cerr << "#pmprof# " << name_ << ": ";
-   dump(sec_, usec_, count_);
+   dump(dur_, count_);
}
else {
std::cerr << "#pmprof# " << name_ << ": ";
-   dump(sec_ + miss_sec_, usec_ + miss_usec_, 
count_ + miss_count_);
+   dump(dur_ + miss_dur_, count_ + miss_count_);
std::cerr << "   hit: " << 100 * count_ / 
(count_ + miss_count_) << "%, ";
-   dump(sec_, usec_, count_);
+   dump(dur_, count_);
std::cerr << "  miss: " << 100 * miss_count_ / 
(count_ + miss_count_) << "%, ";
-   dump(miss_sec_, miss_usec_, miss_count_);
+   dump(miss_dur_, miss_count_);
}
}
}
 
-   void add(const long long s, const long long u, const bool hit) {
+   void add(std::chrono::duration d, const bool hit) {
if (hit) {
-   sec_ += s;
-   usec_ += u;
+   dur_ += d;
count_++;
} else {
-   miss_sec_ += s;
-   miss_usec_ += u;
+   miss_dur_ += d;
miss_count_++;
}

[LyX/master] Fix MSVC warning

2019-03-17 Thread Jean-Marc Lasgouttes
commit 9a15d354437a37342cf71a892b8b7a9b5338c5ad
Author: Jean-Marc Lasgouttes 
Date:   Sun Mar 17 14:28:22 2019 +0100

Fix MSVC warning
---
 src/RowPainter.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index a060874..718b1a9 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -432,7 +432,7 @@ void RowPainter::paintLabel() const
int const x = row_.isRTL() ? row_.width() + fm.width(layout.labelsep)
   : row_.left_margin - 
fm.width(layout.labelsep) - fm.width(str);
 
-   pi_.pain.text(xo_ + x, yo_, str, font);
+   pi_.pain.text(int(xo_) + x, yo_, str, font);
 }
 
 


[LyX/master] Compilation fix for Qt < 5.2.

2019-03-20 Thread Jean-Marc Lasgouttes
commit 0c8eea0fe526e17c75c524c0eacdacfd78d8d7b2
Author: Jean-Marc Lasgouttes 
Date:   Wed Mar 20 11:45:29 2019 +0100

Compilation fix for Qt < 5.2.
---
 src/frontends/qt4/GuiLyXFiles.cpp |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/frontends/qt4/GuiLyXFiles.cpp 
b/src/frontends/qt4/GuiLyXFiles.cpp
index c5d5c05..4d4746d 100644
--- a/src/frontends/qt4/GuiLyXFiles.cpp
+++ b/src/frontends/qt4/GuiLyXFiles.cpp
@@ -58,7 +58,11 @@ void GuiLyXFiles::getFiles(QMap & in, 
QString const type)
string const system = addPath(package().system_support().absFileName(), 
fromqstr(type));
 
// First, query the current language subdir (except for English)
+#if QT_VERSION >= 0x050200
QString const lang = languageCO->currentData().toString();
+#else
+   QString const lang = languageCO->currentText();
+#endif
if (!lang.startsWith("en")) {
// First try with the full code
dirs << toqstr(addPath(user, fromqstr(lang)));


[LyX/master] Cache the value of GuiFontMetrics::lbearing().

2019-03-20 Thread Jean-Marc Lasgouttes
commit d3979e798cd9c85041bb5e6158002384a8cddb8c
Author: Jean-Marc Lasgouttes 
Date:   Wed Mar 20 10:56:16 2019 +0100

Cache the value of GuiFontMetrics::lbearing().

This seems to be necessary on windows, where math editing can get very
slow. Note that other methods like rbearing already use a cache.

In the future all these caches for single characters shall be unified.
---
 src/frontends/qt4/GuiFontMetrics.cpp |   25 +
 src/frontends/qt4/GuiFontMetrics.h   |2 ++
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/frontends/qt4/GuiFontMetrics.cpp 
b/src/frontends/qt4/GuiFontMetrics.cpp
index b57f514..5f70c8d 100644
--- a/src/frontends/qt4/GuiFontMetrics.cpp
+++ b/src/frontends/qt4/GuiFontMetrics.cpp
@@ -148,20 +148,29 @@ int GuiFontMetrics::strikeoutPos() const
 }
 
 
+namespace {
+int const outOfLimitMetric = -1;
+}
+
+
 int GuiFontMetrics::lbearing(char_type c) const
 {
-   if (!is_utf16(c))
+   int value = lbearing_cache_.value(c, outOfLimitMetric);
+   if (value != outOfLimitMetric)
+   return value;
+
+   if (is_utf16(c))
+   value = metrics_.leftBearing(ucs4_to_qchar(c));
+   else {
// FIXME: QFontMetrics::leftBearing does not support the
//full unicode range. Once it does, we could use:
-   //return metrics_.leftBearing(toqstr(docstring(1, c)));
-   return 0;
-
-   return metrics_.leftBearing(ucs4_to_qchar(c));
-}
+   // metrics_.leftBearing(toqstr(docstring(1, c)));
+   value = 0;
+   }
 
+   lbearing_cache_.insert(c, value);
 
-namespace {
-int const outOfLimitMetric = -1;
+   return value;
 }
 
 
diff --git a/src/frontends/qt4/GuiFontMetrics.h 
b/src/frontends/qt4/GuiFontMetrics.h
index 6d50d35..44897c4 100644
--- a/src/frontends/qt4/GuiFontMetrics.h
+++ b/src/frontends/qt4/GuiFontMetrics.h
@@ -103,6 +103,8 @@ private:
/// fill in \c metrics_cache_ at specified value.
AscendDescend const fillMetricsCache(char_type) const;
 
+   /// Cache of char leftt bearings
+   mutable QHash lbearing_cache_;
/// Cache of char right bearings
mutable QHash rbearing_cache_;
 


[LyX/master] Initialize hasTitle in Intervall constructor

2019-03-20 Thread Jean-Marc Lasgouttes
commit 1c755fefa50886cf760d0b03b983e49896b16af5
Author: Jean-Marc Lasgouttes 
Date:   Wed Mar 20 17:25:25 2019 +0100

Initialize hasTitle in Intervall constructor

I also moved around some things while I was at it.

Spotted by coverity scan.
---
 src/lyxfind.cpp |   20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index b347448..d5b750d 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -1114,11 +1114,15 @@ static vector borders = vector(30);
 #define MAXOPENED 30
 class Intervall {
   bool isPatternString;
- public:
- explicit Intervall(bool isPattern) :
-  isPatternString(isPattern),
-ignoreidx(-1),
-actualdeptindex(0) { depts[0] = 0; closes[0] = 0;};
+public:
+  explicit Intervall(bool isPattern, string const & p) :
+   isPatternString(isPattern), par(p), ignoreidx(-1), actualdeptindex(0),
+   hasTitle(false)
+  {
+depts[0] = 0;
+closes[0] = 0;
+  }
+
   string par;
   int ignoreidx;
   int depts[MAXOPENED];
@@ -1463,10 +1467,8 @@ class LatexInfo {
   void removeHead(KeyInfo&, int count=0);
 
  public:
- LatexInfo(string par, bool isPatternString) : entidx(-1), 
interval(isPatternString) {
-interval.par = par;
-interval.hasTitle = false;
-interval.titleValue = "";
+ LatexInfo(string par, bool isPatternString) : entidx(-1), 
interval(isPatternString, par)
+  {
 buildKeys(isPatternString);
 entries = vector();
 buildEntries(isPatternString);


Re: [LyX/master] Initialize hasTitle in Intervall constructor

2019-03-20 Thread Jean-Marc Lasgouttes

Le 20/03/2019 à 17:21, Jean-Marc Lasgouttes a écrit :

commit 1c755fefa50886cf760d0b03b983e49896b16af5
Author: Jean-Marc Lasgouttes 
Date:   Wed Mar 20 17:25:25 2019 +0100

 Initialize hasTitle in Intervall constructor
 
 I also moved around some things while I was at it.
 
 Spotted by coverity scan.


Kornel,

I tried toonly touch what would make coverity happy. In the medium term 
(when you advanced F&R is not in flux anymore), this file will have to 
be updated to follow our code rules, like:

* tabs, not spaces for indentation
* name prvate variables with an _ at the end
* try not to mix methods and variables in class decrlaration
* not parentheses in return statements
* ...

There are probably other things, but we have time for that.

I hope I did not break something, but it should not be the case.

JMarc


---
  src/lyxfind.cpp |   20 +++-
  1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index b347448..d5b750d 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -1114,11 +1114,15 @@ static vector borders = vector(30);
  #define MAXOPENED 30
  class Intervall {
bool isPatternString;
- public:
- explicit Intervall(bool isPattern) :
-  isPatternString(isPattern),
-ignoreidx(-1),
-actualdeptindex(0) { depts[0] = 0; closes[0] = 0;};
+public:
+  explicit Intervall(bool isPattern, string const & p) :
+   isPatternString(isPattern), par(p), ignoreidx(-1), actualdeptindex(0),
+   hasTitle(false)
+  {
+depts[0] = 0;
+closes[0] = 0;
+  }
+
string par;
int ignoreidx;
int depts[MAXOPENED];
@@ -1463,10 +1467,8 @@ class LatexInfo {
void removeHead(KeyInfo&, int count=0);
  
   public:

- LatexInfo(string par, bool isPatternString) : entidx(-1), 
interval(isPatternString) {
-interval.par = par;
-interval.hasTitle = false;
-interval.titleValue = "";
+ LatexInfo(string par, bool isPatternString) : entidx(-1), 
interval(isPatternString, par)
+  {
  buildKeys(isPatternString);
  entries = vector();
  buildEntries(isPatternString);





Re: [LyX/master] Initialize hasTitle in Intervall constructor

2019-03-20 Thread Jean-Marc Lasgouttes

Le 20/03/2019 à 23:36, Kornel Benko a écrit :

Am Mittwoch, 20. März 2019 17:33:39 CET schrieb Jean-Marc Lasgouttes 
:

Le 20/03/2019 à 17:21, Jean-Marc Lasgouttes a écrit :

commit 1c755fefa50886cf760d0b03b983e49896b16af5
Author: Jean-Marc Lasgouttes 
Date:   Wed Mar 20 17:25:25 2019 +0100

  Initialize hasTitle in Intervall constructor
  
  I also moved around some things while I was at it.
  
  Spotted by coverity scan.


Kornel,

I tried to only touch what would make coverity happy.


I think, you removed the initialization of interval.titleValue. This may not be 
needed though.


Indeed a string initializes itself to empty.


* tabs, not spaces for indentation


I don't like this one. Using spaces assures the same indentation on screen 
independent
of the tab value :(
I have always problems setting tab to something else then 8.
And using this value leads sometimes to dep indentations.


I use 4 everywhere and it works pretty well. Anyway, we have to do the 
same for all the code, it is so much easier on the eyes (and on the 
editor configuration).



* name prvate variables with an _ at the end
* try not to mix methods and variables in class decrlaration
* not parentheses in return statements
* ...


OK, but don't expect it to be done yesterday :)


I can do part of that, but I do not want to change all your file behind 
your back (especially if you have pending patches).


JMarc


[LyX/master] Compilation fix

2019-03-21 Thread Jean-Marc Lasgouttes
commit 5d30f790dd0bb01249641f3f45b4871e90bda0a1
Author: Jean-Marc Lasgouttes 
Date:   Thu Mar 21 10:28:16 2019 +0100

Compilation fix

For some reason I need this (maybe a Qt4/5 discrepancy).
---
 src/frontends/qt4/GuiLyXFiles.h |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/frontends/qt4/GuiLyXFiles.h b/src/frontends/qt4/GuiLyXFiles.h
index 6a25697..1f2eaa3 100644
--- a/src/frontends/qt4/GuiLyXFiles.h
+++ b/src/frontends/qt4/GuiLyXFiles.h
@@ -16,6 +16,8 @@
 #include "FancyLineEdit.h"
 #include "ui_LyXFilesUi.h"
 
+#include 
+
 class QListWidgetItem;
 
 namespace lyx {


[LyX/master] Mark inserted/deleted end of paragraph using pilcrow

2019-03-21 Thread Jean-Marc Lasgouttes
commit c2732a30f9e09208cb1010ae42d8e56ee80f2a78
Author: Jean-Marc Lasgouttes 
Date:   Thu Mar 21 11:27:51 2019 +0100

Mark inserted/deleted end of paragraph using pilcrow

Instead of the weird corner line, display a pilcrow sign (even when
disabled in prefs) to mark inserted/deleted end of paragraph.

Incidentally, this fixes the recent placement bug of the corner line.
---
 src/RowPainter.cpp  |   24 
 src/TextMetrics.cpp |6 --
 2 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 718b1a9..a88ac2a 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -507,30 +507,6 @@ static int getEndLabel(pit_type p, Text const & text)
 void RowPainter::paintLast() const
 {
int const endlabel = getEndLabel(row_.pit(), text_);
-
-   // paint imaginary end-of-paragraph character
-
-   Change const & change = par_.lookupChange(par_.size());
-   if (change.changed()) {
-   FontMetrics const & fm =
-   
theFontMetrics(pi_.base.bv->buffer().params().getFont());
-   int const length = fm.maxAscent() / 2;
-   Color col = change.color();
-
-   pi_.pain.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - 
length, col,
-  Painter::line_solid, 3);
-
-   if (change.deleted()) {
-   pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 
1 + length,
-   yo_ + 2, col, Painter::line_solid, 3);
-   } else {
-   pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 
1,
-   yo_ + 2, col, Painter::line_solid, 3);
-   }
-   }
-
-   // draw an endlabel
-
switch (endlabel) {
case END_LABEL_BOX:
case END_LABEL_FILLED_BOX: {
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 88ffa6f..a29b4dc 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1001,7 +1001,9 @@ bool TextMetrics::breakRow(Row & row, int const 
right_margin) const
// End of paragraph marker. The logic here is almost the
// same as in redoParagraph, remember keep them in sync.
ParagraphList const & pars = text_->paragraphs();
-   if (lyxrc.paragraph_markers && !need_new_row
+   Change const & change = par.lookupChange(i);
+   if ((lyxrc.paragraph_markers || change.changed())
+   && !need_new_row
&& i == end && size_type(row.pit() + 1) < pars.size()) {
// add a virtual element for the end-of-paragraph
// marker; it is shown on screen, but does not exist
@@ -1012,7 +1014,7 @@ bool TextMetrics::breakRow(Row & row, int const 
right_margin) const
= text_->inset().buffer().params();
f.setLanguage(par.getParLanguage(bparams));
// ¶ U+00B6 PILCROW SIGN
-   row.addVirtual(end, docstring(1, char_type(0x00B6)), f, 
Change());
+   row.addVirtual(end, docstring(1, char_type(0x00B6)), f, change);
}
 
// Is there a end-of-paragaph change?


[LyX/2.3.x] Place the depth bar correctly in full screen mode

2019-03-21 Thread Jean-Marc Lasgouttes
commit f94cdf6e1c6cd0ca9f4debb109f99e818fff68d9
Author: Jean-Marc Lasgouttes 
Date:   Tue Sep 11 16:45:48 2018 +0200

Place the depth bar correctly in full screen mode

In full screen mode, it is possible to restrict the text width. In
this case, the paint bar should not be painted outside of this
restricted area.

Fixes bug #11286.

(cherry picked from commit 7485225cc6f26c9e03d3674f4f361b431074fa6e)
---
 src/RowPainter.cpp |4 ++--
 status.23x |2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index f27eae6..3f367ce 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -312,9 +312,9 @@ void RowPainter::paintDepthBar() const
for (depth_type i = 1; i <= depth; ++i) {
int const w = nestMargin() / 5;
int x = int(xo_) + w * i;
-   // only consider the changebar space if we're drawing outermost 
text
+   // consider the bufferview left margin if we're drawing 
outermost text
if (text_.isMainText())
-   x += changebarMargin();
+   x += pi_.base.bv->leftMargin();
 
int const starty = yo_ - row_.ascent();
int const h =  row_.height() - 1 - (i - next_depth - 1) * 3;
diff --git a/status.23x b/status.23x
index adf8b13..d7afa35 100644
--- a/status.23x
+++ b/status.23x
@@ -169,6 +169,8 @@ What's new
 
 - Fix behavior of (un)setting all tabular borders (bug 11382).
 
+- Place the indentation bars correctly in full-screen mode (bug 11286).
+
 
 * INTERNALS
 


[LyX/master] Use HAVE_LONG_LONG_INT instead of LYX_USE_LONG_LONG

2019-03-21 Thread Jean-Marc Lasgouttes
commit 601244ba92c3975f6915455943d49c621d9487fb
Author: Jean-Marc Lasgouttes 
Date:   Thu Mar 21 14:05:50 2019 +0100

Use HAVE_LONG_LONG_INT instead of LYX_USE_LONG_LONG

It seems that the extra complication hurts more than it helps (for
example with OpenBSD).

Some adaptation will be needed for cmake.
---
 configure.ac  |   10 --
 src/support/convert.cpp   |4 ++--
 src/support/convert.h |4 ++--
 src/support/debug.cpp |2 +-
 src/support/debug.h   |2 +-
 src/support/docstring.cpp |4 ++--
 src/support/lstrings.cpp  |2 +-
 src/support/lstrings.h|2 +-
 src/texstream.cpp |4 ++--
 9 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/configure.ac b/configure.ac
index 703d267..f4a6caf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,10 +123,6 @@ AC_SUBST([HAVE_WCHAR_T])
 
 # Needed for Mingw-w64
 AC_TYPE_LONG_LONG_INT
-if test "$ac_cv_type_long_long_int" = yes; then
-  AC_CHECK_SIZEOF(long)
-  AC_CHECK_SIZEOF(long long)
-fi
 
 ### We need iconv for unicode support (Qt4 frontend requires it too)
 LYX_USE_INCLUDED_ICONV
@@ -309,12 +305,6 @@ char * strerror(int n);
 #  define USE_WCHAR_T
 #endif
 
-#ifdef HAVE_LONG_LONG_INT
-#if SIZEOF_LONG_LONG > SIZEOF_LONG
-#define LYX_USE_LONG_LONG
-#endif
-#endif
-
 #endif
 ])
 
diff --git a/src/support/convert.cpp b/src/support/convert.cpp
index b1c554e..9455643 100644
--- a/src/support/convert.cpp
+++ b/src/support/convert.cpp
@@ -105,7 +105,7 @@ docstring convert(unsigned long ul)
 }
 
 
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 template<>
 string convert(unsigned long long ull)
 {
@@ -135,7 +135,7 @@ docstring convert(long l)
 }
 
 
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 template<>
 string convert(long long ll)
 {
diff --git a/src/support/convert.h b/src/support/convert.h
index fb069c9..3b97fb6 100644
--- a/src/support/convert.h
+++ b/src/support/convert.h
@@ -33,13 +33,13 @@ template<> std::string convert(unsigned int 
ui);
 template<> docstring convert(unsigned int ui);
 template<> std::string convert(unsigned long ul);
 template<> docstring convert(unsigned long ul);
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 template<> std::string convert(unsigned long long ull);
 template<> docstring convert(unsigned long long ull);
 #endif
 template<> std::string convert(long l);
 template<> docstring convert(long l);
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 template<> std::string convert(long long ll);
 template<> docstring convert(long long ll);
 #endif
diff --git a/src/support/debug.cpp b/src/support/debug.cpp
index 3026df0..e72a43d 100644
--- a/src/support/debug.cpp
+++ b/src/support/debug.cpp
@@ -240,7 +240,7 @@ LyXErr & operator<<(LyXErr & l, long t)
 { return toStream(l, t); }
 LyXErr & operator<<(LyXErr & l, unsigned long t)
 { return toStream(l, t); }
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 LyXErr & operator<<(LyXErr & l, long long t)
 { return toStream(l, t); }
 LyXErr & operator<<(LyXErr & l, unsigned long long t)
diff --git a/src/support/debug.h b/src/support/debug.h
index f6b06d5..212049a 100644
--- a/src/support/debug.h
+++ b/src/support/debug.h
@@ -202,7 +202,7 @@ LyXErr & operator<<(LyXErr &, int);
 LyXErr & operator<<(LyXErr &, unsigned int);
 LyXErr & operator<<(LyXErr &, long);
 LyXErr & operator<<(LyXErr &, unsigned long);
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 LyXErr & operator<<(LyXErr &, long long);
 LyXErr & operator<<(LyXErr &, unsigned long long);
 #endif
diff --git a/src/support/docstring.cpp b/src/support/docstring.cpp
index 496d4c0..c53222d 100644
--- a/src/support/docstring.cpp
+++ b/src/support/docstring.cpp
@@ -514,7 +514,7 @@ protected:
return do_put_helper(oit, b, fill, v);
}
 
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
iter_type
do_put(iter_type oit, ios_base & b, char_type fill, long long v) const
{
@@ -675,7 +675,7 @@ protected:
return do_get_integer(iit, eit, b, err, v);
}
 
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
iter_type
do_get(iter_type iit, iter_type eit, ios_base & b,
ios_base::iostate & err, long long & v) const
diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp
index e69fc88..3195762 100644
--- a/src/support/lstrings.cpp
+++ b/src/support/lstrings.cpp
@@ -1475,7 +1475,7 @@ docstring bformat(docstring const & fmt, long arg1)
 }
 
 
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 docstring bformat(docstring const & fmt, long long arg1)
 {
LATTEST(contains(fmt, from_ascii("%1$d")));
diff --git a/src/support/lstrings.h b/src/support/lstring

Re: [LyX/master] Amend 601244ba92: Use HAVE_LONG_LONG_INT instead of LYX_USE_LONG_LONG

2019-03-21 Thread Jean-Marc Lasgouttes

Le 21/03/2019 à 15:13, Kornel Benko a écrit :

commit afccaae48a88576645ba65c983e26e86c5969a79
Author: Kornel Benko 
Date:   Thu Mar 21 15:17:24 2019 +0100

 Amend 601244ba92: Use HAVE_LONG_LONG_INT instead of LYX_USE_LONG_LONG
 
 Cmake changes



  #ifdef HAVE_LONG_LONG
  #ifdef SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG
-#define LYX_USE_LONG_LONG
+#define HAVE_LONG_LONG_INT 1
  #endif
  #endif


I propose to just rename HAVE_LONG_LONG to HAVE_LONG_LONG_INT and be 
remove the code above.done with it. The test of type sizes is what we 
want to get rid of.


JMarc


[LyX/2.3.x] Cache the value of GuiFontMetrics::lbearing().

2019-03-21 Thread Jean-Marc Lasgouttes
commit e0879b14602c0aff25ba951f6aa1277e4a94f988
Author: Jean-Marc Lasgouttes 
Date:   Wed Mar 20 10:56:16 2019 +0100

Cache the value of GuiFontMetrics::lbearing().

This seems to be necessary on windows, where math editing can get very
slow. Note that other methods like rbearing already use a cache.

In the future all these caches for single characters shall be unified.

(cherry picked from commit d3979e798cd9c85041bb5e6158002384a8cddb8c)
---
 src/frontends/qt4/GuiFontMetrics.cpp |   25 +
 src/frontends/qt4/GuiFontMetrics.h   |2 ++
 status.23x   |2 ++
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/frontends/qt4/GuiFontMetrics.cpp 
b/src/frontends/qt4/GuiFontMetrics.cpp
index 8ed8228..63f61f2 100644
--- a/src/frontends/qt4/GuiFontMetrics.cpp
+++ b/src/frontends/qt4/GuiFontMetrics.cpp
@@ -135,20 +135,29 @@ int GuiFontMetrics::strikeoutPos() const
 }
 
 
+namespace {
+int const outOfLimitMetric = -1;
+}
+
+
 int GuiFontMetrics::lbearing(char_type c) const
 {
-   if (!is_utf16(c))
+   int value = lbearing_cache_.value(c, outOfLimitMetric);
+   if (value != outOfLimitMetric)
+   return value;
+
+   if (is_utf16(c))
+   value = metrics_.leftBearing(ucs4_to_qchar(c));
+   else {
// FIXME: QFontMetrics::leftBearing does not support the
//full unicode range. Once it does, we could use:
-   //return metrics_.leftBearing(toqstr(docstring(1, c)));
-   return 0;
-
-   return metrics_.leftBearing(ucs4_to_qchar(c));
-}
+   // metrics_.leftBearing(toqstr(docstring(1, c)));
+   value = 0;
+   }
 
+   lbearing_cache_.insert(c, value);
 
-namespace {
-int const outOfLimitMetric = -1;
+   return value;
 }
 
 
diff --git a/src/frontends/qt4/GuiFontMetrics.h 
b/src/frontends/qt4/GuiFontMetrics.h
index 3f50dfe..6cea40f 100644
--- a/src/frontends/qt4/GuiFontMetrics.h
+++ b/src/frontends/qt4/GuiFontMetrics.h
@@ -101,6 +101,8 @@ private:
/// fill in \c metrics_cache_ at specified value.
AscendDescend const fillMetricsCache(char_type) const;
 
+   /// Cache of char left bearings
+   mutable QHash lbearing_cache_;
/// Cache of char right bearings
mutable QHash rbearing_cache_;
 
diff --git a/status.23x b/status.23x
index d7afa35..29f9d20 100644
--- a/status.23x
+++ b/status.23x
@@ -51,6 +51,8 @@ What's new
 
 - Fix bad error message (bug 11486).
 
+- Improve performance on Windows with lots of math insets.
+
 
 * DOCUMENTATION AND LOCALIZATION
 


[LyX/master] typo

2019-03-21 Thread Jean-Marc Lasgouttes
commit e170051909b82b518d07c23336c8880d9f85c883
Author: Jean-Marc Lasgouttes 
Date:   Thu Mar 21 18:45:28 2019 +0100

typo
---
 src/frontends/qt4/GuiFontMetrics.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/frontends/qt4/GuiFontMetrics.h 
b/src/frontends/qt4/GuiFontMetrics.h
index 44897c4..830a824 100644
--- a/src/frontends/qt4/GuiFontMetrics.h
+++ b/src/frontends/qt4/GuiFontMetrics.h
@@ -103,7 +103,7 @@ private:
/// fill in \c metrics_cache_ at specified value.
AscendDescend const fillMetricsCache(char_type) const;
 
-   /// Cache of char leftt bearings
+   /// Cache of char left bearings
mutable QHash lbearing_cache_;
/// Cache of char right bearings
mutable QHash rbearing_cache_;


Re: [LyX/master] Use GuiLyXFiles also for ui, kbd and bind files in prefs

2019-03-22 Thread Jean-Marc Lasgouttes

Le 22/03/2019 à 14:09, Juergen Spitzmueller a écrit :

commit 58c4c11c4c12a5ae52da823b5dc53ed5b6e2b703
Author: Juergen Spitzmueller 
Date:   Fri Mar 22 14:11:46 2019 +0100

 Use GuiLyXFiles also for ui, kbd and bind files in prefs


I need to use the following to compile, at least with Qt 4.8 and 5.5.

JMarc

From ddd32db20341b2b4a5f151125b6ffc0209214116 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes 
Date: Fri, 22 Mar 2019 14:39:36 +0100
Subject: [PATCH] Compilation fix

---
 src/frontends/qt4/GuiLyXFiles.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/frontends/qt4/GuiLyXFiles.cpp b/src/frontends/qt4/GuiLyXFiles.cpp
index bcb2dcd..89623b7 100644
--- a/src/frontends/qt4/GuiLyXFiles.cpp
+++ b/src/frontends/qt4/GuiLyXFiles.cpp
@@ -550,7 +550,12 @@ void GuiLyXFiles::passParams(string const & data)
 
 void GuiLyXFiles::selectItem(QString const item)
 {
-	QList twi = filesLW->findItems(item, Qt::MatchExactly|Qt::MatchRecursive);
+	/* Using an intermediary variable flags is needed up to at least
+	 * Qt 5.5 because of a subtle namespace issue. See:
+	 *   https://stackoverflow.com/questions/10755058/qflags-enum-type-conversion-fails-all-of-a-sudden
+	 * for details.*/
+	Qt::MatchFlags const flags(Qt::MatchExactly|Qt::MatchRecursive);
+	QList twi = filesLW->findItems(item, flags);
 	if (!twi.isEmpty())
 		twi.first()->setSelected(true);
 }
-- 
2.7.4



[LyX/master] Compilation fix

2019-03-22 Thread Jean-Marc Lasgouttes
commit b79a694c56bbc60d0695c8ce58d5d79e23321157
Author: Jean-Marc Lasgouttes 
Date:   Fri Mar 22 14:39:36 2019 +0100

Compilation fix
---
 src/frontends/qt4/GuiLyXFiles.cpp |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/frontends/qt4/GuiLyXFiles.cpp 
b/src/frontends/qt4/GuiLyXFiles.cpp
index bcb2dcd..89623b7 100644
--- a/src/frontends/qt4/GuiLyXFiles.cpp
+++ b/src/frontends/qt4/GuiLyXFiles.cpp
@@ -550,7 +550,12 @@ void GuiLyXFiles::passParams(string const & data)
 
 void GuiLyXFiles::selectItem(QString const item)
 {
-   QList twi = filesLW->findItems(item, 
Qt::MatchExactly|Qt::MatchRecursive);
+   /* Using an intermediary variable flags is needed up to at least
+* Qt 5.5 because of a subtle namespace issue. See:
+*   
https://stackoverflow.com/questions/10755058/qflags-enum-type-conversion-fails-all-of-a-sudden
+* for details.*/
+   Qt::MatchFlags const flags(Qt::MatchExactly|Qt::MatchRecursive);
+   QList twi = filesLW->findItems(item, flags);
if (!twi.isEmpty())
twi.first()->setSelected(true);
 }


[LyX/master] Fix fonts used by sub/superscript in text

2019-03-22 Thread Jean-Marc Lasgouttes
commit d52e04a9b308c0cb72c93e416a4bd59d9e8f9b39
Author: Jean-Marc Lasgouttes 
Date:   Fri Mar 22 16:13:30 2019 +0100

Fix fonts used by sub/superscript in text

Several changes are needed to get things right:
* nested supersripts only work with inheritFonts=true.

* to get caret position right, it is necessary to remember the outside
  font of the inset before computing metrics.

* to get the size right at insertion time, it is necessary to trigger
  a metrics computation just after inset insertion.
---
 src/Text3.cpp  |   10 ++
 src/insets/InsetScript.cpp |5 +++--
 src/insets/InsetScript.h   |4 +++-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/Text3.cpp b/src/Text3.cpp
index 6db9c2b..e8c3dee 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -2030,6 +2030,16 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// inside it.
doInsertInset(cur, this, cmd, true, true);
cur.posForward();
+   if (act == LFUN_SCRIPT_INSERT) {
+   /* Script insets change the font style in metrics(), and
+* this is used to compute the height of the caret
+* (because the font is stored in TextMetrics::font_).
+* When we insert, we have to make sure that metrics are
+* computed so that the caret height is wrong. Arguably,
+* this is hackish.*/
+   bv->processUpdateFlags(Update::SinglePar);
+   }
+   cur.setCurrentFont();
// Some insets are numbered, others are shown in the outline 
pane so
// let's update the labels and the toc backend.
cur.forceBufferUpdate();
diff --git a/src/insets/InsetScript.cpp b/src/insets/InsetScript.cpp
index 918492f..c7bdd42 100644
--- a/src/insets/InsetScript.cpp
+++ b/src/insets/InsetScript.cpp
@@ -160,6 +160,8 @@ Inset::DisplayType InsetScript::display() const
 void InsetScript::metrics(MetricsInfo & mi, Dimension & dim) const
 {
int const shift = params_.shift(mi.base.font);
+   // Remember the value of the outser font, so that it can be used in 
cursorPos.
+   outer_font_ = mi.base.font;
Changer dummy = mi.base.changeScript();
InsetText::metrics(mi, dim);
dim.asc -= shift;
@@ -178,8 +180,7 @@ void InsetScript::draw(PainterInfo & pi, int x, int y) const
 void InsetScript::cursorPos(BufferView const & bv,
CursorSlice const & sl, bool boundary, int & x, int & y) const
 {
-   Font const font = bv.textMetrics(&text()).displayFont(sl.pit(), 
sl.pos());
-   int const shift = params_.shift(font.fontInfo());
+   int const shift = params_.shift(outer_font_);
InsetText::cursorPos(bv, sl, boundary, x, y);
y += shift;
 }
diff --git a/src/insets/InsetScript.h b/src/insets/InsetScript.h
index 3107b62..1aee8e8 100644
--- a/src/insets/InsetScript.h
+++ b/src/insets/InsetScript.h
@@ -86,7 +86,7 @@ public:
///
bool neverIndent() const { return true; }
///
-   bool inheritFont() const { return false; }
+   bool inheritFont() const { return true; }
///
int plaintext(odocstringstream & ods, OutputParams const & op,
  size_t max_length = INT_MAX) const;
@@ -129,6 +129,8 @@ private:
friend class InsetScriptParams;
///
InsetScriptParams params_;
+   /// The font of containing inset; this is necessary to compute shift
+   mutable FontInfo outer_font_;
 };
 
 


[LyX/master] Treat math style a bit more like other font features

2019-03-22 Thread Jean-Marc Lasgouttes
commit cfb8b214d182052ee0ac2475de936273c51f2d99
Author: Jean-Marc Lasgouttes 
Date:   Fri Mar 22 15:19:27 2019 +0100

Treat math style a bit more like other font features

While math style (scriptstyle,...) is not really something that can be
set, it is useful for text subscripts and superscripts and therefore
it makes sense to handle it in some places.

With this change, style is still not a first class feature, but good
enough for now. In particular, it is taken into account in update().
---
 src/Font.cpp |5 -
 src/FontEnums.h  |4 
 src/FontInfo.cpp |   16 
 src/FontInfo.h   |4 +++-
 src/MetricsInfo.cpp  |6 ++
 src/mathed/MathClass.cpp |2 ++
 6 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/Font.cpp b/src/Font.cpp
index a920220..965a830 100644
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -154,6 +154,7 @@ docstring const stateText(FontInfo const & f, bool const 
terse)
os << _(GUIShapeNames[f.shape()]) << ", ";
if (f.size() != FONT_SIZE_INHERIT && (!terse || f.size() != 
FONT_SIZE_IGNORE))
os << _(GUISizeNames[f.size()]) << ", ";
+   // FIXME: shall style be handled there? Probably not.
if (f.color() != Color_inherit && (!terse || f.color() != Color_ignore))
os << lcolor.getGUIName(f.color()) << ", ";
// FIXME: uncomment this when we support background.
@@ -225,6 +226,7 @@ void Font::lyxWriteChanges(Font const & orgfont,
os << "\\shape " << LyXShapeNames[bits_.shape()] << "\n";
if (orgfont.fontInfo().size() != bits_.size())
os << "\\size " << LyXSizeNames[bits_.size()] << "\n";
+   // FIXME: shall style be handled there? Probably not.
if (orgfont.fontInfo().emph() != bits_.emph())
os << "\\emph " << LyXMiscNames[bits_.emph()] << "\n";
if (orgfont.fontInfo().number() != bits_.number())
@@ -662,7 +664,7 @@ bool Font::fromString(string const & data, bool & toggle)
} else if (token == "size") {
int const next = lex.getInteger();
bits_.setSize(FontSize(next));
-
+   // FIXME: shall style be handled there? Probably not.
} else if (token == "emph" || token == "underbar"
|| token == "noun" || token == "number"
|| token == "uuline" || token == "uwave"
@@ -808,6 +810,7 @@ ostream & operator<<(ostream & os, FontInfo const & f)
<< " series " << f.series()
<< " shape " << f.shape()
<< " size " << f.size()
+   << " style " << f.style()
<< " color " << f.color()
// FIXME: uncomment this when we support background.
//<< " background " << f.background()
diff --git a/src/FontEnums.h b/src/FontEnums.h
index 43d614d..dadbb98 100644
--- a/src/FontEnums.h
+++ b/src/FontEnums.h
@@ -154,6 +154,10 @@ enum MathStyle {
///
LM_ST_DISPLAY,
///
+   LM_ST_INHERIT,
+   ///
+   LM_ST_IGNORE,
+   /// the text and display fonts are the same
NUM_STYLE = LM_ST_DISPLAY
 };
 
diff --git a/src/FontInfo.cpp b/src/FontInfo.cpp
index 983499d..a813c9c 100644
--- a/src/FontInfo.cpp
+++ b/src/FontInfo.cpp
@@ -62,6 +62,7 @@ FontInfo const sane_font(
MEDIUM_SERIES,
UP_SHAPE,
FONT_SIZE_NORMAL,
+   LM_ST_TEXT,
Color_none,
Color_background,
FONT_OFF,
@@ -79,6 +80,7 @@ FontInfo const inherit_font(
INHERIT_SERIES,
INHERIT_SHAPE,
FONT_SIZE_INHERIT,
+   LM_ST_INHERIT,
Color_inherit,
Color_inherit,
FONT_INHERIT,
@@ -96,6 +98,7 @@ FontInfo const ignore_font(
IGNORE_SERIES,
IGNORE_SHAPE,
FONT_SIZE_IGNORE,
+   LM_ST_IGNORE,
Color_ignore,
Color_ignore,
FONT_IGNORE,
@@ -187,6 +190,8 @@ double FontInfo::realSize() const
switch (style()) {
case LM_ST_DISPLAY:
case LM_ST_TEXT:
+   case LM_ST_INHERIT:
+   case LM_ST_IGNORE:
break;
case LM_ST_SCRIPT:
d *= .73;
@@ -211,6 +216,8 @@ void FontInfo::reduce(FontInfo const & tmplt)
shape_ = INHERIT_SHAPE;
if (size_ == tmplt.size_)
size_ = FONT_SIZE_INHERIT;
+   if (style_ == tmplt.style_)
+   style_ = LM_ST_INHERIT;
if (emph_ == tmp

<    6   7   8   9   10   11   12   13   14   15   >