+
+
+string InsetInfoParams::infoType() const
+{
+ return nameTranslator().find(type);
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////
+//
+// InsetInfo
+//
+/////////////////////////////////////////////////////////////////////////
+
+
+
+InsetInfo::InsetInfo(Buffer * buf, string const & info)
+ : InsetCollapsible(buf), initialized_(false)
+{
+ params_.type = InsetInfoParams::UNKNOWN_INFO;
+ params_.force_ltr = false;
+ setInfo(info);
+ status_ = Collapsed;
+}
+
+
+Inset * InsetInfo::editXY(Cursor & cur, int x, int y)
+{
+ // do not allow the cursor to be set in this Inset
+ return Inset::editXY(cur, x, y);
+}
+
+
+docstring InsetInfo::layoutName() const
+{
+ return from_ascii("Info:" + params_.infoType());
+}
+
+
+docstring InsetInfo::toolTip(BufferView const &, int, int) const
+{
+ docstring result;
+ switch (nameTranslator().find(params_.infoType())) {
+ case InsetInfoParams::UNKNOWN_INFO:
+ result = _("Invalid information inset");
+ break;
+ case InsetInfoParams::SHORTCUT_INFO:
+ result = bformat(_("The keybard shortcut for the function '%1$s'"),
+ from_utf8(params_.name));
+ break;
+ case InsetInfoParams::SHORTCUTS_INFO:
+ result = bformat(_("The keybard shortcuts for the function '%1$s'"),
+ from_utf8(params_.name));
+ break;
+ case InsetInfoParams::MENU_INFO:
+ result = bformat(_("The menu location for the function '%1$s'"),
+ from_utf8(params_.name));
+ break;
+ case InsetInfoParams::L7N_INFO:
+ result = bformat(_("The localization for the string '%1$s'"),
+ from_utf8(params_.name));
+ break;
+ case InsetInfoParams::ICON_INFO:
+ result = bformat(_("The toolbar icon for the function '%1$s'"),
+ from_utf8(params_.name));
+ break;
+ case InsetInfoParams::LYXRC_INFO:
+ result = bformat(_("The preference setting for the preference key '%1$s'"),
+ from_utf8(params_.name));
+ break;
+ case InsetInfoParams::PACKAGE_INFO:
+ result = bformat(_("Availability of the LaTeX package '%1$s'"),
+ from_utf8(params_.name));
+ break;
+ case InsetInfoParams::TEXTCLASS_INFO:
+ result = bformat(_("Availability of the LaTeX class '%1$s'"),
+ from_utf8(params_.name));
+ break;
+ case InsetInfoParams::BUFFER_INFO:
+ if (params_.name == "name")
+ result = _("The name of this file (incl. extension)");
+ else if (params_.name == "name-noext")
+ result = _("The name of this file (without extension)");
+ else if (params_.name == "path")
+ result = _("The path where this file is saved");
+ else if (params_.name == "class")
+ result = _("The class this document uses");
+ break;
+ case InsetInfoParams::VCS_INFO:
+ if (params_.name == "revision")
+ result = _("Version control revision");
+ else if (params_.name == "revision-abbrev")
+ result = _("Version control abbreviated revision");
+ else if (params_.name == "tree-revision")
+ result = _("Version control tree revision");
+ else if (params_.name == "author")
+ result = _("Version control author");
+ else if (params_.name == "date")
+ result = _("Version control date");
+ else if (params_.name == "time")
+ result = _("Version control time");
+ break;
+ case InsetInfoParams::LYX_INFO:
+ 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");
+ break;
+ case InsetInfoParams::MODDATE_INFO:
+ result = _("The date of last save");
+ break;
+ case InsetInfoParams::FIXDATE_INFO:
+ result = _("A static date");
+ break;
+ case InsetInfoParams::TIME_INFO:
+ result = _("The current time");
+ break;
+ case InsetInfoParams::MODTIME_INFO:
+ result = _("The time of last save");
+ break;
+ case InsetInfoParams::FIXTIME_INFO:
+ result = _("A static time");
+ break;
+ }
+
+ return result;
+}
+
+
+void InsetInfo::read(Lexer & lex)
+{
+ string token;
+ while (lex.isOK()) {
+ lex.next();
+ token = lex.getString();
+ if (token == "type") {
+ lex.next();
+ token = lex.getString();
+ params_.type = nameTranslator().find(token);
+ } else if (token == "arg") {
+ lex.next(true);
+ params_.name = lex.getString();
+ } else if (token == "\\end_inset")
+ break;
+ }
+ if (token != "\\end_inset") {
+ lex.printError("Missing \\end_inset at this point");
+ throw ExceptionMessage(WarningException,
+ _("Missing \\end_inset at this point."),
+ from_utf8(token));
+ }
+}
+
+
+void InsetInfo::write(ostream & os) const
+{
+ os << "Info\ntype \"" << params_.infoType()
+ << "\"\narg " << Lexer::quoteString(params_.name);
+}
+
+