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 #include "tex-accent.h"
16 #include "support/tostr.h"
18 /* the names used by TeX and XWindows for deadkeys/accents are not the same
19 so here follows a table to clearify the differences. Please correct this
22 |------------------|------------------|------------------|--------------|
23 | TeX | XWindows | \bind/LFUN | used by intl |
24 |------------------|------------------|------------------|--------------|
25 | grave | grave |LFUN_GRAVE | grave
26 | acute | acute |LFUN_ACUTE | acute
27 | circumflex | circumflex |LFUN_CIRCUMFLEX | circumflex
28 | umlaut/dieresis | diaeresis |LFUN_UMLAUT | umlaut
29 | tilde | tilde |LFUN_TILDE | tilde
30 | macron | maron |LFUN_MACRON | macron
31 | dot | abovedot |LFUN_DOT | dot
32 | cedilla | cedilla |LFUN_CEDILLA | cedilla
33 | underdot | |LFUN_UNDERDOT | underdot
34 | underbar | |LFUN_UNDERBAR | underbar
35 | hácek | caron |LFUN_CARON | caron
36 | breve | breve |LFUN_BREVE | breve
37 | tie | |LFUN_TIE | tie
38 | Hungarian umlaut | doubleacute |LFUN_HUNG_UMLAUT | hungarian umlaut
39 | circle | abovering |LFUN_CIRCLE | circle
43 | | semivoiced_sound | |
44 | | |LFUN_SPECIAL_CARON| special caron
46 // I am not sure how some of the XWindows names coresponds to the TeX ones.
48 tex_accent_struct lyx_accent_table[18] = {
49 { static_cast<tex_accent>(0), "", /*"",*/ "", static_cast<kb_action>(0)},
50 {TEX_ACUTE, "\\'", /*" AEIOUYaeiouySZszRLCNrlcn",*/ "acute", LFUN_ACUTE},
51 {TEX_GRAVE, "\\`", /*" aeiouAEIOU",*/ "grave", LFUN_GRAVE},
52 {TEX_MACRON, "\\=", /*" EeAIOUaiou",*/ "macron", LFUN_MACRON},
53 {TEX_TILDE, "\\~", /*" ANOanoIiUu",*/ "tilde", LFUN_TILDE},
54 {TEX_UNDERBAR, "\\b", /*" ",*/ "underbar", LFUN_UNDERBAR},
55 {TEX_CEDILLA, "\\c", /*" CcSsTtRLGrlgNKnk",*/ "cedilla", LFUN_CEDILLA},
56 {TEX_UNDERDOT, "\\d", /*" ",*/ "underdot", LFUN_UNDERDOT},
57 {TEX_CIRCUMFLEX, "\\^", /*" AEIOUaeiouHJhjCGScgs",*/ "circumflex", LFUN_CIRCUMFLEX},
58 {TEX_CIRCLE, "\\r", /*" AaUu",*/ "circle", LFUN_CIRCLE},
59 {TEX_TIE, "\\t", /*" ",*/ "tie", LFUN_TIE},
60 {TEX_BREVE, "\\u", /*" AaGgUu",*/ "breve", LFUN_BREVE},
61 {TEX_CARON, "\\v", /*" LSTZlstzCEDNRcednr",*/ "caron", LFUN_CARON},
62 // {TEX_SPECIAL_CARON, "\\q", "", "ooo", LFUN_SPECIAL_CARON},
63 {TEX_HUNGUML, "\\H", /*" OUou",*/ "hugarian_umlaut", LFUN_HUNG_UMLAUT},
64 {TEX_UMLAUT, "\\\"", /*" AEIOUaeiouy",*/ "umlaut", LFUN_UMLAUT},
65 {TEX_DOT, "\\.", /*" ZzICGicgEe",*/ "dot", LFUN_DOT},
66 {TEX_OGONEK, "\\k", /*" AaEe",*/ "ogonek", LFUN_OGONEK},
67 { static_cast<tex_accent>(0), "", /*"",*/ "", static_cast<kb_action>(0)}};
70 tex_accent_struct get_accent(kb_action action)
73 while (i <= TEX_MAX_ACCENT) {
74 if (lyx_accent_table[i].action == action)
75 return lyx_accent_table[i];
78 struct tex_accent_struct temp = { static_cast<tex_accent>(0), 0,
79 0, static_cast<kb_action>(0)};
84 string const DoAccent(string const & s, tex_accent accent)
88 res += lyx_accent_table[accent].cmd;
90 if (s == "i" || s == "j") {
99 string const DoAccent(char c, tex_accent accent)
101 return DoAccent(tostr(c), accent);