X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTrans.cpp;h=5a0366568481965f9e97ee95258f9a7363d18161;hb=7261fa94482916cb9bf2ba0d21c4df390ea58320;hp=2c25db7039b842c791655b31ca85d4f32d1ca406;hpb=11a0458d3f66bce83b90e23f1c85175a8ffcae45;p=lyx.git diff --git a/src/Trans.cpp b/src/Trans.cpp index 2c25db7039..5a03665684 100644 --- a/src/Trans.cpp +++ b/src/Trans.cpp @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * \author Matthias Ettrich * * Full author contact details are available in file CREDITS. @@ -13,15 +13,9 @@ #include "Trans.h" -#include "Buffer.h" -#include "BufferView.h" -#include "Cursor.h" -#include "CutAndPaste.h" #include "Lexer.h" -#include "LyXRC.h" #include "Text.h" -#include "support/convert.h" #include "support/debug.h" #include "support/docstream.h" #include "support/FileName.h" @@ -56,7 +50,7 @@ namespace lyx { | cedilla | cedilla |LFUN_ACCENT_CEDILLA | cedilla | underdot | |LFUN_ACCENT_UNDERDOT | underdot | underbar | |LFUN_ACCENT_UNDERBAR | underbar - | hácek | caron |LFUN_ACCENT_CARON | caron + | há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 @@ -65,7 +59,6 @@ namespace lyx { | | iota | | | | voiced_sound | | | | semivoiced_sound | | - | | |LFUN_ACCENT_SPECIAL_CARON| special caron */ static TeXAccent lyx_accent_table[] = { {TEX_NOACCENT, 0, "", LFUN_NOACTION}, @@ -73,7 +66,9 @@ static TeXAccent lyx_accent_table[] = { {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_PERISPOMENI, 0x0342, "perispomeni", LFUN_ACCENT_PERISPOMENI}, + {TEX_UNDERBAR, 0x0320, "underbar", LFUN_ACCENT_UNDERBAR}, // COMBINING MINUS SIGN BELOW or 0x0331 COMBINING MACRON BELOW ? + {TEX_CEDILLA, 0x0327, "cedilla", LFUN_ACCENT_CEDILLA}, {TEX_UNDERDOT, 0x0323, "underdot", LFUN_ACCENT_UNDERDOT}, {TEX_CIRCUMFLEX, 0x0302, "circumflex", LFUN_ACCENT_CIRCUMFLEX}, @@ -81,7 +76,6 @@ static TeXAccent lyx_accent_table[] = { {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}, @@ -99,7 +93,7 @@ TeXAccent get_accent(FuncCode action) ++i; } struct TeXAccent temp = { static_cast(0), 0, - 0, static_cast(0)}; + nullptr, static_cast(0)}; return temp; } @@ -173,7 +167,7 @@ enum { KCOMB = 1, KMOD, KMAP, - KXMOD, + KXMOD }; @@ -187,23 +181,21 @@ void Trans::addDeadkey(tex_accent accent, docstring const & keys) tmp.accent = accent; kmod_list_[accent] = tmp; - for (docstring::size_type i = 0; i < keys.length(); ++i) { + for (char_type key : keys) { // FIXME This is a hack. // tmp is no valid UCS4 string, but misused to store the // accent. - docstring tmp; - tmp += char_type(0); - tmp += char_type(accent); - keymap_[keys[i]] = tmp; + docstring tmpd; + tmpd += char_type(0); + tmpd += char_type(accent); + keymap_[key] = tmpd; } } int Trans::load(Lexer & lex) { - bool error = false; - - while (lex.isOK() && !error) { + while (lex.isOK()) { switch (lex.lex()) { case KMOD: { @@ -281,10 +273,14 @@ int Trans::load(Lexer & lex) && it->second[1] == accent_2) break; } + + // could not find accent2 on a key -- this should not happen. + if (it == end) + return -1; + docstring allowed; if (!lex.next()) return -1; - allowed = lex.getDocString(); LYXERR(Debug::KBMAP, "allowed: " << to_utf8(allowed)); @@ -300,7 +296,7 @@ int Trans::load(Lexer & lex) if (!lex.next(true)) return -1; - key_from = lex.getString()[0]; + key_from = static_cast(lex.getString()[0]); LYXERR(Debug::KBMAP, "\t`" << lex.getString() << '\''); if (!lex.next(true)) @@ -378,7 +374,7 @@ docstring const Trans::process(char_type c, TransManager & k) int Trans::load(string const & language) { - struct LexerKeyword kmapTags[] = { + LexerKeyword kmapTags[] = { {"\\kcomb", KCOMB }, { "\\kmap", KMAP }, { "\\kmod", KMOD }, @@ -430,10 +426,9 @@ tex_accent getkeymod(string const & p) // TransFSMData -TransFSMData::TransFSMData() +TransFSMData::TransFSMData() : deadkey_(0), deadkey2_(0), init_state_(nullptr), + deadkey_state_(nullptr), combined_state_(nullptr), currentState(nullptr) { - deadkey_ = deadkey2_ = 0; - deadkey_info_.accent = deadkey2_info_.accent = TEX_NOACCENT; } @@ -510,7 +505,7 @@ docstring const TransDeadkeyState::deadkey(char_type c, KmodInfo d) KmodException::const_iterator cit = deadkey_info_.exception_list.begin(); KmodException::const_iterator end = deadkey_info_.exception_list.end(); for (; cit != end; ++cit) { - if (cit->combined == true && cit->accent == d.accent) { + if (cit->combined && cit->accent == d.accent) { deadkey2_ = c; deadkey2_info_ = d; comb_info_ = (*cit); @@ -583,7 +578,7 @@ Trans TransManager::default_; TransManager::TransManager() - : active_(0) + : active_(&default_) {} @@ -656,7 +651,7 @@ void TransManager::deadkey(char_type c, tex_accent accent, Text * t, Cursor & cu // A deadkey was pressed that cannot be printed // or a accent command was typed in the minibuffer KmodInfo i; - if (active_->isAccentDefined(accent, i) == true) { + if (active_->isAccentDefined(accent, i)) { docstring const res = trans_fsm_ .currentState->deadkey(c, i); insert(res, t, cur);