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
+ ', ' + 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
#
[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]],
// 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;
/////////////////////////////////////////////////////////////////
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)
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;
}
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;
}
setText(_("Unknown buffer info"));
break;
}
+ case LYX_INFO:
+ if (name_ == "version")
+ setText(from_ascii(PACKAGE_VERSION));
}
}
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
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
};
///