]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInfo.h
Add Erlang support for listings (bug 4263)
[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 "InsetText.h"
16 #include "RenderButton.h"
17 #include "gettext.h"
18 #include "Cursor.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 as 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.
31 The screen and latex output is the content of the information. An 
32 InsetInfo can have type "shortcut", "lyxrc", "package", "textclass", or
33 "menu". Arguments and outputs vary by type.
34
35 shortcut: name of the LFUN such as "math-insert \alpha". The syntax
36         is the same as what is used in the bind and ui files.
37         The output of this inset is all shortcuts separated by comma.
38
39 lyxrc: name of the rc entry such as "bind_file". Look in src/LyXRC.h
40         for available entries. The output is the content of this RC
41         entry.
42
43 package: name of a latex package such as "listings". The output is
44         "yes" or "no".
45
46 textclass: name of a textclass such as "article". The output is "yes"
47         or "no".
48
49 menu: name of the LFUN such as "paste". The syntax is the same as
50         what is used in the bind and ui files. The output is the
51         menu item that trigger this LFUN. For example, "File > Paste".
52         '>' is actually \lyxarrow (an InsetSpecialChar).
53
54
55 Because this inset is intended to be used only by document maintainers,
56 there is no GUI, no menu entry for this inset. A user would have to
57 define a shortcut for "info-insert" (e.g. C-S-I), and
58
59 1. input the type and argument of this inset. E.g. "menu paste".
60 2. select the text and run "info-insert" (e.g. press C-S-I).
61
62 */
63
64 namespace lyx {
65
66 /** Used to insert index labels
67   */
68 class InsetInfo : public InsetText {
69 public:
70         enum info_type {
71                 UNKNOWN_INFO,   // Invalid type
72                 SHORTCUT_INFO,  // Keyboard shortcut
73                 LYXRC_INFO,     // RC entry
74                 PACKAGE_INFO,   // Availability of package
75                 TEXTCLASS_INFO, // Availability of textclass
76                 MENU_INFO,      // Which menu item is used for certain function
77         };
78
79         ///
80         InsetInfo(BufferParams const & bp, std::string const & info = std::string());
81         ///
82         Inset * editXY(Cursor & cur, int x, int y);
83         ///
84         EDITABLE editable() const { return NOT_EDITABLE; }
85         ///
86         void draw(PainterInfo & pi, int x, int y) const;
87         ///
88         void read(Buffer const &, Lexer & lex);
89         ///
90         void write(Buffer const & buf, std::ostream & os) const;
91         ///
92         void doDispatch(Cursor & cur, FuncRequest & cmd);
93         ///
94         InsetCode lyxCode() const { return INFO_CODE; }
95         ///
96         void setInfo(std::string const & info);
97         ///
98         bool setMouseHover(bool mouse_hover);
99
100 private:
101         /// The translator between the information type enum and corresponding string.
102         Translator<info_type, std::string> const & nameTranslator() const;
103         /// update info_ and text
104         void updateInfo();
105         ///
106         virtual Inset * clone() const { return new InsetInfo(*this); }
107         ///
108         info_type type_;
109         ///
110         std::string name_;
111         /// store the buffer parameter
112         BufferParams const & bp_;
113         ///
114         bool mouse_hover_;
115 };
116
117
118
119 } // namespace lyx
120
121 #endif