1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \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<EFBFBD>nnes
|
|
|
|
|
* \author Matthias Ettrich
|
|
|
|
|
* \author John Levon
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
|
#ifndef TRANS_MANAGER_H
|
|
|
|
|
#define TRANS_MANAGER_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-09-07 01:45:40 +00:00
|
|
|
|
#include "trans_decl.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-11-03 17:47:28 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
class LCursor;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
class LyXText;
|
|
|
|
|
class Trans;
|
|
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
|
/// Translation state
|
1999-09-27 18:44:28 +00:00
|
|
|
|
class TransState {
|
|
|
|
|
public:
|
|
|
|
|
///
|
1999-12-10 00:07:59 +00:00
|
|
|
|
virtual ~TransState() {}
|
2001-07-07 17:52:03 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
virtual docstring const normalkey(char_type) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
|
virtual bool backspace() = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
virtual docstring const deadkey(char_type, KmodInfo) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
static char_type const TOKEN_SEP;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Translation FSM
|
|
|
|
|
class TransFSMData {
|
|
|
|
|
protected:
|
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
|
virtual ~TransFSMData() {}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
char_type deadkey_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
|
|
|
|
KmodInfo deadkey_info_;
|
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
char_type deadkey2_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
|
|
|
|
KmodInfo deadkey2_info_;
|
2001-07-16 15:42:57 +00:00
|
|
|
|
///
|
|
|
|
|
Keyexc comb_info_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
|
TransState * init_state_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
|
TransState * deadkey_state_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
|
TransState * combined_state_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
TransFSMData();
|
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
|
TransState * currentState;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Init State
|
2003-08-11 09:09:01 +00:00
|
|
|
|
class TransInitState :virtual public TransFSMData, public TransState {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
1999-12-21 06:10:21 +00:00
|
|
|
|
///
|
|
|
|
|
TransInitState();
|
2001-07-07 17:52:03 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
virtual docstring const normalkey(char_type);
|
1999-12-21 06:10:21 +00:00
|
|
|
|
///
|
|
|
|
|
virtual bool backspace() { return true; }
|
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
virtual docstring const deadkey(char_type, KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Deadkey State
|
2000-08-07 20:58:24 +00:00
|
|
|
|
class TransDeadkeyState : virtual public TransFSMData, public TransState {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
1999-12-21 06:10:21 +00:00
|
|
|
|
///
|
|
|
|
|
TransDeadkeyState();
|
2001-07-07 17:52:03 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
virtual docstring const normalkey(char_type);
|
1999-12-21 06:10:21 +00:00
|
|
|
|
///
|
|
|
|
|
virtual bool backspace() {
|
1999-11-15 12:01:38 +00:00
|
|
|
|
currentState = init_state_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
1999-12-21 06:10:21 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
virtual docstring const deadkey(char_type, KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Combined State
|
2000-08-07 20:58:24 +00:00
|
|
|
|
class TransCombinedState : virtual public TransFSMData, public TransState {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
1999-12-21 06:10:21 +00:00
|
|
|
|
///
|
|
|
|
|
TransCombinedState();
|
2001-07-07 17:52:03 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
virtual docstring const normalkey(char_type);
|
1999-12-21 06:10:21 +00:00
|
|
|
|
///
|
|
|
|
|
virtual bool backspace() {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// cancel the second deadkey
|
1999-11-15 12:01:38 +00:00
|
|
|
|
deadkey2_ = 0;
|
|
|
|
|
deadkey2_info_.accent = TEX_NOACCENT;
|
|
|
|
|
currentState = deadkey_state_;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
1999-12-21 06:10:21 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
virtual docstring const deadkey(char_type, KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
2000-08-07 20:58:24 +00:00
|
|
|
|
class TransFSM : virtual public TransFSMData,
|
|
|
|
|
public TransInitState,
|
|
|
|
|
public TransDeadkeyState,
|
|
|
|
|
public TransCombinedState {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
TransFSM();
|
|
|
|
|
};
|
|
|
|
|
|
1999-12-21 06:10:21 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
1999-12-21 06:10:21 +00:00
|
|
|
|
class TransManager {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
|
|
|
|
TransFSM trans_fsm_;
|
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
|
Trans * active_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-11-03 17:47:28 +00:00
|
|
|
|
boost::scoped_ptr<Trans> t1_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-11-03 17:47:28 +00:00
|
|
|
|
boost::scoped_ptr<Trans> t2_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-03-06 19:29:58 +00:00
|
|
|
|
static Trans default_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
void insert(docstring const &, LyXText *, LCursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
TransManager();
|
|
|
|
|
///
|
2003-11-03 17:47:28 +00:00
|
|
|
|
~TransManager();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2006-04-09 00:26:19 +00:00
|
|
|
|
int setPrimary(std::string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2006-04-09 00:26:19 +00:00
|
|
|
|
int setSecondary(std::string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void enablePrimary();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void enableSecondary();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void disableKeymap();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
1999-12-21 06:10:21 +00:00
|
|
|
|
bool backspace() {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return trans_fsm_.currentState->backspace();
|
|
|
|
|
}
|
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
void translateAndInsert(char_type, LyXText *, LCursor &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
docstring const deadkey(char_type, KmodInfo);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
docstring const normalkey(char_type);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2007-03-31 08:12:08 +00:00
|
|
|
|
void deadkey(char_type, tex_accent, LyXText *, LCursor &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2001-07-07 17:52:03 +00:00
|
|
|
|
inline
|
2007-03-31 08:12:08 +00:00
|
|
|
|
docstring const TransManager::normalkey(char_type c)
|
2001-07-07 17:52:03 +00:00
|
|
|
|
{
|
|
|
|
|
return trans_fsm_.currentState->normalkey(c);
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2001-07-07 17:52:03 +00:00
|
|
|
|
inline
|
2007-03-31 08:12:08 +00:00
|
|
|
|
docstring const TransManager::deadkey(char_type c, KmodInfo t)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
|
return trans_fsm_.currentState->deadkey(c, t);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
|
#endif // TRANS_MANAGER_H
|