diff --git a/src/ChangeLog b/src/ChangeLog index f756bcff8d..3d491c90ff 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-07-07 Lars Gullik Bjønnes + + * trans_mgr.[Ch]: simplify normalkey to only take a char as arg. + * trans.C: changes because of the above. + 2001-07-07 Dekel Tsur * text2.C (setCounter): Fix counters bug with bibliography layout. diff --git a/src/trans.C b/src/trans.C index e324cc46d9..403ac0630a 100644 --- a/src/trans.C +++ b/src/trans.C @@ -35,6 +35,7 @@ DefaultTrans::DefaultTrans() } +#if 0 string const DefaultTrans::process(char c, TransManager & k) { char dummy[2] = "?"; @@ -42,6 +43,12 @@ string const DefaultTrans::process(char c, TransManager & k) return k.normalkey(c, dummy); } +#else +string const DefaultTrans::process(char c, TransManager & k) +{ + return k.normalkey(c); +} +#endif // Trans class @@ -346,10 +353,9 @@ bool Trans::isAccentDefined(tex_accent accent, KmodInfo & i) const } +#if 0 string const Trans::process(char c, TransManager & k) { - //string dummy("?"); - //string dt = dummy; string dt("?"); string const t = Match(static_cast(c)); @@ -364,6 +370,21 @@ string const Trans::process(char c, TransManager & k) *kmod_list_[static_cast(t[1])]); } } +#else +string const Trans::process(char c, TransManager & k) +{ + string const t = Match(static_cast(c)); + + if (t.empty() && c != 0) { + return k.normalkey(c); + } else if (!t.empty() && t[0] != char(0)) { + return k.normalkey(c); + } else { + return k.deadkey(c, + *kmod_list_[static_cast(t[1])]); + } +} +#endif int Trans::Load(string const & language) diff --git a/src/trans_mgr.C b/src/trans_mgr.C index cbef7d5b94..f158438e6d 100644 --- a/src/trans_mgr.C +++ b/src/trans_mgr.C @@ -45,6 +45,7 @@ TransInitState::TransInitState() } +#if 0 string const TransInitState::normalkey(char c, string const & t) { string res; @@ -53,6 +54,14 @@ string const TransInitState::normalkey(char c, string const & t) return res; } +#else +string const TransInitState::normalkey(char c) +{ + string res; + res = c; + return res; +} +#endif string const TransInitState::deadkey(char c, KmodInfo d) @@ -71,6 +80,7 @@ TransDeadkeyState::TransDeadkeyState() } +#if 0 string const TransDeadkeyState::normalkey(char c, string const & trans) { string res; @@ -85,12 +95,9 @@ string const TransDeadkeyState::normalkey(char c, string const & trans) l = l->next; } if (l == 0) { -#if 0 // Not an exception. Check if it allowed if (countChar(deadkey_info_.allowed, c) > 0) { -#endif res = DoAccent(c, deadkey_info_.accent); -#if 0 } else { // Not allowed if (deadkey_!= 0) @@ -98,11 +105,31 @@ string const TransDeadkeyState::normalkey(char c, string const & trans) res+= TOKEN_SEP; res+= trans; } -#endif } currentState = init_state_; return res; } +#else +string const TransDeadkeyState::normalkey(char c) +{ + string res; + + // Check if it is an exception + KmodException l = deadkey_info_.exception_list; + while(l != 0) { + if (l->c == c) { + res = l->data; + break; + } + l = l->next; + } + if (l == 0) { + res = DoAccent(c, deadkey_info_.accent); + } + currentState = init_state_; + return res; +} +#endif string const TransDeadkeyState::deadkey(char c, KmodInfo d) @@ -122,7 +149,7 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d) KmodException l; l = deadkey_info_.exception_list; - while(l) { + while (l) { if (l->combined == true && l->accent == d.accent) { deadkey2_ = c; deadkey2_info_ = d; @@ -158,18 +185,16 @@ TransCombinedState::TransCombinedState() } +#if 0 string const TransCombinedState::normalkey(char c, string const & trans) { string res; -#if 0 // Check if the key is allowed on the combination if (countChar(comb_info_->data, c) > 0) { -#endif string const temp = DoAccent(c, deadkey2_info_.accent); res = DoAccent(temp, deadkey_info_.accent); currentState = init_state_; -#if 0 } else { // Not allowed. Output deadkey1 and check deadkey2 + c if (deadkey_ != 0) @@ -180,9 +205,19 @@ string const TransCombinedState::normalkey(char c, string const & trans) // Call deadkey state and leave it to setup the FSM res += deadkey_state_->normalkey(c, trans); } -#endif return res; } +#else +string const TransCombinedState::normalkey(char c) +{ + string res; + + string const temp = DoAccent(c, deadkey2_info_.accent); + res = DoAccent(temp, deadkey_info_.accent); + currentState = init_state_; + return res; +} +#endif string const TransCombinedState::deadkey(char c, KmodInfo d) diff --git a/src/trans_mgr.h b/src/trans_mgr.h index 842c07ae2e..2145f6a5df 100644 --- a/src/trans_mgr.h +++ b/src/trans_mgr.h @@ -19,8 +19,13 @@ class TransState { public: /// virtual ~TransState() {} +#if 0 /// virtual string const normalkey(char, string const &) = 0; +#else + /// + virtual string const normalkey(char) = 0; +#endif /// virtual bool backspace() = 0; /// @@ -65,8 +70,13 @@ class TransInitState : virtual public TransFSMData, public TransState { public: /// TransInitState(); +#if 0 /// virtual string const normalkey(char, string const &); +#else + /// + virtual string const normalkey(char); +#endif /// virtual bool backspace() { return true; } /// @@ -79,8 +89,13 @@ class TransDeadkeyState : virtual public TransFSMData, public TransState { public: /// TransDeadkeyState(); +#if 0 /// virtual string const normalkey(char, string const &); +#else + /// + virtual string const normalkey(char); +#endif /// virtual bool backspace() { currentState = init_state_; @@ -96,8 +111,13 @@ class TransCombinedState : virtual public TransFSMData, public TransState { public: /// TransCombinedState(); +#if 0 /// virtual string const normalkey(char, string const &); +#else + /// + virtual string const normalkey(char); +#endif /// virtual bool backspace() { // cancel the second deadkey @@ -166,20 +186,35 @@ public: /// void TranslateAndInsert(char, LyXText *); /// - inline string const deadkey(char, KmodInfo); + string const deadkey(char, KmodInfo); +#if 0 /// - inline string const normalkey(char, string const &); + string const normalkey(char, string const &); +#else + /// + string const normalkey(char); +#endif /// void deadkey(char, tex_accent, LyXText *); }; +#if 0 +inline string const TransManager::normalkey(char c, string const & t) { return trans_fsm_.currentState->normalkey(c, t); } +#else +inline +string const TransManager::normalkey(char c) +{ + return trans_fsm_.currentState->normalkey(c); +} +#endif +inline string const TransManager::deadkey(char c, KmodInfo t) { return trans_fsm_.currentState->deadkey(c, t);