]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInfo.h
Compile fix.
[lyx.git] / src / insets / InsetInfo.h
1 // -*- C++ -*-
2 /**
3  * \file InsetInfo.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Bo Peng
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_INFO_H
13 #define INSET_INFO_H
14
15 #include "InsetCollapsable.h"
16 #include "Cursor.h"
17
18 #include "support/gettext.h"
19 #include "support/Translator.h"
20
21 /* InsetInfo displays shortcuts, lyxrc, package and textclass
22 availability and menu information in a non-editable boxed InsetText.
23
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.
29
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 or "buffer". Arguments and outputs vary by type.
34
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
38     separated by comma.
39
40 shortcut: the same as shortcuts, but only output the last shortcut.
41
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
44     entry.
45
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.
48
49 textclass: argument is the name a textclass such as "article". The output is
50     "yes" or "no", indicating the availability of this textclass.
51
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).
56
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.
60
61 buffer: argument can be one of "name", "path", "class". This inset output the
62     filename, path, and textclass of this buffer.
63                 
64 lyxinfo: argument must (presently) be "version". This inset outputs information 
65                 about the version of LyX currently in use.
66
67 There is currently no GUI, no menu entry for this inset. A user can define a
68 shortcut for "info-insert" (e.g. C-S-I), and
69
70 1. input the type and argument of this inset, e.g. "menu paste", in
71    the work area.
72 2. select the text and run "info-insert" (e.g. press C-S-I).
73
74 An alternative method is to enter command "info-insert type arg" in
75 the command buffer (view->Toolbar->Command Buffer).
76
77 */
78
79 namespace lyx {
80
81 class InsetInfo : public InsetCollapsable {
82 public:
83         enum info_type {
84                 UNKNOWN_INFO,   // Invalid type
85                 SHORTCUTS_INFO, // Keyboard shortcuts
86                 SHORTCUT_INFO,  // Keyboard shortcut
87                 LYXRC_INFO,     // RC entry
88                 PACKAGE_INFO,   // Availability of package
89                 TEXTCLASS_INFO, // Availability of textclass
90                 MENU_INFO,      // Which menu item is used for certain function
91                 ICON_INFO,      // which toolbar icon is used for certain function
92                 BUFFER_INFO,    // Buffer related information
93                 LYX_INFO,       // LyX version information
94         };
95
96         ///
97         InsetInfo(Buffer * buf, std::string const & info = std::string());
98         ///
99         InsetCode lyxCode() const { return INFO_CODE; }
100         ///
101         docstring name() const;
102         ///
103         Inset * editXY(Cursor & cur, int x, int y);
104         ///
105         bool editable() const { return false; }
106         ///
107         bool hasSettings() const { return true; }
108         ///
109         void read(Lexer & lex);
110         ///
111         void write(std::ostream & os) const;
112         ///
113         std::string infoType() const;
114         ///
115         std::string infoName() const { return name_; }
116         ///
117         bool validateModifyArgument(docstring const & argument) const;
118         ///
119         bool showInsetDialog(BufferView * bv) const;
120         ///
121         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
122         ///
123         void doDispatch(Cursor & cur, FuncRequest & cmd);
124         ///
125         void setInfo(std::string const & info);
126         /// update info_ and text
127         void updateInfo();
128         ///
129         docstring toolTip(BufferView const & bv, int x, int y) const;
130         ///
131         docstring contextMenu(BufferView const &, int, int) const;
132         /// should paragraph indendation be ommitted in any case?
133         bool neverIndent() const { return true; }
134
135 private:
136         ///
137         virtual Inset * clone() const { return new InsetInfo(*this); }
138         ///
139         void error(std::string const & err);
140         ///
141         void setText(docstring const & str);
142         // make sure that the other version of setText is still available.
143         using InsetCollapsable::setText;
144         ///
145         info_type type_;
146         ///
147         std::string name_;
148 };
149
150
151 } // namespace lyx
152
153 #endif