2000-07-24 13:53:19 +00:00
|
|
|
|
/* This file is part of
|
|
|
|
|
* ======================================================
|
|
|
|
|
*
|
|
|
|
|
* LyX, The Document Processor
|
|
|
|
|
*
|
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
|
|
|
|
*
|
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#include <cstdlib>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "tex-accent.h"
|
|
|
|
|
#include "commandtags.h"
|
|
|
|
|
#include "LString.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#include "support/lstrings.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/* the names used by TeX and XWindows for deadkeys/accents are not the same
|
|
|
|
|
so here follows a table to clearify the differences. Please correct this
|
|
|
|
|
if I got it wrong
|
|
|
|
|
|
|
|
|
|
|------------------|------------------|------------------|--------------|
|
|
|
|
|
| TeX | XWindows | \bind/LFUN | used by intl |
|
|
|
|
|
|------------------|------------------|------------------|--------------|
|
|
|
|
|
| grave | grave |LFUN_GRAVE | grave
|
|
|
|
|
| acute | acute |LFUN_ACUTE | acute
|
|
|
|
|
| circumflex | circumflex |LFUN_CIRCUMFLEX | circumflex
|
|
|
|
|
| umlaut/dieresis | diaeresis |LFUN_UMLAUT | umlaut
|
|
|
|
|
| tilde | tilde |LFUN_TILDE | tilde
|
|
|
|
|
| macron | maron |LFUN_MACRON | macron
|
|
|
|
|
| dot | abovedot |LFUN_DOT | dot
|
|
|
|
|
| cedilla | cedilla |LFUN_CEDILLA | cedilla
|
|
|
|
|
| underdot | |LFUN_UNDERDOT | underdot
|
|
|
|
|
| underbar | |LFUN_UNDERBAR | underbar
|
|
|
|
|
| h<EFBFBD>cek | caron |LFUN_CARON | caron
|
|
|
|
|
| breve | breve |LFUN_BREVE | breve
|
|
|
|
|
| tie | |LFUN_TIE | tie
|
|
|
|
|
| Hungarian umlaut | doubleacute |LFUN_HUNG_UMLAUT | hungarian umlaut
|
|
|
|
|
| circle | abovering |LFUN_CIRCLE | circle
|
|
|
|
|
| | ogonek | |
|
|
|
|
|
| | iota | |
|
|
|
|
|
| | voiced_sound | |
|
|
|
|
|
| | semivoiced_sound | |
|
|
|
|
|
| | |LFUN_SPECIAL_CARON| special caron
|
|
|
|
|
*/
|
|
|
|
|
// I am not sure how some of the XWindows names coresponds to the TeX ones.
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
tex_accent_struct lyx_accent_table[18] = {
|
1999-12-13 00:05:34 +00:00
|
|
|
|
{ static_cast<tex_accent>(0), "", "", "", static_cast<kb_action>(0)},
|
1999-11-15 12:01:38 +00:00
|
|
|
|
{TEX_ACUTE, "\\'", " AEIOUYaeiouySZszRLCNrlcn", "acute", LFUN_ACUTE},
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{TEX_GRAVE, "\\`", " aeiouAEIOU", "grave", LFUN_GRAVE},
|
|
|
|
|
{TEX_MACRON, "\\=", " EeAIOUaiou", "macron", LFUN_MACRON},
|
|
|
|
|
{TEX_TILDE, "\\~", " ANOanoIiUu", "tilde", LFUN_TILDE},
|
|
|
|
|
{TEX_UNDERBAR, "\\b", " ", "underbar", LFUN_UNDERBAR},
|
|
|
|
|
{TEX_CEDILLA, "\\c", " CcSsTtRLGrlgNKnk", "cedilla", LFUN_CEDILLA},
|
|
|
|
|
{TEX_UNDERDOT, "\\d", " ", "underdot", LFUN_UNDERDOT},
|
|
|
|
|
{TEX_CIRCUMFLEX, "\\^", " AEIOUaeiouHJhjCGScgs", "circumflex", LFUN_CIRCUMFLEX},
|
|
|
|
|
{TEX_CIRCLE, "\\r", " AaUu", "circle", LFUN_CIRCLE},
|
|
|
|
|
{TEX_TIE, "\\t", " ", "tie", LFUN_TIE},
|
|
|
|
|
{TEX_BREVE, "\\u", " AaGgUu", "breve", LFUN_BREVE},
|
|
|
|
|
{TEX_CARON, "\\v", " LSTZlstzCEDNRcednr", "caron", LFUN_CARON},
|
1999-11-15 12:01:38 +00:00
|
|
|
|
// {TEX_SPECIAL_CARON, "\\q", "", "ooo", LFUN_SPECIAL_CARON},
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{TEX_HUNGUML, "\\H", " OUou", "hugarian_umlaut", LFUN_HUNG_UMLAUT},
|
|
|
|
|
{TEX_UMLAUT, "\\\"", " AEIOUaeiouy", "umlaut", LFUN_UMLAUT},
|
|
|
|
|
{TEX_DOT, "\\.", " ZzICGicgEe", "dot", LFUN_DOT},
|
|
|
|
|
{TEX_OGONEK, "\\k", " AaEe", "ogonek", LFUN_OGONEK},
|
1999-12-13 00:05:34 +00:00
|
|
|
|
{ static_cast<tex_accent>(0), "", "", "", static_cast<kb_action>(0)}};
|
2001-03-20 01:22:46 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
tex_accent_struct get_accent(kb_action action)
|
|
|
|
|
{
|
1999-12-13 00:05:34 +00:00
|
|
|
|
int i = 0;
|
|
|
|
|
while (i <= TEX_MAX_ACCENT){
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (lyx_accent_table[i].action == action)
|
|
|
|
|
return lyx_accent_table[i];
|
1999-12-13 00:05:34 +00:00
|
|
|
|
++i;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-12-13 00:05:34 +00:00
|
|
|
|
struct tex_accent_struct temp = { static_cast<tex_accent>(0), 0, 0,
|
|
|
|
|
0, static_cast<kb_action>(0)};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return temp;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string DoAccent(string const & s, tex_accent accent)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string res;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-03-06 02:42:40 +00:00
|
|
|
|
res += lyx_accent_table[accent].cmd;
|
|
|
|
|
res += '{';
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (s == "i" || s == "j") {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
res += '\\';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-03-06 02:42:40 +00:00
|
|
|
|
res += s;
|
|
|
|
|
res += '}';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string DoAccent(char c, tex_accent accent)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
|
return DoAccent(tostr(c), accent);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|