simplify normalkey

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2201 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-07-07 17:52:03 +00:00
parent 823daa40f1
commit 9f42e337f0
4 changed files with 109 additions and 13 deletions

View File

@ -1,3 +1,8 @@
2001-07-07 Lars Gullik Bjønnes <larsbj@birdstep.com>
* trans_mgr.[Ch]: simplify normalkey to only take a char as arg.
* trans.C: changes because of the above.
2001-07-07 Dekel Tsur <dekelts@tau.ac.il>
* text2.C (setCounter): Fix counters bug with bibliography layout.

View File

@ -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<unsigned char>(c));
@ -364,6 +370,21 @@ string const Trans::process(char c, TransManager & k)
*kmod_list_[static_cast<tex_accent>(t[1])]);
}
}
#else
string const Trans::process(char c, TransManager & k)
{
string const t = Match(static_cast<unsigned char>(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<tex_accent>(t[1])]);
}
}
#endif
int Trans::Load(string const & language)

View File

@ -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)

View File

@ -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);