]> git.lyx.org Git - lyx.git/commitdiff
Implement layout format in insetinfo
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 20 Sep 2018 09:33:03 +0000 (11:33 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 20 Sep 2018 09:33:03 +0000 (11:33 +0200)
The docs refer to the outdated layout formats. The inset prevents this.

development/FORMAT
lib/lyx2lyx/lyx_2_4.py
src/insets/InsetInfo.cpp
src/insets/InsetInfo.h
src/version.h

index e54fddbadc60681a27732c236024b325c6344710..251e00ec09bed5f829b3ce424493f17d9be08f16 100644 (file)
@@ -8,6 +8,10 @@ changes happened in particular if possible. A good example would be
 -----------------------
 
 
+2018-09-20  Jürgen Spitzmüller <spitz@lyx.org>
+       * format incremented to 564: New info-inset lyxinfo subtype layoutformat. This returns
+          the current layout format.
+
 2018-08-16  Jürgen Spitzmüller <spitz@lyx.org>
        * format incremented to 563: New inset argument type "listpreamble". The content will
           be inserted between environment begin and first \item of a list.
index eb7aa4e52096e3a560cf38d431d59e057a3f1a94..13a95cf17dfaeed42fdfbd6181ac7b60e6fbf2a0 100644 (file)
@@ -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
index e712a7564d14f803f861663c6d38a8d422f82fd1..bb7f3af98e8ffd407cdf45099628a7749574f323 100644 (file)
@@ -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:
index 811153afb048a08d2071d0edd566349d2a0c2e75..2f1b65153b956efae0ea87af343fed3112b71bc3 100644 (file)
@@ -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.
index 452cec320373d3b062da88307edaff64691ddb27..7634a2a33283816d19953ecb2d95394d3673cbcd 100644 (file)
@@ -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