]> git.lyx.org Git - lyx.git/blob - src/insets/InsetSpecialChar.h
dab1bc3da190eff55c65ae2103c2ff0e6eee4618
[lyx.git] / src / insets / InsetSpecialChar.h
1 // -*- C++ -*-
2 /**
3  * \file InsetSpecialChar.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger Alstrup Nielsen
8  * \author Jean-Marc Lasgouttes
9  * \author Lars Gullik Bjønnes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef INSET_SPECIALCHAR_H
15 #define INSET_SPECIALCHAR_H
16
17
18 #include "Inset.h"
19
20
21 namespace lyx {
22
23 class LaTeXFeatures;
24
25 ///  Used to insert special chars
26 class InsetSpecialChar : public Inset {
27 public:
28
29         /// The different kinds of special chars we support
30         enum Kind {
31                 /// Optional hyphenation point (\-)
32                 HYPHENATION,
33                 /// Optional line wrap point without hyphen (ZWSP)
34                 ALLOWBREAK,
35                 /// Ligature break point (\textcompwordmark)
36                 LIGATURE_BREAK,
37                 /// ... (\ldots)
38                 LDOTS,
39                 /// End of sentence punctuation (\@)
40                 END_OF_SENTENCE,
41                 /// Menu separator
42                 MENU_SEPARATOR,
43                 /// breakable slash
44                 SLASH,
45                 /// protected dash
46                 NOBREAKDASH,
47                 /// LyX logo
48                 PHRASE_LYX,
49                 /// TeX logo
50                 PHRASE_TEX,
51                 /// LaTeX2e logo
52                 PHRASE_LATEX2E,
53                 /// LaTeX logo
54                 PHRASE_LATEX
55         };
56
57         ///
58         InsetSpecialChar() : Inset(0), kind_(HYPHENATION) {}
59         ///
60         explicit InsetSpecialChar(Kind k);
61         ///
62         Kind kind() const;
63         ///
64         docstring toolTip(BufferView const & bv, int x, int y) const override;
65         /// some special chars allow line breaking after them
66         int rowFlags() const override;
67         ///
68         void metrics(MetricsInfo &, Dimension &) const override;
69         ///
70         void draw(PainterInfo & pi, int x, int y) const override;
71         ///
72         void write(std::ostream &) const override;
73         /// Will not be used when lyxf3
74         void read(support::Lexer & lex) override;
75         ///
76         void latex(otexstream &, OutputParams const &) const override;
77         ///
78         int plaintext(odocstringstream & ods, OutputParams const & op,
79                       size_t max_length = INT_MAX) const override;
80         ///
81         void docbook(XMLStream &, OutputParams const &) const override;
82         ///
83         docstring xhtml(XMLStream &, OutputParams const &) const override;
84         ///
85         bool findUsesToString() const override { return true; }
86         ///
87         void toString(odocstream &) const override;
88         ///
89         bool isInToc() const override { return true; }
90         ///
91         void forOutliner(docstring &, size_t const, bool const) const override;
92         ///
93         InsetCode lyxCode() const override { return SPECIALCHAR_CODE; }
94         /// We don't need \begin_inset and \end_inset
95         bool directWrite() const override { return true; }
96         ///
97         void validate(LaTeXFeatures &) const override;
98
99         /// should this inset be handled like a normal character?
100         bool isChar() const override;
101         /// is this equivalent to a letter?
102         bool isLetter() const override;
103         /// should we break lines after this inset?
104         bool isLineSeparator() const override;
105         /// Is the content of this inset part of the immediate (visible) text sequence?
106         bool isPartOfTextSequence() const override { return isChar(); }
107 private:
108         Inset * clone() const override { return new InsetSpecialChar(*this); }
109
110         /// And which kind is this?
111         Kind kind_;
112 };
113
114
115 } // namespace lyx
116
117 #endif