[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::ignoreSectioning = false;
-bool IgnoreFormats::ignoreFrontMatter= true;
-bool IgnoreFormats::ignoreColor  = 

[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] FindAdv: Polishing

2018-11-09 Thread Kornel Benko
commit f5d5777a86238296b2bfaf09d4a610ed43072cd3
Author: Kornel Benko 
Date:   Fri Nov 9 13:36:47 2018 +0100

FindAdv: Polishing

1.) Added \textmd to be ignored (sometimes it is used and sometimes not)
2.) Typo: multiline --> multline. Searching in 'multline' caused a crash
because processing all of the '{' and '}' in the content of this math
exceeded the size of the interval field.
---
 src/lyxfind.cpp |   29 +++--
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index b547df9..85e2d3b 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -846,7 +846,7 @@ static size_t identifyLeading(string const & s)
// @TODO Support \item[text]
// Kornel: Added textsl, textsf, textit, texttt and noun
// + allow to search for colored text too
-   while (regex_replace(t, t, REGEX_BOS 
"(((emph|noun|minisec|text(bf|sl|sf|it|tt))|((textcolor|foreignlanguage)\\{[a-z]+\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)\\{",
 "")
+   while (regex_replace(t, t, REGEX_BOS 
"(((emph|noun|minisec|text(bf|md|sl|sf|it|tt))|((textcolor|foreignlanguage)\\{[a-z]+\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)\\{",
 "")
   || regex_replace(t, t, REGEX_BOS "\\$", "")
   || regex_replace(t, t, REGEX_BOS "\\[ ", "")
   || regex_replace(t, t, REGEX_BOS " ?item\\{[a-z]+\\}", "")
@@ -868,7 +868,7 @@ typedef map Features;
 static Features identifyFeatures(string const & s)
 {
static regex const feature("(([a-z]+(\\{([a-z]+)\\}|\\*)?))\\{");
-   static regex const 
valid("^(((emph|noun|text(bf|sl|sf|it|tt)|(textcolor|foreignlanguage|item)\\{[a-z]+\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)$");
+   static regex const 
valid("^(((emph|noun|text(bf|md|sl|sf|it|tt)|(textcolor|foreignlanguage|item)\\{[a-z]+\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)$");
smatch sub;
bool displ = true;
Features info;
@@ -1349,7 +1349,7 @@ class MathInfo {
 
 void LatexInfo::buildEntries(bool isPatternString)
 {
-  static regex const 
rmath("\\$|\\[|\\]|(begin|end)\\{((eqnarray|equation|flalign|gather|multiline|align)\\*?)\\}");
+  static regex const 
rmath("\\$|\\[|\\]|(begin|end)\\{((eqnarray|equation|flalign|gather|multline|align)\\*?)\\}");
   static regex const 
rkeys("\\$|\\[|\\]|((([a-zA-Z]+\\*?)(\\{([a-z]+\\*?)\\}|=[0-9]+[a-z]+)?))");
   static bool disableLanguageOverride = false;
   smatch sub, submath;
@@ -1365,23 +1365,24 @@ void LatexInfo::buildEntries(bool isPatternString)
 submath = *itmath;
 if (math_end_waiting) {
   size_t pos = submath.position(size_t(0));
-  if (math_end == "$") {
-if ((submath.str(0) == "$") && (interval.par[pos-1] != '\\')) {
-  mi.insert("$", math_pos, pos + 1);
-  math_end_waiting = false;
-}
+  if ((math_end == "$") &&
+  (submath.str(0) == "$") &&
+  (interval.par[pos-1] != '\\')) {
+mi.insert("$", math_pos, pos + 1);
+math_end_waiting = false;
   }
-  else if (math_end == "\\]") {
-if (submath.str(0) == "\\]") {
-  mi.insert("\\]", math_pos, pos + 2);
-  math_end_waiting = false;
-}
+  else if ((math_end == "\\]") &&
+   (submath.str(0) == "\\]")) {
+mi.insert("\\]", math_pos, pos + 2);
+math_end_waiting = false;
   }
   else if ((submath.str(1).compare("end") == 0) &&
   (submath.str(2).compare(math_end) == 0)) {
 mi.insert(math_end, math_pos, pos + submath.str(0).length());
 math_end_waiting = false;
   }
+  else
+continue;
 }
 else {
   if (submath.str(1).compare("begin") == 0) {
@@ -1610,7 +1611,7 @@ void LatexInfo::buildKeys(bool isPatternString)
 
   // Macros to remove, but let the parameter survive
   // No split
-  makeKey("url|href|menuitem|footnote|code|index", 
KeyInfo(KeyInfo::isStandard, 1, true), isPatternString);
+  makeKey("url|href|menuitem|footnote|code|index|textmd", 
KeyInfo(KeyInfo::isStandard, 1, true), isPatternString);
 
   // Same effect as previous, parameter will survive (because there is no one 
anyway)
   // No split


[LyX/master] missed this.

2018-11-09 Thread Juergen Spitzmueller
commit 523d284729312376609e8b239b16e434c156da2a
Author: Juergen Spitzmueller 
Date:   Fri Nov 9 11:47:51 2018 +0100

missed this.
---
 src/insets/InsetInfo.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp
index 52d98e3..d6c68ed 100644
--- a/src/insets/InsetInfo.cpp
+++ b/src/insets/InsetInfo.cpp
@@ -157,7 +157,7 @@ set getTexFileList(string const & filename)
 
// Normalise paths like /foo//bar ==> /foo/bar
for (auto doc : doclist) {
-   subst(doc, from_ascii("\r"), docstring());
+   doc = subst(doc, from_ascii("\r"), docstring());
while (contains(doc, from_ascii("//")))
doc = subst(doc, from_ascii("//"), from_ascii("/"));
if (!doc.empty())


[LyX/master] Fix thinko

2018-11-09 Thread Juergen Spitzmueller
commit a5004a394abf1eb64a6524b7e1c31795cfa71f80
Author: Juergen Spitzmueller 
Date:   Fri Nov 9 11:28:38 2018 +0100

Fix thinko

Actually use the replaced path string :-/
---
 src/insets/InsetInfo.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp
index bb7f3af..52d98e3 100644
--- a/src/insets/InsetInfo.cpp
+++ b/src/insets/InsetInfo.cpp
@@ -159,7 +159,7 @@ set getTexFileList(string const & filename)
for (auto doc : doclist) {
subst(doc, from_ascii("\r"), docstring());
while (contains(doc, from_ascii("//")))
-   subst(doc, from_ascii("//"), from_ascii("/"));
+   doc = subst(doc, from_ascii("//"), from_ascii("/"));
if (!doc.empty())

list.insert(removeExtension(onlyFileName(to_utf8(doc;
}