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