2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file tex-accent.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Matthias Ettrich
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "tex-accent.h"
|
2007-03-31 18:28:36 +00:00
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
2005-01-06 16:39:35 +00:00
|
|
|
|
#include "support/convert.h"
|
2007-03-31 18:28:36 +00:00
|
|
|
|
#include "support/docstream.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2007-03-31 18:28:36 +00:00
|
|
|
|
// FIXME This file has nothing to do with TeX anymore
|
|
|
|
|
|
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 |
|
|
|
|
|
|------------------|------------------|------------------|--------------|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
| grave | grave |LFUN_ACCENT_GRAVE | grave
|
|
|
|
|
| acute | acute |LFUN_ACCENT_ACUTE | acute
|
|
|
|
|
| circumflex | circumflex |LFUN_ACCENT_CIRCUMFLEX | circumflex
|
|
|
|
|
| umlaut/dieresis | diaeresis |LFUN_ACCENT_UMLAUT | umlaut
|
|
|
|
|
| tilde | tilde |LFUN_ACCENT_TILDE | tilde
|
|
|
|
|
| macron | maron |LFUN_ACCENT_MACRON | macron
|
|
|
|
|
| dot | abovedot |LFUN_ACCENT_DOT | dot
|
|
|
|
|
| cedilla | cedilla |LFUN_ACCENT_CEDILLA | cedilla
|
|
|
|
|
| underdot | |LFUN_ACCENT_UNDERDOT | underdot
|
|
|
|
|
| underbar | |LFUN_ACCENT_UNDERBAR | underbar
|
|
|
|
|
| h<EFBFBD>cek | caron |LFUN_ACCENT_CARON | caron
|
|
|
|
|
| breve | breve |LFUN_ACCENT_BREVE | breve
|
|
|
|
|
| tie | |LFUN_ACCENT_TIE | tie
|
|
|
|
|
| Hungarian umlaut | doubleacute |LFUN_ACCENT_HUNGARIAN_UMLAUT | hungarian umlaut
|
|
|
|
|
| circle | abovering |LFUN_ACCENT_CIRCLE | circle
|
1999-09-27 18:44:28 +00:00
|
|
|
|
| | ogonek | |
|
|
|
|
|
| | iota | |
|
|
|
|
|
| | voiced_sound | |
|
|
|
|
|
| | semivoiced_sound | |
|
2006-05-05 20:23:12 +00:00
|
|
|
|
| | |LFUN_ACCENT_SPECIAL_CARON| special caron
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
|
|
|
|
// I am not sure how some of the XWindows names coresponds to the TeX ones.
|
|
|
|
|
|
2007-03-31 18:28:36 +00:00
|
|
|
|
tex_accent_struct lyx_accent_table[] = {
|
|
|
|
|
{TEX_NOACCENT, 0, "", LFUN_NOACTION},
|
|
|
|
|
{TEX_ACUTE, 0x0301, "acute", LFUN_ACCENT_ACUTE},
|
|
|
|
|
{TEX_GRAVE, 0x0300, "grave", LFUN_ACCENT_GRAVE},
|
|
|
|
|
{TEX_MACRON, 0x0304, "macron", LFUN_ACCENT_MACRON},
|
|
|
|
|
{TEX_TILDE, 0x0303, "tilde", LFUN_ACCENT_TILDE},
|
|
|
|
|
{TEX_UNDERBAR, 0x0320, "underbar", LFUN_ACCENT_UNDERBAR},
|
|
|
|
|
{TEX_CEDILLA, 0x0327, "cedilla", LFUN_ACCENT_CEDILLA},
|
|
|
|
|
{TEX_UNDERDOT, 0x0323, "underdot", LFUN_ACCENT_UNDERDOT},
|
|
|
|
|
{TEX_CIRCUMFLEX, 0x0302, "circumflex", LFUN_ACCENT_CIRCUMFLEX},
|
|
|
|
|
{TEX_CIRCLE, 0x030a, "circle", LFUN_ACCENT_CIRCLE},
|
|
|
|
|
{TEX_TIE, 0x0361, "tie", LFUN_ACCENT_TIE},
|
|
|
|
|
{TEX_BREVE, 0x0306, "breve", LFUN_ACCENT_BREVE},
|
|
|
|
|
{TEX_CARON, 0x030c, "caron", LFUN_ACCENT_CARON},
|
|
|
|
|
// {TEX_SPECIAL_CARON, 0x030c, "ooo", LFUN_ACCENT_SPECIAL_CARON},
|
|
|
|
|
// Don't fix this typo for compatibility reasons!
|
|
|
|
|
{TEX_HUNGUML, 0x030b, "hugarian_umlaut", LFUN_ACCENT_HUNGARIAN_UMLAUT},
|
|
|
|
|
{TEX_UMLAUT, 0x0308, "umlaut", LFUN_ACCENT_UMLAUT},
|
|
|
|
|
{TEX_DOT, 0x0307, "dot", LFUN_ACCENT_DOT},
|
|
|
|
|
{TEX_OGONEK, 0x0328, "ogonek", LFUN_ACCENT_OGONEK}
|
|
|
|
|
};
|
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;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
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
|
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
|
struct tex_accent_struct temp = { static_cast<tex_accent>(0), 0,
|
1999-12-13 00:05:34 +00:00
|
|
|
|
0, static_cast<kb_action>(0)};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return temp;
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-16 07:53:23 +00:00
|
|
|
|
|
2007-03-31 08:12:08 +00:00
|
|
|
|
docstring const DoAccent(docstring const & s, tex_accent accent)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2007-03-31 18:28:36 +00:00
|
|
|
|
if (s.empty())
|
|
|
|
|
return docstring(1, lyx_accent_table[accent].ucs4);
|
|
|
|
|
|
|
|
|
|
odocstringstream os;
|
|
|
|
|
os.put(s[0]);
|
|
|
|
|
os.put(lyx_accent_table[accent].ucs4);
|
|
|
|
|
if (s.length() > 1) {
|
|
|
|
|
if (accent != TEX_TIE || s.length() > 2)
|
|
|
|
|
lyxerr << "Warning: Too many characters given for accent "
|
|
|
|
|
<< lyx_accent_table[accent].name << '.' << std::endl;
|
|
|
|
|
os << s.substr(1);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2007-03-31 18:28:36 +00:00
|
|
|
|
// FIXME: We should normalize the result to precomposed form
|
|
|
|
|
return os.str();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-05-16 07:53:23 +00:00
|
|
|
|
|
2007-03-31 08:12:08 +00:00
|
|
|
|
docstring const DoAccent(char_type c, tex_accent accent)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2007-03-31 08:12:08 +00:00
|
|
|
|
return DoAccent(docstring(1, c), accent);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|