LyX version info for InsetInfo.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34186 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-04-17 13:04:41 +00:00
parent bdd586cb53
commit 49945d3fac
5 changed files with 56 additions and 5 deletions

View File

@ -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]],

View File

@ -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<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;

View File

@ -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)

View File

@ -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));
}
}

View File

@ -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
};
///