mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-24 18:43:37 +00:00
f2769c00c7
again (bug 3304) * src/intl.C (Intl::initKeyMapper): Don't set the char set of trans anymore * src/chset.[Ch]: delete, no longer needed * lib/kbd/*.cdef: ditto * src/lyxrc.[Ch]: remove RC_SCREEN_FONT_ENCODING and font_norm, these are no longer needed * src/lyxfunc.C: adapt to lyxrc changes * src/Makefile.am: remove deleted files * lib/Makefile.am: ditto * development/scons/scons_manifest.py: ditto * src/text3.C (LyXText::dispatch): reenable the kmap mechanism * src/trans_mgr.[Ch] (TransManager::setCharset): remove, no longer needed (TransManager::insert): remove, since it would be identical to insertVerbatim now (TransManager::insertVerbatim): rename to insert git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17665 a592a061-630c-0410-9148-cb99ea01b6c8
199 lines
3.3 KiB
C++
199 lines
3.3 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file trans_mgr.h
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Lars Gullik Bjønnes
|
|
* \author Matthias Ettrich
|
|
* \author John Levon
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#ifndef TRANS_MANAGER_H
|
|
#define TRANS_MANAGER_H
|
|
|
|
#include "trans_decl.h"
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
namespace lyx {
|
|
|
|
class LCursor;
|
|
class LyXText;
|
|
class Trans;
|
|
|
|
/// Translation state
|
|
class TransState {
|
|
public:
|
|
///
|
|
virtual ~TransState() {}
|
|
///
|
|
virtual docstring const normalkey(char_type) = 0;
|
|
///
|
|
virtual bool backspace() = 0;
|
|
///
|
|
virtual docstring const deadkey(char_type, KmodInfo) = 0;
|
|
///
|
|
static char_type const TOKEN_SEP;
|
|
};
|
|
|
|
|
|
/// Translation FSM
|
|
class TransFSMData {
|
|
protected:
|
|
///
|
|
virtual ~TransFSMData() {}
|
|
///
|
|
char_type deadkey_;
|
|
///
|
|
KmodInfo deadkey_info_;
|
|
///
|
|
char_type deadkey2_;
|
|
///
|
|
KmodInfo deadkey2_info_;
|
|
///
|
|
Keyexc comb_info_;
|
|
///
|
|
TransState * init_state_;
|
|
///
|
|
TransState * deadkey_state_;
|
|
///
|
|
TransState * combined_state_;
|
|
///
|
|
public:
|
|
///
|
|
TransFSMData();
|
|
///
|
|
TransState * currentState;
|
|
};
|
|
|
|
|
|
/// Init State
|
|
class TransInitState :virtual public TransFSMData, public TransState {
|
|
public:
|
|
///
|
|
TransInitState();
|
|
///
|
|
virtual docstring const normalkey(char_type);
|
|
///
|
|
virtual bool backspace() { return true; }
|
|
///
|
|
virtual docstring const deadkey(char_type, KmodInfo);
|
|
};
|
|
|
|
|
|
/// Deadkey State
|
|
class TransDeadkeyState : virtual public TransFSMData, public TransState {
|
|
public:
|
|
///
|
|
TransDeadkeyState();
|
|
///
|
|
virtual docstring const normalkey(char_type);
|
|
///
|
|
virtual bool backspace() {
|
|
currentState = init_state_;
|
|
return false;
|
|
}
|
|
///
|
|
virtual docstring const deadkey(char_type, KmodInfo);
|
|
};
|
|
|
|
|
|
/// Combined State
|
|
class TransCombinedState : virtual public TransFSMData, public TransState {
|
|
public:
|
|
///
|
|
TransCombinedState();
|
|
///
|
|
virtual docstring const normalkey(char_type);
|
|
///
|
|
virtual bool backspace() {
|
|
// cancel the second deadkey
|
|
deadkey2_ = 0;
|
|
deadkey2_info_.accent = TEX_NOACCENT;
|
|
currentState = deadkey_state_;
|
|
|
|
return false;
|
|
}
|
|
///
|
|
virtual docstring const deadkey(char_type, KmodInfo);
|
|
};
|
|
|
|
|
|
///
|
|
class TransFSM : virtual public TransFSMData,
|
|
public TransInitState,
|
|
public TransDeadkeyState,
|
|
public TransCombinedState {
|
|
public:
|
|
///
|
|
TransFSM();
|
|
};
|
|
|
|
|
|
///
|
|
class TransManager {
|
|
private:
|
|
///
|
|
TransFSM trans_fsm_;
|
|
///
|
|
Trans * active_;
|
|
///
|
|
boost::scoped_ptr<Trans> t1_;
|
|
///
|
|
boost::scoped_ptr<Trans> t2_;
|
|
///
|
|
static Trans default_;
|
|
///
|
|
void insert(docstring const &, LyXText *, LCursor & cur);
|
|
public:
|
|
///
|
|
TransManager();
|
|
///
|
|
~TransManager();
|
|
///
|
|
int setPrimary(std::string const &);
|
|
///
|
|
int setSecondary(std::string const &);
|
|
///
|
|
void enablePrimary();
|
|
///
|
|
void enableSecondary();
|
|
///
|
|
void disableKeymap();
|
|
///
|
|
bool backspace() {
|
|
return trans_fsm_.currentState->backspace();
|
|
}
|
|
///
|
|
void translateAndInsert(char_type, LyXText *, LCursor &);
|
|
///
|
|
docstring const deadkey(char_type, KmodInfo);
|
|
///
|
|
docstring const normalkey(char_type);
|
|
///
|
|
void deadkey(char_type, tex_accent, LyXText *, LCursor &);
|
|
};
|
|
|
|
|
|
inline
|
|
docstring const TransManager::normalkey(char_type c)
|
|
{
|
|
return trans_fsm_.currentState->normalkey(c);
|
|
}
|
|
|
|
|
|
inline
|
|
docstring const TransManager::deadkey(char_type c, KmodInfo t)
|
|
{
|
|
return trans_fsm_.currentState->deadkey(c, t);
|
|
}
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
#endif // TRANS_MANAGER_H
|