lyx_mirror/src/trans_mgr.h
Abdelrazak Younes eb651c3d61 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

206 lines
3.4 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 "chset.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 std::string const normalkey(char) = 0;
///
virtual bool backspace() = 0;
///
virtual std::string const deadkey(char, KmodInfo) = 0;
///
static char const TOKEN_SEP;
};
/// Translation FSM
class TransFSMData {
protected:
///
virtual ~TransFSMData() {}
///
char deadkey_;
///
KmodInfo deadkey_info_;
///
char 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 std::string const normalkey(char);
///
virtual bool backspace() { return true; }
///
virtual std::string const deadkey(char, KmodInfo);
};
/// Deadkey State
class TransDeadkeyState : virtual public TransFSMData, public TransState {
public:
///
TransDeadkeyState();
///
virtual std::string const normalkey(char);
///
virtual bool backspace() {
currentState = init_state_;
return false;
}
///
virtual std::string const deadkey(char, KmodInfo);
};
/// Combined State
class TransCombinedState : virtual public TransFSMData, public TransState {
public:
///
TransCombinedState();
///
virtual std::string const normalkey(char);
///
virtual bool backspace() {
// cancel the second deadkey
deadkey2_ = 0;
deadkey2_info_.accent = TEX_NOACCENT;
currentState = deadkey_state_;
return false;
}
///
virtual std::string const deadkey(char, 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_;
///
CharacterSet chset_;
///
void insert(std::string const &, LyXText *, LCursor & cur);
///
void insertVerbatim(std::string const &, LyXText *, LCursor & cur);
public:
///
TransManager();
///
~TransManager();
///
int setPrimary(std::string const &);
///
int setSecondary(std::string const &);
///
void enablePrimary();
///
void enableSecondary();
///
void disableKeymap();
///
bool setCharset(std::string const &);
///
bool backspace() {
return trans_fsm_.currentState->backspace();
}
///
void translateAndInsert(char, LyXText *, LCursor &);
///
std::string const deadkey(char, KmodInfo);
///
std::string const normalkey(char);
///
void deadkey(char, tex_accent, LyXText *, LCursor &);
};
inline
std::string const TransManager::normalkey(char c)
{
return trans_fsm_.currentState->normalkey(c);
}
inline
std::string const TransManager::deadkey(char c, KmodInfo t)
{
return trans_fsm_.currentState->deadkey(c, t);
}
} // namespace lyx
#endif // TRANS_MANAGER_H