]> git.lyx.org Git - lyx.git/commitdiff
Split vcs Info inset from buffer Info inset
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 29 Jul 2018 17:41:34 +0000 (19:41 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 29 Jul 2018 17:41:34 +0000 (19:41 +0200)
This should go separately in the GUI, and thus in the inset.

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

index edab9cb82dcddf5252dda9f8bcff42e0dc41a473..3c77ed4183cbe9c2595f8676aa48e99da69dbda6 100644 (file)
@@ -7,6 +7,9 @@ changes happened in particular if possible. A good example would be
 
 -----------------------
 
+2018-07-29  Jürgen Spitzmüller <spitz@lyx.org>
+       * format incremented to 557: Separate vcs Info inset from buffer Info inset.
+
 2018-07-07  Jürgen Spitzmüller <spitz@lyx.org>
        * format incremented to 556: Support for bib file encoding.
           - New param "encoding" for CommandInset bibtex
index c00e63014844f4589ee8232342bc2be5ea1c646a..8bf0dc17bfd7d90b060434c225db943b079f7067 100644 (file)
@@ -537,6 +537,72 @@ def revert_bibencoding(document):
         i = j + 1
 
 
+
+def convert_vcsinfo(document):
+    " Separate vcs Info inset from buffer Info inset. "
+
+    types = {
+        "vcs-revision" : "revision",
+        "vcs-tree-revision" : "tree-revision",
+        "vcs-author" : "author",
+        "vcs-time" : "time",
+        "vcs-date" : "date"
+    }
+    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 != "buffer":
+            i = i + 1
+            continue
+        arg = find_token(document.body, 'arg', i, j)
+        argv = get_quoted_value(document.body, "arg", arg)
+        if argv not in list(types.keys()):
+            i = i + 1
+            continue
+        document.body[tp] = "type \"vcs\""
+        document.body[arg] = "arg \"" + types[argv] + "\""
+        i = i + 1
+
+
+def revert_vcsinfo(document):
+    " Merge vcs Info inset to buffer Info inset. "
+
+    args = ["revision", "tree-revision", "author", "time", "date" ]
+    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 != "vcs":
+            i = i + 1
+            continue
+        arg = find_token(document.body, 'arg', i, j)
+        argv = get_quoted_value(document.body, "arg", arg)
+        if argv not in args:
+            document.warning("Malformed Info inset. Invalid vcs arg.")
+            i = i + 1
+            continue
+        document.body[tp] = "type \"buffer\""
+        document.body[arg] = "arg \"vcs-" + argv + "\""
+        i = i + 1
+
+
 ##
 # Conversion hub
 #
@@ -554,10 +620,12 @@ convert = [
            [553, []],
            [554, []],
            [555, []],
-           [556, []]
+           [556, []],
+           [557, [convert_vcsinfo]]
           ]
 
 revert =  [
+           [556, [revert_vcsinfo]],
            [555, [revert_bibencoding]],
            [554, [revert_vcolumns]],
            [553, [revert_stretchcolumn]],
index 2ba2ec645b9e06bab55665d199f3d63921194ddb..cafcca8634f7a69b54a04c65d784cb96af68bfa0 100644 (file)
@@ -40,16 +40,18 @@ namespace frontend {
 /////////////////////////////////////////////////////////////////
 
 char const * info_types[] =
-{ "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "lyxinfo", "" };
+{ "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "vcs", "lyxinfo", "" };
 
 char const * info_types_gui[] =
 { N_("Unknown"), N_("Last Assigned Keyboard Shortcut"), N_("All Keyboard Shortcuts"),
   N_("LyX Preferences Entry"),  N_("LaTeX Package Availability"), N_("LaTeX Class Availability"),
-  N_("LyX Menu Location"), N_("LyX Toolbar Icon"), N_("Document Information"), N_("LyX Application Information"), ""};
+  N_("LyX Menu Location"), N_("LyX Toolbar Icon"), N_("Document Information"),
+  N_("Version Control Information"), N_("LyX Application Information"), ""};
 
 char const * info_name_gui[] =
 { N_("Not Applicable"), N_("LyX Function"), N_("LyX Function"), N_("Preferences Key"),  N_("Package Name"),
-  N_("Class Name"), N_("LyX Function"), N_("LyX Function"), N_("Information Type"), N_("Information Type"), ""};
+  N_("Class Name"), N_("LyX Function"), N_("LyX Function"), N_("Information"),
+  N_("Information"), N_("Information"), ""};
 
 char const * info_tooltip[] =
 { N_("Please select a valid type above"),
@@ -68,6 +70,7 @@ char const * info_tooltip[] =
   N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
      "The output is the toolbar icon for this function (using the active icon theme)."),
   N_("Enter either 'name' (outputs the filename of the current document), 'path' (outputs the file path), or 'class' (outputs the text class)."),
+  N_("Enter either 'revision', 'tree-revision', 'author', 'time' or 'date'. If available, the respective version control information is output."),
   N_("Currently supported information type: 'version' (outputs the current LyX version)."),
   ""};
 
index 3da1d004701be145236d8d195f6affcc4182864a..403ba10dec3d23770a6a8993b7dbced6dcd18187 100644 (file)
@@ -75,6 +75,7 @@ NameTranslator const initTranslator()
        translator.addPair(InsetInfo::ICON_INFO, "icon");
        translator.addPair(InsetInfo::BUFFER_INFO, "buffer");
        translator.addPair(InsetInfo::LYX_INFO, "lyxinfo");
+       translator.addPair(InsetInfo::VCS_INFO, "vcs");
 
        return translator;
 }
@@ -166,15 +167,17 @@ docstring InsetInfo::toolTip(BufferView const &, int, int) const
                        result = _("The path were this file is saved");
                else if (name_ == "class")
                        result = _("The class this document uses");
-               else if (name_ == "vcs-revision")
+               break;
+       case VCS_INFO:
+               if (name_ == "revision")
                        result = _("Version control revision");
-               else if (name_ == "vcs-tree-revision")
+               else if (name_ == "tree-revision")
                        result = _("Version control tree revision");
-               else if (name_ == "vcs-author")
+               else if (name_ == "author")
                         result = _("Version control author");
-                else if (name_ == "vcs-date")
+               else if (name_ == "date")
                        result = _("Version control date");
-               else if (name_ == "vcs-time")
+               else if (name_ == "time")
                        result = _("Version control time");
                break;
        case LYX_INFO:
@@ -254,10 +257,11 @@ bool InsetInfo::validateModifyArgument(docstring const & arg) const
                return true;
 
        case BUFFER_INFO:
-               if (name == "name" || name == "path" || name == "class")
-                       return true;
-               if (name == "vcs-revision" || name == "vcs-tree-revision" ||
-                      name == "vcs-author" || name == "vcs-date" || name == "vcs-time")
+               return (name == "name" || name == "path" || name == "class");
+
+       case VCS_INFO:
+               if (name == "revision" || name == "tree-revision"
+                   || name == "author" || name == "date" || name == "time")
                        return buffer().lyxvc().inUse();
                return false;
 
@@ -579,23 +583,15 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
        }
        case BUFFER_INFO: {
                // this could all change, so we will recalculate each time
-               if (name_ == "name") {
+               if (name_ == "name")
                        setText(from_utf8(buffer().fileName().onlyFileName()), lang);
-                       break;
-               }
-               if (name_ == "path") {
+               else if (name_ == "path")
                        setText(from_utf8(os::latex_path(buffer().filePath())), lang);
-                       break;
-               }
-               if (name_ == "class") {
+               else if (name_ == "class")
                        setText(from_utf8(bp.documentClass().name()), lang);
-                       break;
-               }
-
-               ////////////////////////////////////////////////////////////////
-               // everything that follows is for version control.
-               // nothing that isn't version control should go below this line.
-               
+               break;
+       }
+       case VCS_INFO: {
                // this information could change, in principle, so we will 
                // recalculate each time through
                if (!buffer().lyxvc().inUse()) {
@@ -604,15 +600,15 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
                        break;
                }
                LyXVC::RevisionInfo itype = LyXVC::Unknown;
-               if (name_ == "vcs-revision")
+               if (name_ == "revision")
                        itype = LyXVC::File;
-               else if (name_ == "vcs-tree-revision")
+               else if (name_ == "tree-revision")
                        itype = LyXVC::Tree;
-               else if (name_ == "vcs-author")
+               else if (name_ == "author")
                        itype = LyXVC::Author;
-               else if (name_ == "vcs-time")
+               else if (name_ == "time")
                        itype = LyXVC::Time;
-               else if (name_ == "vcs-date")
+               else if (name_ == "date")
                        itype = LyXVC::Date;
                string binfo = buffer().lyxvc().revisionInfo(itype);
                if (binfo.empty()) {
index c5530629522d977aaca5a15fa5da933be8882733..4a4bf89d4d711d04b68b8a4fdf38c3ca1d5fcbba 100644 (file)
@@ -30,7 +30,7 @@ uses it to display currently used shortcuts.
 This inset has two arguments: the type and argument of the information. The
 screen and latex output is the content of the information. An InsetInfo can
 have type "shortcuts", "shortcut", "lyxrc", "package", "textclass", "menu",
-or "buffer". Arguments and outputs vary by type.
+"buffer" or "vcs". Arguments and outputs vary by type.
 
 shortcuts: argument of this type of InsetInfo is the name of the LFUN such as
     "math-insert \alpha". The syntax is the same as what is used in the bind
@@ -63,7 +63,10 @@ buffer: argument can be one of "name", "path", "class". This inset output the
     filename, path, and textclass of this buffer.
 
 lyxinfo: argument must (presently) be "version". This inset outputs information
-               about the version of LyX currently in use.
+    about the version of LyX currently in use.
+
+vcs: argument can be one of "revision", "tree-revision", "author", "time", "date".
+    This insets outputs revision control information, if available.
 
 There is currently no GUI, no menu entry for this inset. A user can define a
 shortcut for "info-insert" (e.g. C-S-I), and
@@ -89,7 +92,8 @@ public:
                MENU_INFO,      // Which menu item is used for certain function
                ICON_INFO,      // which toolbar icon is used for certain function
                BUFFER_INFO,    // Buffer related information
-               LYX_INFO        // LyX version information
+               LYX_INFO,        // LyX version information
+               VCS_INFO,        // Version control information
        };
 
        ///
index e8ca1534731e42a867219f47a1965f1cf9a5a788..ce168b3d1708873b05389d7ecc2871ec3610b281 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 556 // spitz: bib encoding
-#define LYX_FORMAT_TEX2LYX 556
+#define LYX_FORMAT_LYX 557 // spitz: separate vcs info inset
+#define LYX_FORMAT_TEX2LYX 557
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER