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