From: Richard Heck Date: Sat, 17 Apr 2010 13:04:41 +0000 (+0000) Subject: LyX version info for InsetInfo. X-Git-Tag: 2.0.0~3434 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=49945d3fac0b580a24f328e3429103a158618a6a;p=features.git LyX version info for InsetInfo. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34186 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index d7f00c8e80..f520446406 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -22,6 +22,7 @@ import re, string import unicodedata import sys, os +import lyx2lyx_version from parser_tools import find_token, find_end_of, find_tokens, get_value, get_value_string @@ -1466,6 +1467,44 @@ def revert_shadedboxcolor(document): + ', ' + str(blueout) + '}\n') +def revert_lyx_version(document): + " Reverts LyX Version information from Inset Info " + i = 0 + while 1: + 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: + # should not happen + document.warning("Malformed LyX document: Could not find end of Info inset.") + # We expect: + # \begin_inset Info + # type "lyxinfo" + # arg "version" + # \end_inset + # but we shall try to be forgiving. + arg = typ = "" + for k in range(i, j): + if document.body[k].startswith("arg"): + arg = document.body[k][3:].strip().strip('"') + if document.body[k].startswith("type"): + typ = document.body[k][4:].strip().strip('"') + if arg != "version" or typ != "lyxinfo": + i = j+1 + continue + # We do not actually know the version of LyX used to produce the document. + # But we can use our version, since we are reverting. + s = [lyx2lyx_version.version] + # Now we want to check if the line after "\end_inset" is empty. It normally + # is, so we want to remove it, too. + lastline = j+1 + if document.body[j+1].strip() == "": + lastline = j+2 + document.body[i: lastline] = s + i = i+1 + + ## # Conversion hub # @@ -1510,10 +1549,12 @@ convert = [[346, []], [382, []], [383, []], [384, []], - [385, []] + [385, []], + [386, []] ] -revert = [[384, [revert_shadedboxcolor]], +revert = [[385, [revert_lyx_version]], + [384, [revert_shadedboxcolor]], [383, [revert_fontcolor]], [382, [revert_turkmen]], [381, [revert_notefontcolor]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index fa98e36958..b0688cb318 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -126,7 +126,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 385; // uwestoehr: support to change the shaded box color +int const LYX_FORMAT = 386; // rgh: LyX version for InsetInfo typedef map DepClean; typedef map > RefCache; diff --git a/src/frontends/qt4/GuiInfo.cpp b/src/frontends/qt4/GuiInfo.cpp index db7efb5d65..9147638961 100644 --- a/src/frontends/qt4/GuiInfo.cpp +++ b/src/frontends/qt4/GuiInfo.cpp @@ -40,11 +40,11 @@ namespace frontend { ///////////////////////////////////////////////////////////////// char const * info_types[] = -{ "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "" }; +{ "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "lyxinfo", "" }; char const * info_types_gui[] = { N_("unknown"), N_("shortcut"), N_("shortcuts"), N_("lyxrc"), N_("package"), N_("textclass"), - N_("menu"), N_("icon"), N_("buffer"), ""}; + N_("menu"), N_("icon"), N_("buffer"), N_("lyxinfo"), ""}; GuiInfo::GuiInfo(QWidget * parent) : InsetParamsWidget(parent) diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index bf9bdda93b..62e2f663cd 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -61,6 +61,7 @@ NameTranslator const initTranslator() translator.addPair(InsetInfo::MENU_INFO, "menu"); translator.addPair(InsetInfo::ICON_INFO, "icon"); translator.addPair(InsetInfo::BUFFER_INFO, "buffer"); + translator.addPair(InsetInfo::LYX_INFO, "lyxinfo"); return translator; } @@ -176,6 +177,8 @@ bool InsetInfo::validateModifyArgument(docstring const & arg) const return name == "name" || name == "path" || name == "class" || name == "vcs-revision" || name == "vcs-tree-revision" || name == "vcs-author" || name == "vcs-date" || name == "vcs-time"; + case LYX_INFO: + return name == "version"; } return false; } @@ -385,6 +388,9 @@ void InsetInfo::updateInfo() setText(_("Unknown buffer info")); break; } + case LYX_INFO: + if (name_ == "version") + setText(from_ascii(PACKAGE_VERSION)); } } diff --git a/src/insets/InsetInfo.h b/src/insets/InsetInfo.h index ebe987b9cc..6bcd8ed4d0 100644 --- a/src/insets/InsetInfo.h +++ b/src/insets/InsetInfo.h @@ -60,6 +60,9 @@ icon: argument is the name of the LFUN such as "paste". The syntax is the same 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. 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 @@ -87,6 +90,7 @@ 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 }; ///