mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-20 06:49:56 +00:00
simplify normalkey
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2201 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
823daa40f1
commit
9f42e337f0
@ -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>
|
2001-07-07 Dekel Tsur <dekelts@tau.ac.il>
|
||||||
|
|
||||||
* text2.C (setCounter): Fix counters bug with bibliography layout.
|
* text2.C (setCounter): Fix counters bug with bibliography layout.
|
||||||
|
25
src/trans.C
25
src/trans.C
@ -35,6 +35,7 @@ DefaultTrans::DefaultTrans()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
string const DefaultTrans::process(char c, TransManager & k)
|
string const DefaultTrans::process(char c, TransManager & k)
|
||||||
{
|
{
|
||||||
char dummy[2] = "?";
|
char dummy[2] = "?";
|
||||||
@ -42,6 +43,12 @@ string const DefaultTrans::process(char c, TransManager & k)
|
|||||||
|
|
||||||
return k.normalkey(c, dummy);
|
return k.normalkey(c, dummy);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
string const DefaultTrans::process(char c, TransManager & k)
|
||||||
|
{
|
||||||
|
return k.normalkey(c);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Trans class
|
// 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 const Trans::process(char c, TransManager & k)
|
||||||
{
|
{
|
||||||
//string dummy("?");
|
|
||||||
//string dt = dummy;
|
|
||||||
string dt("?");
|
string dt("?");
|
||||||
string const t = Match(static_cast<unsigned char>(c));
|
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])]);
|
*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)
|
int Trans::Load(string const & language)
|
||||||
|
@ -45,6 +45,7 @@ TransInitState::TransInitState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
string const TransInitState::normalkey(char c, string const & t)
|
string const TransInitState::normalkey(char c, string const & t)
|
||||||
{
|
{
|
||||||
string res;
|
string res;
|
||||||
@ -53,6 +54,14 @@ string const TransInitState::normalkey(char c, string const & t)
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
string const TransInitState::normalkey(char c)
|
||||||
|
{
|
||||||
|
string res;
|
||||||
|
res = c;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
string const TransInitState::deadkey(char c, KmodInfo d)
|
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 const TransDeadkeyState::normalkey(char c, string const & trans)
|
||||||
{
|
{
|
||||||
string res;
|
string res;
|
||||||
@ -85,12 +95,9 @@ string const TransDeadkeyState::normalkey(char c, string const & trans)
|
|||||||
l = l->next;
|
l = l->next;
|
||||||
}
|
}
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
#if 0
|
|
||||||
// Not an exception. Check if it allowed
|
// Not an exception. Check if it allowed
|
||||||
if (countChar(deadkey_info_.allowed, c) > 0) {
|
if (countChar(deadkey_info_.allowed, c) > 0) {
|
||||||
#endif
|
|
||||||
res = DoAccent(c, deadkey_info_.accent);
|
res = DoAccent(c, deadkey_info_.accent);
|
||||||
#if 0
|
|
||||||
} else {
|
} else {
|
||||||
// Not allowed
|
// Not allowed
|
||||||
if (deadkey_!= 0)
|
if (deadkey_!= 0)
|
||||||
@ -98,11 +105,31 @@ string const TransDeadkeyState::normalkey(char c, string const & trans)
|
|||||||
res+= TOKEN_SEP;
|
res+= TOKEN_SEP;
|
||||||
res+= trans;
|
res+= trans;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
currentState = init_state_;
|
currentState = init_state_;
|
||||||
return res;
|
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)
|
string const TransDeadkeyState::deadkey(char c, KmodInfo d)
|
||||||
@ -122,7 +149,7 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d)
|
|||||||
KmodException l;
|
KmodException l;
|
||||||
l = deadkey_info_.exception_list;
|
l = deadkey_info_.exception_list;
|
||||||
|
|
||||||
while(l) {
|
while (l) {
|
||||||
if (l->combined == true && l->accent == d.accent) {
|
if (l->combined == true && l->accent == d.accent) {
|
||||||
deadkey2_ = c;
|
deadkey2_ = c;
|
||||||
deadkey2_info_ = d;
|
deadkey2_info_ = d;
|
||||||
@ -158,18 +185,16 @@ TransCombinedState::TransCombinedState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
string const TransCombinedState::normalkey(char c, string const & trans)
|
string const TransCombinedState::normalkey(char c, string const & trans)
|
||||||
{
|
{
|
||||||
string res;
|
string res;
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Check if the key is allowed on the combination
|
// Check if the key is allowed on the combination
|
||||||
if (countChar(comb_info_->data, c) > 0) {
|
if (countChar(comb_info_->data, c) > 0) {
|
||||||
#endif
|
|
||||||
string const temp = DoAccent(c, deadkey2_info_.accent);
|
string const temp = DoAccent(c, deadkey2_info_.accent);
|
||||||
res = DoAccent(temp, deadkey_info_.accent);
|
res = DoAccent(temp, deadkey_info_.accent);
|
||||||
currentState = init_state_;
|
currentState = init_state_;
|
||||||
#if 0
|
|
||||||
} else {
|
} else {
|
||||||
// Not allowed. Output deadkey1 and check deadkey2 + c
|
// Not allowed. Output deadkey1 and check deadkey2 + c
|
||||||
if (deadkey_ != 0)
|
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
|
// Call deadkey state and leave it to setup the FSM
|
||||||
res += deadkey_state_->normalkey(c, trans);
|
res += deadkey_state_->normalkey(c, trans);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return res;
|
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)
|
string const TransCombinedState::deadkey(char c, KmodInfo d)
|
||||||
|
@ -19,8 +19,13 @@ class TransState {
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
virtual ~TransState() {}
|
virtual ~TransState() {}
|
||||||
|
#if 0
|
||||||
///
|
///
|
||||||
virtual string const normalkey(char, string const &) = 0;
|
virtual string const normalkey(char, string const &) = 0;
|
||||||
|
#else
|
||||||
|
///
|
||||||
|
virtual string const normalkey(char) = 0;
|
||||||
|
#endif
|
||||||
///
|
///
|
||||||
virtual bool backspace() = 0;
|
virtual bool backspace() = 0;
|
||||||
///
|
///
|
||||||
@ -65,8 +70,13 @@ class TransInitState : virtual public TransFSMData, public TransState {
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
TransInitState();
|
TransInitState();
|
||||||
|
#if 0
|
||||||
///
|
///
|
||||||
virtual string const normalkey(char, string const &);
|
virtual string const normalkey(char, string const &);
|
||||||
|
#else
|
||||||
|
///
|
||||||
|
virtual string const normalkey(char);
|
||||||
|
#endif
|
||||||
///
|
///
|
||||||
virtual bool backspace() { return true; }
|
virtual bool backspace() { return true; }
|
||||||
///
|
///
|
||||||
@ -79,8 +89,13 @@ class TransDeadkeyState : virtual public TransFSMData, public TransState {
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
TransDeadkeyState();
|
TransDeadkeyState();
|
||||||
|
#if 0
|
||||||
///
|
///
|
||||||
virtual string const normalkey(char, string const &);
|
virtual string const normalkey(char, string const &);
|
||||||
|
#else
|
||||||
|
///
|
||||||
|
virtual string const normalkey(char);
|
||||||
|
#endif
|
||||||
///
|
///
|
||||||
virtual bool backspace() {
|
virtual bool backspace() {
|
||||||
currentState = init_state_;
|
currentState = init_state_;
|
||||||
@ -96,8 +111,13 @@ class TransCombinedState : virtual public TransFSMData, public TransState {
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
TransCombinedState();
|
TransCombinedState();
|
||||||
|
#if 0
|
||||||
///
|
///
|
||||||
virtual string const normalkey(char, string const &);
|
virtual string const normalkey(char, string const &);
|
||||||
|
#else
|
||||||
|
///
|
||||||
|
virtual string const normalkey(char);
|
||||||
|
#endif
|
||||||
///
|
///
|
||||||
virtual bool backspace() {
|
virtual bool backspace() {
|
||||||
// cancel the second deadkey
|
// cancel the second deadkey
|
||||||
@ -166,20 +186,35 @@ public:
|
|||||||
///
|
///
|
||||||
void TranslateAndInsert(char, LyXText *);
|
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 *);
|
void deadkey(char, tex_accent, LyXText *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
inline
|
||||||
string const TransManager::normalkey(char c, string const & t)
|
string const TransManager::normalkey(char c, string const & t)
|
||||||
{
|
{
|
||||||
return trans_fsm_.currentState->normalkey(c, 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)
|
string const TransManager::deadkey(char c, KmodInfo t)
|
||||||
{
|
{
|
||||||
return trans_fsm_.currentState->deadkey(c, t);
|
return trans_fsm_.currentState->deadkey(c, t);
|
||||||
|
Loading…
Reference in New Issue
Block a user