3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Matthias Ettrich
9 * Full author contact details are available in file CREDITS.
14 #include "tex-accent.h"
17 #include "support/convert.h"
18 #include "support/docstream.h"
23 // FIXME This file has nothing to do with TeX anymore
25 /* the names used by TeX and XWindows for deadkeys/accents are not the same
26 so here follows a table to clearify the differences. Please correct this
29 |------------------|------------------|------------------|--------------|
30 | TeX | XWindows | \bind/LFUN | used by intl |
31 |------------------|------------------|------------------|--------------|
32 | grave | grave |LFUN_ACCENT_GRAVE | grave
33 | acute | acute |LFUN_ACCENT_ACUTE | acute
34 | circumflex | circumflex |LFUN_ACCENT_CIRCUMFLEX | circumflex
35 | umlaut/dieresis | diaeresis |LFUN_ACCENT_UMLAUT | umlaut
36 | tilde | tilde |LFUN_ACCENT_TILDE | tilde
37 | macron | maron |LFUN_ACCENT_MACRON | macron
38 | dot | abovedot |LFUN_ACCENT_DOT | dot
39 | cedilla | cedilla |LFUN_ACCENT_CEDILLA | cedilla
40 | underdot | |LFUN_ACCENT_UNDERDOT | underdot
41 | underbar | |LFUN_ACCENT_UNDERBAR | underbar
42 | hácek | caron |LFUN_ACCENT_CARON | caron
43 | breve | breve |LFUN_ACCENT_BREVE | breve
44 | tie | |LFUN_ACCENT_TIE | tie
45 | Hungarian umlaut | doubleacute |LFUN_ACCENT_HUNGARIAN_UMLAUT | hungarian umlaut
46 | circle | abovering |LFUN_ACCENT_CIRCLE | circle
50 | | semivoiced_sound | |
51 | | |LFUN_ACCENT_SPECIAL_CARON| special caron
53 // I am not sure how some of the XWindows names coresponds to the TeX ones.
55 tex_accent_struct lyx_accent_table[] = {
56 {TEX_NOACCENT, 0, "", LFUN_NOACTION},
57 {TEX_ACUTE, 0x0301, "acute", LFUN_ACCENT_ACUTE},
58 {TEX_GRAVE, 0x0300, "grave", LFUN_ACCENT_GRAVE},
59 {TEX_MACRON, 0x0304, "macron", LFUN_ACCENT_MACRON},
60 {TEX_TILDE, 0x0303, "tilde", LFUN_ACCENT_TILDE},
61 {TEX_UNDERBAR, 0x0320, "underbar", LFUN_ACCENT_UNDERBAR},
62 {TEX_CEDILLA, 0x0327, "cedilla", LFUN_ACCENT_CEDILLA},
63 {TEX_UNDERDOT, 0x0323, "underdot", LFUN_ACCENT_UNDERDOT},
64 {TEX_CIRCUMFLEX, 0x0302, "circumflex", LFUN_ACCENT_CIRCUMFLEX},
65 {TEX_CIRCLE, 0x030a, "circle", LFUN_ACCENT_CIRCLE},
66 {TEX_TIE, 0x0361, "tie", LFUN_ACCENT_TIE},
67 {TEX_BREVE, 0x0306, "breve", LFUN_ACCENT_BREVE},
68 {TEX_CARON, 0x030c, "caron", LFUN_ACCENT_CARON},
69 // {TEX_SPECIAL_CARON, 0x030c, "ooo", LFUN_ACCENT_SPECIAL_CARON},
70 // Don't fix this typo for compatibility reasons!
71 {TEX_HUNGUML, 0x030b, "hugarian_umlaut", LFUN_ACCENT_HUNGARIAN_UMLAUT},
72 {TEX_UMLAUT, 0x0308, "umlaut", LFUN_ACCENT_UMLAUT},
73 {TEX_DOT, 0x0307, "dot", LFUN_ACCENT_DOT},
74 {TEX_OGONEK, 0x0328, "ogonek", LFUN_ACCENT_OGONEK}
78 tex_accent_struct get_accent(kb_action action)
81 while (i <= TEX_MAX_ACCENT) {
82 if (lyx_accent_table[i].action == action)
83 return lyx_accent_table[i];
86 struct tex_accent_struct temp = { static_cast<tex_accent>(0), 0,
87 0, static_cast<kb_action>(0)};
92 docstring const DoAccent(docstring const & s, tex_accent accent)
95 return docstring(1, lyx_accent_table[accent].ucs4);
99 os.put(lyx_accent_table[accent].ucs4);
100 if (s.length() > 1) {
101 if (accent != TEX_TIE || s.length() > 2)
102 lyxerr << "Warning: Too many characters given for accent "
103 << lyx_accent_table[accent].name << '.' << std::endl;
106 return normalize_kc(os.str());
110 docstring const DoAccent(char_type c, tex_accent accent)
112 return DoAccent(docstring(1, c), accent);