X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftrans_mgr.C;h=88b4190e48ee0d3922946376850910e04c3e089b;hb=068e2cfb25bfbab62f80bc0c776ca169032c2219;hp=f7e4bb63102a5e9e0a47dc14ca34c94d9cf73175;hpb=532141facfd18627e9972f7a4f3d2032d18e0d2c;p=lyx.git diff --git a/src/trans_mgr.C b/src/trans_mgr.C index f7e4bb6310..88b4190e48 100644 --- a/src/trans_mgr.C +++ b/src/trans_mgr.C @@ -19,8 +19,8 @@ using std::endl; using std::pair; -extern string DoAccent(string const &, tex_accent); -extern string DoAccent(char, tex_accent); +extern string const DoAccent(string const &, tex_accent); +extern string const DoAccent(char, tex_accent); extern BufferView * current_view; @@ -44,17 +44,17 @@ TransInitState::TransInitState() } -string TransInitState::normalkey(char c, char * t) +string const TransInitState::normalkey(char c, string const & t) { string res; - if (t) res = t; + if (!t.empty()) res = t; else res = c; return res; } -string TransInitState::deadkey(char c, KmodInfo d) +string const TransInitState::deadkey(char c, KmodInfo d) { deadkey_ = c; deadkey_info_ = d; @@ -70,7 +70,7 @@ TransDeadkeyState::TransDeadkeyState() } -string TransDeadkeyState::normalkey(char c, char * trans) +string const TransDeadkeyState::normalkey(char c, string const & trans) { string res; @@ -85,8 +85,7 @@ string TransDeadkeyState::normalkey(char c, char * trans) } if (l == 0) { // Not an exception. Check if it allowed - if (current_view->buffer()->params.allowAccents == true || - countChar(deadkey_info_.allowed, c) > 0) { + if (countChar(deadkey_info_.allowed, c) > 0) { res = DoAccent(c, deadkey_info_.accent); } else { // Not allowed @@ -101,7 +100,7 @@ string TransDeadkeyState::normalkey(char c, char * trans) } -string TransDeadkeyState::deadkey(char c, KmodInfo d) +string const TransDeadkeyState::deadkey(char c, KmodInfo d) { string res; @@ -154,7 +153,7 @@ TransCombinedState::TransCombinedState() } -string TransCombinedState::normalkey(char c, char * trans) +string const TransCombinedState::normalkey(char c, string const & trans) { string res; @@ -178,7 +177,7 @@ string TransCombinedState::normalkey(char c, char * trans) } -string TransCombinedState::deadkey(char c, KmodInfo d) +string const TransCombinedState::deadkey(char c, KmodInfo d) { // Third key in a row. Output the first one and // reenter with shifted deadkeys @@ -206,14 +205,15 @@ TransFSM::TransFSM(): // TransManager +// Initialize static member. +Trans TransManager::default_; + + TransManager::TransManager() : active_(0), t1_(new Trans), t2_(new Trans) {} -Trans * TransManager::default_ = new Trans; - - TransManager::~TransManager() { delete t1_; @@ -239,9 +239,9 @@ int TransManager::SetSecondary(string const & language) } -bool TransManager::setCharset(char const * set) +bool TransManager::setCharset(string const & str) { - return chset_.loadFile(set); + return chset_.loadFile(str); } @@ -264,7 +264,7 @@ void TransManager::EnableSecondary() void TransManager::DisableKeymap() { - active_ = default_; + active_ = &default_; lyxerr[Debug::KBMAP] << "Disabling keymap" << endl; } @@ -285,17 +285,17 @@ void TransManager::TranslateAndInsert(char c, LyXText * text) void TransManager::insertVerbatim(string const & str, LyXText * text) { - int l = str.length(); + string::size_type const l = str.length(); - for (int i = 0; i < l; ++i){ + for (string::size_type i = 0; i < l; ++i) { if (str[i] == '\"' - && text->GetFont(text->cursor.par, - text->cursor.pos).latex() == LyXFont::OFF - && text->GetFont(text->cursor.par, - text->cursor.pos).language()->lang != "hebrew") + && text->GetFont(current_view->buffer(),text->cursor.par(), + text->cursor.pos()).latex() == LyXFont::OFF + && text->GetFont(current_view->buffer(),text->cursor.par(), + text->cursor.pos()).language()->lang() != "hebrew") current_view->insertCorrectQuote(); else - text->InsertChar(str[i]); + text->InsertChar(current_view, str[i]); } } @@ -314,7 +314,7 @@ void TransManager::insert(string const & str, LyXText * text) // Could not find an encoding InsetLatexAccent ins(str); if (ins.CanDisplay()) { - text->InsertInset(new InsetLatexAccent(ins)); + text->InsertInset(current_view, new InsetLatexAccent(ins)); } else { insertVerbatim(str, text); } @@ -327,7 +327,7 @@ void TransManager::insert(string const & str, LyXText * text) void TransManager::deadkey(char c, tex_accent accent, LyXText * t) { - if (c == 0 && active_ != default_) { + if (c == 0 && active_ != &default_) { // A deadkey was pressed that cannot be printed // or a accent command was typed in the minibuffer KmodInfo i; @@ -338,7 +338,7 @@ void TransManager::deadkey(char c, tex_accent accent, LyXText * t) } } - if (active_ == default_ || c == 0) { + if (active_ == &default_ || c == 0) { KmodInfo i; i.accent = accent; i.allowed = lyx_accent_table[accent].native;