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