]> git.lyx.org Git - lyx.git/blob - src/tex-accent.C
update build instructions (Qt 4.2.2 etc.)
[lyx.git] / src / tex-accent.C
1 /**
2  * \file tex-accent.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Matthias Ettrich
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "tex-accent.h"
15 #include "support/convert.h"
16
17 #include <string>
18
19
20 namespace lyx {
21
22 using std::string;
23
24 /* the names used by TeX and XWindows for deadkeys/accents are not the same
25    so here follows a table to clearify the differences. Please correct this
26    if I got it wrong
27
28    |------------------|------------------|------------------|--------------|
29    |      TeX         |     XWindows     |   \bind/LFUN     | used by intl |
30    |------------------|------------------|------------------|--------------|
31    |    grave         |    grave         |LFUN_ACCENT_GRAVE        | grave
32    |    acute         |    acute         |LFUN_ACCENT_ACUTE        | acute
33    |    circumflex    |    circumflex    |LFUN_ACCENT_CIRCUMFLEX   | circumflex
34    | umlaut/dieresis  |    diaeresis     |LFUN_ACCENT_UMLAUT       | umlaut
35    |    tilde         |    tilde         |LFUN_ACCENT_TILDE        | tilde
36    |    macron        |    maron         |LFUN_ACCENT_MACRON       | macron
37    |    dot           |    abovedot      |LFUN_ACCENT_DOT          | dot
38    |    cedilla       |    cedilla       |LFUN_ACCENT_CEDILLA      | cedilla
39    |    underdot      |                  |LFUN_ACCENT_UNDERDOT     | underdot
40    |    underbar      |                  |LFUN_ACCENT_UNDERBAR     | underbar
41    |    hácek         |    caron         |LFUN_ACCENT_CARON        | caron
42    |    breve         |    breve         |LFUN_ACCENT_BREVE        | breve
43    |    tie           |                  |LFUN_ACCENT_TIE          | tie
44    | Hungarian umlaut |    doubleacute   |LFUN_ACCENT_HUNGARIAN_UMLAUT  | hungarian umlaut
45    |    circle        |    abovering     |LFUN_ACCENT_CIRCLE       | circle
46    |                  |    ogonek        |                  |
47    |                  |    iota          |                  |
48    |                  |    voiced_sound  |                  |
49    |                  | semivoiced_sound |                  |
50    |                  |                  |LFUN_ACCENT_SPECIAL_CARON| special caron
51    */
52 // I am not sure how some of the XWindows names coresponds to the TeX ones.
53
54 tex_accent_struct lyx_accent_table[18] = {
55         { static_cast<tex_accent>(0), "", /*"",*/ "", static_cast<kb_action>(0)},
56         {TEX_ACUTE,      "\\'",  /*" AEIOUYaeiouySZszRLCNrlcn",*/ "acute",   LFUN_ACCENT_ACUTE},
57         {TEX_GRAVE,      "\\`",  /*" aeiouAEIOU",*/           "grave",    LFUN_ACCENT_GRAVE},
58         {TEX_MACRON,     "\\=",  /*" EeAIOUaiou",*/           "macron",    LFUN_ACCENT_MACRON},
59         {TEX_TILDE,      "\\~",  /*" ANOanoIiUu",*/           "tilde",    LFUN_ACCENT_TILDE},
60         {TEX_UNDERBAR,   "\\b", /*" ",*/                     "underbar", LFUN_ACCENT_UNDERBAR},
61         {TEX_CEDILLA,    "\\c", /*" CcSsTtRLGrlgNKnk",*/     "cedilla",    LFUN_ACCENT_CEDILLA},
62         {TEX_UNDERDOT,   "\\d", /*" ",*/                     "underdot", LFUN_ACCENT_UNDERDOT},
63         {TEX_CIRCUMFLEX, "\\^",  /*" AEIOUaeiouHJhjCGScgs",*/ "circumflex",  LFUN_ACCENT_CIRCUMFLEX},
64         {TEX_CIRCLE,     "\\r", /*" AaUu",*/                 "circle",  LFUN_ACCENT_CIRCLE},
65         {TEX_TIE,        "\\t", /*" ",*/                     "tie",    LFUN_ACCENT_TIE},
66         {TEX_BREVE,      "\\u", /*" AaGgUu",*/               "breve",    LFUN_ACCENT_BREVE},
67         {TEX_CARON,      "\\v", /*" LSTZlstzCEDNRcednr",*/   "caron",    LFUN_ACCENT_CARON},
68 //  {TEX_SPECIAL_CARON, "\\q", "", "ooo",  LFUN_ACCENT_SPECIAL_CARON},
69         {TEX_HUNGUML,    "\\H", /*" OUou",*/                 "hugarian_umlaut",    LFUN_ACCENT_HUNGARIAN_UMLAUT},
70         {TEX_UMLAUT,     "\\\"", /*" AEIOUaeiouy",*/          "umlaut",    LFUN_ACCENT_UMLAUT},
71         {TEX_DOT,        "\\.",  /*" ZzICGicgEe",*/           "dot",    LFUN_ACCENT_DOT},
72         {TEX_OGONEK,     "\\k",  /*" AaEe",*/                 "ogonek",    LFUN_ACCENT_OGONEK},
73         { static_cast<tex_accent>(0), "", /*"",*/ "", static_cast<kb_action>(0)}};
74
75
76 tex_accent_struct get_accent(kb_action action)
77 {
78         int i = 0;
79         while (i <= TEX_MAX_ACCENT) {
80                 if (lyx_accent_table[i].action == action)
81                         return lyx_accent_table[i];
82                 ++i;
83         }
84         struct tex_accent_struct temp = { static_cast<tex_accent>(0), 0,
85                                           0, static_cast<kb_action>(0)};
86         return temp;
87 }
88
89
90 string const DoAccent(string const & s, tex_accent accent)
91 {
92         string res;
93
94         res += lyx_accent_table[accent].cmd;
95         res += '{';
96         if (s == "i" || s == "j") {
97                 res += '\\';
98         }
99         res += s;
100         res += '}';
101         return res;
102 }
103
104
105 string const DoAccent(char c, tex_accent accent)
106 {
107         return DoAccent(convert<string>(c), accent);
108 }
109
110
111 } // namespace lyx