commit 5e26a3a63369205d75c89562c836dbe8b402da86
Author: Juergen Spitzmueller <[email protected]>
Date: Thu Sep 20 11:33:03 2018 +0200
Implement layout format in insetinfo
The docs refer to the outdated layout formats. The inset prevents this.
---
development/FORMAT | 4 ++++
lib/lyx2lyx/lyx_2_4.py | 32 +++++++++++++++++++++++++++++++-
src/insets/InsetInfo.cpp | 10 ++++++++--
src/insets/InsetInfo.h | 4 ++--
src/version.h | 4 ++--
5 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/development/FORMAT b/development/FORMAT
index e54fddb..251e00e 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -8,6 +8,10 @@ changes happened in particular if possible. A good example
would be
-----------------------
+2018-09-20 Jürgen Spitzmüller <[email protected]>
+ * format incremented to 564: New info-inset lyxinfo subtype
layoutformat. This returns
+ the current layout format.
+
2018-08-16 Jürgen Spitzmüller <[email protected]>
* format incremented to 563: New inset argument type "listpreamble".
The content will
be inserted between environment begin and first \item of a list.
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index eb7aa4e..13a95cf 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -1330,6 +1330,34 @@ def revert_listpargs(document):
i += 1
+def revert_lformatinfo(document):
+ " Revert layout format Info inset to text. "
+
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset Info", i)
+ if i == -1:
+ return
+ j = find_end_of_inset(document.body, i + 1)
+ if j == -1:
+ document.warning("Malformed LyX document: Could not find end of
Info inset.")
+ i = i + 1
+ continue
+ tp = find_token(document.body, 'type', i, j)
+ tpv = get_quoted_value(document.body, "type", tp)
+ if tpv != "lyxinfo":
+ i = i + 1
+ continue
+ arg = find_token(document.body, 'arg', i, j)
+ argv = get_quoted_value(document.body, "arg", arg)
+ if argv != "layoutformat":
+ i = i + 1
+ continue
+ # hardcoded for now
+ document.body[i : j+1] = "69"
+ i = i + 1
+
+
##
# Conversion hub
#
@@ -1354,10 +1382,12 @@ convert = [
[560, []],
[561, [convert_latexFonts]], # Handle dejavu, ibmplex fonts in GUI
[562, []],
- [563, []]
+ [563, []],
+ [564, []]
]
revert = [
+ [563, [revert_lformatinfo]],
[562, [revert_listpargs]],
[561, [revert_l7ninfo]],
[560, [revert_latexFonts]], # Handle dejavu, ibmplex fonts in user
preamble
diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp
index e712a75..bb7f3af 100644
--- a/src/insets/InsetInfo.cpp
+++ b/src/insets/InsetInfo.cpp
@@ -281,6 +281,7 @@ vector<pair<string,docstring>>
InsetInfoParams::getArguments(Buffer const * buf,
case LYX_INFO:
result.push_back(make_pair("version", _("LyX version")));
+ result.push_back(make_pair("layoutformat", _("LyX layout
format")));
break;
case FIXDATE_INFO:
@@ -384,7 +385,7 @@ bool InsetInfoParams::validateArgument(Buffer const * buf,
docstring const & arg
return false;
case LYX_INFO:
- return name == "version";
+ return name == "version" || name == "layoutformat";
case FIXDATE_INFO: {
string date;
@@ -532,7 +533,10 @@ docstring InsetInfo::toolTip(BufferView const &, int, int)
const
result = _("Version control time");
break;
case InsetInfoParams::LYX_INFO:
- result = _("The current LyX version");
+ if (params_.name == "version")
+ result = _("The current LyX version");
+ else if (params_.name == "layoutformat")
+ result = _("The current LyX layout format");
break;
case InsetInfoParams::DATE_INFO:
result = _("The current date");
@@ -1084,6 +1088,8 @@ void InsetInfo::updateBuffer(ParIterator const & it,
UpdateType utype) {
break;
if (params_.name == "version")
setText(from_ascii(lyx_version), params_.lang);
+ else if (params_.name == "layoutformat")
+ setText(convert<docstring>(LAYOUT_FORMAT),
params_.lang);
initialized_ = true;
break;
case InsetInfoParams::DATE_INFO:
diff --git a/src/insets/InsetInfo.h b/src/insets/InsetInfo.h
index 811153a..2f1b651 100644
--- a/src/insets/InsetInfo.h
+++ b/src/insets/InsetInfo.h
@@ -98,8 +98,8 @@ icon: argument is the name of the LFUN such as "paste". The
syntax is the same
buffer: argument can be one of "name", "name-noext", "path", "class". This
inset output the
filename (with extension), filename (without extension), path, and
textclass of this buffer.
-lyxinfo: argument must (presently) be "version". This inset outputs information
- about the version of LyX currently in use.
+lyxinfo: argument must be "version" or "layoutformat". This outputs information
+ about the version of LyX currently in use or the current LyX layout
format, respectively.
vcs: argument can be one of "revision", "tree-revision", "author", "time",
"date".
This insets outputs revision control information, if available.
diff --git a/src/version.h b/src/version.h
index 452cec3..7634a2a 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 563 // spitz: listpreamble arguments
-#define LYX_FORMAT_TEX2LYX 563
+#define LYX_FORMAT_LYX 564 // spitz: layoutformat info inset
+#define LYX_FORMAT_TEX2LYX 564
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER