1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
18 #include "tex-accent.h"
19 #include "commandtags.h"
21 #include "support/lstrings.h"
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
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
48 | | semivoiced_sound | |
49 | | |LFUN_SPECIAL_CARON| special caron
51 // I am not sure how some of the XWindows names coresponds to the TeX ones.
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)}};
75 tex_accent_struct get_accent(kb_action action)
78 while (i <= TEX_MAX_ACCENT) {
79 if (lyx_accent_table[i].action == action)
80 return lyx_accent_table[i];
83 struct tex_accent_struct temp = { static_cast<tex_accent>(0), 0,
84 0, static_cast<kb_action>(0)};
89 string const DoAccent(string const & s, tex_accent accent)
93 res += lyx_accent_table[accent].cmd;
95 if (s == "i" || s == "j") {
104 string const DoAccent(char c, tex_accent accent)
106 return DoAccent(tostr(c), accent);