4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
15 #include "InsetCollapsible.h"
21 /* InsetInfo displays shortcuts, lyxrc, package and textclass
22 availability and menu information in a non-editable boxed InsetText.
24 Output of such an inset may vary from system to system, depending
25 on LyX and LaTeX configurations. Two LyX help files, LaTeXConfig.lyx
26 and Shortcuts.lyx make heavy use of this inset. The former uses it
27 to display the availability of packages and textclasses, the latter
28 uses it to display currently used shortcuts.
30 This inset has two arguments: the type and argument of the information. The
31 screen and latex output is the content of the information. An InsetInfo can
32 have type "shortcuts", "shortcut", "lyxrc", "package", "textclass", "menu",
33 "buffer" or "vcs". Arguments and outputs vary by type.
35 shortcuts: argument of this type of InsetInfo is the name of the LFUN such as
36 "math-insert \alpha". The syntax is the same as what is used in the bind
37 and ui files. The output of this inset is all shortcuts for this LFUN
40 shortcut: the same as shortcuts, but only output the last shortcut.
42 lyxrc: argument is the name of the rc entry such as "bind_file". Look in
43 src/LyXRC.h for available entries. The output is the content of this RC
46 package: argument is the name of a latex package such as "listings". The
47 output is "yes" or "no", indicating the availability of this package.
49 textclass: argument is the name a textclass such as "article". The output is
50 "yes" or "no", indicating the availability of this textclass.
52 menu: argument is the name of the LFUN such as "paste". The syntax is the same
53 as what is used in the bind and ui files. The output is the menu item that
54 triggers this LFUN. For example, "File > Paste", where '>' is actually
55 \lyxarrow (an InsetSpecialChar).
57 icon: argument is the name of the LFUN such as "paste". The syntax is the same
58 as what is used in the bind and ui files. The output is the icon use in
59 the toolbar for this LFUN. Alternatively, argument can be the icon path
60 without extension specified with respect to the images directory.
62 buffer: argument can be one of "name", "path", "class". This inset output the
63 filename, path, and textclass of this buffer.
65 lyxinfo: argument must (presently) be "version". This inset outputs information
66 about the version of LyX currently in use.
68 vcs: argument can be one of "revision", "tree-revision", "author", "time", "date".
69 This insets outputs revision control information, if available.
71 There is currently no GUI, no menu entry for this inset. A user can define a
72 shortcut for "info-insert" (e.g. C-S-I), and
74 1. input the type and argument of this inset, e.g. "menu paste", in
76 2. select the text and run "info-insert" (e.g. press C-S-I).
78 An alternative method is to enter command "info-insert type arg" in
79 the command buffer (view->Toolbar->Command Buffer).
83 class InsetInfo : public InsetCollapsible {
86 BUFFER_INFO, // Buffer related information
87 VCS_INFO, // Version control information
88 PACKAGE_INFO, // Availability of package
89 TEXTCLASS_INFO, // Availability of textclass
90 SHORTCUTS_INFO, // Keyboard shortcuts
91 SHORTCUT_INFO, // Keyboard shortcut
92 LYXRC_INFO, // RC entry
93 MENU_INFO, // Which menu item is used for certain function
94 ICON_INFO, // which toolbar icon is used for certain function
95 LYX_INFO, // LyX version information
96 UNKNOWN_INFO, // Invalid type
100 InsetInfo(Buffer * buf, std::string const & info = std::string());
102 InsetCode lyxCode() const { return INFO_CODE; }
104 docstring layoutName() const;
106 Inset * editXY(Cursor & cur, int x, int y);
107 /** FIXME: we would like to do that, but then InsetText::updateBuffer breaks
108 * on info insets. Do we need to run this method on InsetInfo contents?
109 * Having a InsetInfo that hides an InsetText is really annoying, actually.
111 ///bool isActive() const { return false; }
113 bool editable() const { return false; }
115 bool hasSettings() const { return true; }
117 void read(Lexer & lex);
119 void write(std::ostream & os) const;
121 std::string infoType() const;
123 std::string infoName() const { return name_; }
125 bool validateModifyArgument(docstring const & argument) const;
127 std::vector<std::pair<std::string,docstring>> getArguments(std::string const &) const;
129 bool showInsetDialog(BufferView * bv) const;
131 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
133 void doDispatch(Cursor & cur, FuncRequest & cmd);
134 /// Force inset into LTR environment if surroundings are RTL
135 bool forceLTR() const;
137 void setInfo(std::string const & info);
139 void updateBuffer(ParIterator const & it, UpdateType utype);
141 docstring toolTip(BufferView const & bv, int x, int y) const;
143 std::string contextMenu(BufferView const &, int, int) const;
145 std::string contextMenuName() const;
146 /// should paragraph indendation be omitted in any case?
147 bool neverIndent() const { return true; }
151 virtual Inset * clone() const { return new InsetInfo(*this); }
153 void error(docstring const & err, Language const *);
155 void info(docstring const & err, Language const *);
157 void setText(docstring const & str, Language const *);
158 // make sure that the other version of setText is still available.
159 using InsetCollapsible::setText;