]> git.lyx.org Git - lyx.git/blob - src/tex-accent.C
Use Gtk::ComboBoxText::clear() instead of clear_items(), which only exists in newer...
[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 using std::string;
20
21 /* the names used by TeX and XWindows for deadkeys/accents are not the same
22    so here follows a table to clearify the differences. Please correct this
23    if I got it wrong
24
25    |------------------|------------------|------------------|--------------|
26    |      TeX         |     XWindows     |   \bind/LFUN     | used by intl |
27    |------------------|------------------|------------------|--------------|
28    |    grave         |    grave         |LFUN_GRAVE        | grave
29    |    acute         |    acute         |LFUN_ACUTE        | acute
30    |    circumflex    |    circumflex    |LFUN_CIRCUMFLEX   | circumflex
31    | umlaut/dieresis  |    diaeresis     |LFUN_UMLAUT       | umlaut
32    |    tilde         |    tilde         |LFUN_TILDE        | tilde
33    |    macron        |    maron         |LFUN_MACRON       | macron
34    |    dot           |    abovedot      |LFUN_DOT          | dot
35    |    cedilla       |    cedilla       |LFUN_CEDILLA      | cedilla
36    |    underdot      |                  |LFUN_UNDERDOT     | underdot
37    |    underbar      |                  |LFUN_UNDERBAR     | underbar
38    |    hácek         |    caron         |LFUN_CARON        | caron
39    |    breve         |    breve         |LFUN_BREVE        | breve
40    |    tie           |                  |LFUN_TIE          | tie
41    | Hungarian umlaut |    doubleacute   |LFUN_HUNG_UMLAUT  | hungarian umlaut
42    |    circle        |    abovering     |LFUN_CIRCLE       | circle
43    |                  |    ogonek        |                  |
44    |                  |    iota          |                  |
45    |                  |    voiced_sound  |                  |
46    |                  | semivoiced_sound |                  |
47    |                  |                  |LFUN_SPECIAL_CARON| special caron
48    */
49 // I am not sure how some of the XWindows names coresponds to the TeX ones.
50
51 tex_accent_struct lyx_accent_table[18] = {
52         { static_cast<tex_accent>(0), "", /*"",*/ "", static_cast<kb_action>(0)},
53         {TEX_ACUTE,      "\\'",  /*" AEIOUYaeiouySZszRLCNrlcn",*/ "acute",   LFUN_ACUTE},
54         {TEX_GRAVE,      "\\`",  /*" aeiouAEIOU",*/           "grave",    LFUN_GRAVE},
55         {TEX_MACRON,     "\\=",  /*" EeAIOUaiou",*/           "macron",    LFUN_MACRON},
56         {TEX_TILDE,      "\\~",  /*" ANOanoIiUu",*/           "tilde",    LFUN_TILDE},
57         {TEX_UNDERBAR,   "\\b", /*" ",*/                     "underbar", LFUN_UNDERBAR},
58         {TEX_CEDILLA,    "\\c", /*" CcSsTtRLGrlgNKnk",*/     "cedilla",    LFUN_CEDILLA},
59         {TEX_UNDERDOT,   "\\d", /*" ",*/                     "underdot", LFUN_UNDERDOT},
60         {TEX_CIRCUMFLEX, "\\^",  /*" AEIOUaeiouHJhjCGScgs",*/ "circumflex",  LFUN_CIRCUMFLEX},
61         {TEX_CIRCLE,     "\\r", /*" AaUu",*/                 "circle",  LFUN_CIRCLE},
62         {TEX_TIE,        "\\t", /*" ",*/                     "tie",    LFUN_TIE},
63         {TEX_BREVE,      "\\u", /*" AaGgUu",*/               "breve",    LFUN_BREVE},
64         {TEX_CARON,      "\\v", /*" LSTZlstzCEDNRcednr",*/   "caron",    LFUN_CARON},
65 //  {TEX_SPECIAL_CARON, "\\q", "", "ooo",  LFUN_SPECIAL_CARON},
66         {TEX_HUNGUML,    "\\H", /*" OUou",*/                 "hugarian_umlaut",    LFUN_HUNG_UMLAUT},
67         {TEX_UMLAUT,     "\\\"", /*" AEIOUaeiouy",*/          "umlaut",    LFUN_UMLAUT},
68         {TEX_DOT,        "\\.",  /*" ZzICGicgEe",*/           "dot",    LFUN_DOT},
69         {TEX_OGONEK,     "\\k",  /*" AaEe",*/                 "ogonek",    LFUN_OGONEK},
70         { static_cast<tex_accent>(0), "", /*"",*/ "", static_cast<kb_action>(0)}};
71
72
73 tex_accent_struct get_accent(kb_action action)
74 {
75         int i = 0;
76         while (i <= TEX_MAX_ACCENT) {
77                 if (lyx_accent_table[i].action == action)
78                         return lyx_accent_table[i];
79                 ++i;
80         }
81         struct tex_accent_struct temp = { static_cast<tex_accent>(0), 0,
82                                           0, static_cast<kb_action>(0)};
83         return temp;
84 }
85
86
87 string const DoAccent(string const & s, tex_accent accent)
88 {
89         string res;
90
91         res += lyx_accent_table[accent].cmd;
92         res += '{';
93         if (s == "i" || s == "j") {
94                 res += '\\';
95         }
96         res += s;
97         res += '}';
98         return res;
99 }
100
101
102 string const DoAccent(char c, tex_accent accent)
103 {
104         return DoAccent(convert<string>(c), accent);
105 }