remove out-commented code

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3150 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-12-05 08:50:13 +00:00
parent 33a28bdc9c
commit c80187fbfc
8 changed files with 13 additions and 438 deletions

View File

@ -1,5 +1,11 @@
2001-12-05 Lars Gullik Bjønnes <larsbj@birdstep.com>
* trans_decl.h:
* trans_mgr.[Ch]:
* trans.[Ch]:
* lyxgluelength.C:
* lyxlength.C: remove out-commented code.
* BufferView_pimpl:
* CutAndPaste.C:
* DepTable.C:

View File

@ -19,20 +19,6 @@
#include "Lsstream.h"
#if 0
namespace {
// this is now here and in lyxlenght.h
int const num_units = LyXLength::UNIT_NONE;
// I am not sure if "mu" should be possible to select (Lgb)
char const * unit_name[num_units] = { "sp", "pt", "bp", "dd",
"mm", "pc", "cc", "cm",
"in", "ex", "em", "mu",
"%", "c%", "p%", "l%" };
}
#endif
LyXGlueLength::LyXGlueLength(LyXLength const & len)
: len_(len)

View File

@ -21,30 +21,6 @@
#include <cstdlib>
#if 0
namespace {
// this is now here and in lyxgluelength.C
int const num_units = LyXLength::UNIT_NONE;
// I am not sure if "mu" should be possible to select (Lgb)
char const * unit_name[num_units] = { "sp", "pt", "bp", "dd",
"mm", "pc", "cc", "cm",
"in", "ex", "em", "mu",
"%", "c%", "p%", "l%" };
LyXLength::UNIT unitFromString(string const & data)
{
int i = 0;
while (i < num_units && data != unit_name[i])
++i;
return static_cast<LyXLength::UNIT>(i);
}
}
#endif
LyXLength::LyXLength()
: val_(0), unit_(LyXLength::PT)

View File

@ -19,50 +19,13 @@ using std::endl;
// KmodInfo
KmodInfo::KmodInfo()
{
#if 0
exception_list = 0;
#endif
}
#if 0
// Default Trans
bool DefaultTrans::init_ = false;
DefaultTrans::DefaultTrans()
{
if (init_ == false) {
// Do initialization
init_ = true;
}
}
#if 0
string const DefaultTrans::process(char c, TransManager & k)
{
char dummy[2] = "?";
dummy[0] = c;
return k.normalkey(c, dummy);
}
#else
string const DefaultTrans::process(char c, TransManager & k)
{
return k.normalkey(c);
}
#endif
#endif
// Trans class
Trans::Trans()
{
#if 0
for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i)
kmod_list_[i] = 0;
#endif
}
@ -75,17 +38,6 @@ Trans::~Trans()
void Trans::InsertException(KmodException & exclist, char c,
string const & data, bool flag, tex_accent accent)
{
#if 0
keyexc p = new Keyexc;
p->next = exclist;
p->c = c;
p->data = data;
p->combined = flag;
p->accent = accent;
exclist = p;
#else
Keyexc p;
p.c = c;
p.data = data;
@ -94,42 +46,19 @@ void Trans::InsertException(KmodException & exclist, char c,
exclist.insert(exclist.begin(), p);
// or just
// exclist.push_back(p);
#endif
}
void Trans::FreeException(KmodException & exclist)
{
#if 0
Trans::keyexc p = exclist;
while (p) {
p = exclist->next;
delete exclist;
exclist = p;
}
#else
exclist.clear();
#endif
}
void Trans::FreeKeymap()
{
#if 0
for (int i = 0; i < 256; ++i)
if (!keymap_[i].empty()) {
keymap_[i].erase();
}
for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i)
if (kmod_list_[i]) {
FreeException(kmod_list_[i]->exception_list);
delete kmod_list_[i];
kmod_list_[i] = 0;
}
#else
kmod_list_.clear();
keymap_.clear();
#endif
}
@ -165,59 +94,19 @@ struct keyword_item kmapTags[K_LAST - 1] = {
tex_accent getkeymod(string const &);
#if 0
void Trans::AddDeadkey(tex_accent accent, string const & keys,
string const & allowed)
#else
void Trans::AddDeadkey(tex_accent accent, string const & keys)
#endif
{
#if 0
if (kmod_list_[accent]) {
FreeException(kmod_list_[accent]->exception_list);
delete kmod_list_[accent];
}
kmod_list_[accent] = new KmodInfo;
kmod_list_[accent]->data = keys;
kmod_list_[accent]->accent = accent;
#else
KmodInfo tmp;
tmp.data = keys;
tmp.accent = accent;
kmod_list_[accent] = tmp;
#endif
#if 0
if (allowed == "native") {
kmod_list_[accent]->allowed= lyx_accent_table[accent].native;
} else {
kmod_list_[accent]->allowed = allowed;
}
for (string::size_type i = 0; i < keys.length(); ++i) {
string & temp =
keymap_[static_cast<unsigned char>(keys[i])];
if (!temp.empty())
temp.erase();
// But the question remains: "Should we be allowed
// to change bindings, without unbinding first?"
// Lgb
temp += char(0);
temp += char(accent);
}
#else
for (string::size_type i = 0; i < keys.length(); ++i) {
string tmp;
tmp += char(0);
tmp += char(accent);
keymap_[keys[i]] = tmp;
}
#endif
#if 0
kmod_list_[accent]->exception_list = 0;
#endif
}
@ -292,11 +181,6 @@ int Trans::Load(LyXLex & lex)
tex_accent accent_2= getkeymod(str);
if (accent_2 == TEX_NOACCENT) return -1;
#if 0
if (kmod_list_[accent_1] == 0
|| kmod_list_[accent_2] == 0)
return -1;
#else
std::map<int, KmodInfo>::iterator it1 =
kmod_list_.find(accent_1);
std::map<int, KmodInfo>::iterator it2 =
@ -305,31 +189,9 @@ int Trans::Load(LyXLex & lex)
|| it2 == kmod_list_.end()) {
return -1;
}
#endif
// Find what key accent_2 is on - should
// check about accent_1 also
#if 0
int key = 0;
for (; key < 256; ++key) {
if (!keymap_[key].empty()
&& keymap_[key][0] == 0
&& keymap_[key][1] == accent_2)
break;
}
string allowed;
if (lex.next()) {
allowed = lex.GetString();
lyxerr[Debug::KBMAP] << "allowed: "
<< allowed << endl;
} else
return -1;
InsertException(kmod_list_[accent_1].exception_list,
static_cast<char>(key), allowed,
true, accent_2);
#else
std::map<int, string>::iterator it = keymap_.begin();
std::map<int, string>::iterator end = keymap_.end();
for (; it != end; ++it) {
@ -350,7 +212,6 @@ int Trans::Load(LyXLex & lex)
InsertException(kmod_list_[accent_1].exception_list,
static_cast<char>(it->first), allowed,
true, accent_2);
#endif
}
break;
case KMAP: {
@ -427,41 +288,15 @@ int Trans::Load(LyXLex & lex)
bool Trans::isAccentDefined(tex_accent accent, KmodInfo & i) const
{
#if 0
if (kmod_list_[accent] != 0) {
i = *kmod_list_[accent];
return true;
}
return false;
#else
std::map<int, KmodInfo>::const_iterator cit = kmod_list_.find(accent);
if (cit != kmod_list_.end()) {
i = cit->second;
return true;
}
return false;
#endif
}
#if 0
string const Trans::process(char c, TransManager & k)
{
string dt("?");
string const t = Match(static_cast<unsigned char>(c));
if (t.empty() && c != 0) {
dt[0] = c;
return k.normalkey(c, dt);
} else if (!t.empty() && t[0] != char(0)) {
dt = t;
return k.normalkey(c, dt);
} else {
return k.deadkey(c,
*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));
@ -472,16 +307,10 @@ string const Trans::process(char c, TransManager & k)
//return k.normalkey(c);
return t;
} else {
#if 0
return k.deadkey(c,
*kmod_list_[static_cast<tex_accent>(t[1])]);
#else
return k.deadkey(c,
kmod_list_[static_cast<tex_accent>(t[1])]);
#endif
}
}
#endif
int Trans::Load(string const & language)

View File

@ -16,36 +16,6 @@ class LyXLex;
class TransManager;
#if 0
/**
TransInterface: the interface that every translation class
should obey too.
Visitor pattern applied here
*/
class TransInterface {
public:
///
virtual string const process(char, TransManager &) = 0;
///
virtual bool isAccentDefined(tex_accent, KmodInfo &) const = 0;
};
/**
DefaultTrans: the default translation class. Holds info
on tex-accents. Monostate
*/
class DefaultTrans : public TransInterface {
public:
///
DefaultTrans();
///
virtual string const process(char, TransManager &);
private:
///
static bool init_;
};
#endif
/**
Trans: holds a .kmap file
*/
@ -69,25 +39,14 @@ public:
bool isAccentDefined(tex_accent, KmodInfo &) const;
private:
#if 0
///
typedef KmodInfo kmod_list_decl;
///
typedef KmodException keyexc;
#endif
#if 0
///
void AddDeadkey(tex_accent, string const &, string const &);
#else
///
void AddDeadkey(tex_accent, string const &);
#endif
///
void FreeKeymap();
///
int Load(LyXLex &);
///
inline string const & Match(unsigned char c);
string const & Match(unsigned char c);
///
void InsertException(KmodException & exclist, char c,
string const & data, bool = false,
@ -97,36 +56,23 @@ private:
///
string name_;
#if 0
///
string keymap_[256];
#else
std::map<int, string> keymap_;
#endif
#if 0
///
kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1];
#else
///
//KmodInfo * kmod_list_[TEX_MAX_ACCENT+1];
std::map<int, KmodInfo> kmod_list_;
#endif
};
///
inline
string const & Trans::Match(unsigned char c)
{
#if 0
return keymap_[c];
#else
std::map<int, string>::iterator it = keymap_.find(c);
if (it != keymap_.end()) {
return it->second;
}
static string dummy;
return dummy;
#endif
}
#endif

View File

@ -2,34 +2,26 @@
#ifndef Trans_Decl_h
#define Trans_Decl_h
#include <list>
#include "LString.h"
#include "tex-accent.h"
#include <list>
///
struct Keyexc {
/// character to make exception
char c;
/// exception data
string data;
#if 0
///
Keyexc * next;
#endif
/// Combination with another deadkey
bool combined;
/// The accent comined with
tex_accent accent;
};
#if 0
///
typedef Keyexc * KmodException;
#else
///
typedef std::list<Keyexc> KmodException;
#endif
///
struct KmodInfo {
@ -37,10 +29,6 @@ struct KmodInfo {
string data;
///
tex_accent accent;
#if 0
///
string allowed;
#endif
///
KmodException exception_list;
///

View File

@ -29,9 +29,6 @@ TransFSMData::TransFSMData()
{
deadkey_ = deadkey2_ = 0;
deadkey_info_.accent = deadkey2_info_.accent = TEX_NOACCENT;
#if 0
comb_info_ = 0;
#endif
}
@ -46,23 +43,12 @@ TransInitState::TransInitState()
}
#if 0
string const TransInitState::normalkey(char c, string const & t)
{
string res;
if (!t.empty()) res = t;
else res = c;
return res;
}
#else
string const TransInitState::normalkey(char c)
{
string res;
res = c;
return res;
}
#endif
string const TransInitState::deadkey(char c, KmodInfo d)
@ -81,56 +67,8 @@ TransDeadkeyState::TransDeadkeyState()
}
#if 0
string const TransDeadkeyState::normalkey(char c, string const & trans)
{
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) {
// Not an exception. Check if it allowed
if (countChar(deadkey_info_.allowed, c) > 0) {
res = DoAccent(c, deadkey_info_.accent);
} else {
// Not allowed
if (deadkey_!= 0)
res = deadkey_;
res+= TOKEN_SEP;
res+= trans;
}
}
currentState = init_state_;
return res;
}
#else
string const TransDeadkeyState::normalkey(char c)
{
#if 0
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;
#else
string res;
KmodException::iterator it = deadkey_info_.exception_list.begin();
@ -147,9 +85,7 @@ string const TransDeadkeyState::normalkey(char c)
}
currentState = init_state_;
return res;
#endif
}
#endif
string const TransDeadkeyState::deadkey(char c, KmodInfo d)
@ -166,28 +102,6 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d)
}
// Check if it is a combination or an exception
#if 0
KmodException l;
l = deadkey_info_.exception_list;
while (l) {
if (l->combined == true && l->accent == d.accent) {
deadkey2_ = c;
deadkey2_info_ = d;
comb_info_ = l;
currentState = combined_state_;
return string();
}
if (l->c == c) {
res = l->data;
deadkey_ = 0;
deadkey_info_.accent = TEX_NOACCENT;
currentState = init_state_;
return res;
}
l = l->next;
}
#else
KmodException::const_iterator cit = deadkey_info_.exception_list.begin();
KmodException::const_iterator end = deadkey_info_.exception_list.end();
for (; cit != end; ++cit) {
@ -206,7 +120,7 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d)
return res;
}
}
#endif
// Not a combination or an exception.
// Output deadkey1 and keep deadkey2
@ -225,39 +139,13 @@ TransCombinedState::TransCombinedState()
}
#if 0
string const TransCombinedState::normalkey(char c, string const & trans)
{
string res;
// Check if the key is allowed on the combination
if (countChar(comb_info_->data, c) > 0) {
string const temp = DoAccent(c, deadkey2_info_.accent);
res = DoAccent(temp, deadkey_info_.accent);
currentState = init_state_;
} else {
// Not allowed. Output deadkey1 and check deadkey2 + c
if (deadkey_ != 0)
res += deadkey_;
res += TOKEN_SEP;
deadkey_ = deadkey2_;
deadkey_info_ = deadkey2_info_;
// Call deadkey state and leave it to setup the FSM
res += deadkey_state_->normalkey(c, trans);
}
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);
string const res = DoAccent(temp, deadkey_info_.accent);
currentState = init_state_;
return res;
}
#endif
string const TransCombinedState::deadkey(char c, KmodInfo d)
@ -420,13 +308,7 @@ void TransManager::deadkey(char c, tex_accent accent, LyXText * t)
if (active_ == &default_ || c == 0) {
KmodInfo i;
i.accent = accent;
#if 0
i.allowed = lyx_accent_table[accent].native;
#endif
i.data.erase();
#if 0
i.exception_list = 0;
#endif
string res = trans_fsm_.currentState->deadkey(c, i);
insert(res, t);
} else {

View File

@ -19,13 +19,8 @@ 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;
///
@ -48,13 +43,8 @@ protected:
char deadkey2_;
///
KmodInfo deadkey2_info_;
#if 0
///
KmodException comb_info_;
#else
///
Keyexc comb_info_;
#endif
///
TransState * init_state_;
///
@ -75,13 +65,8 @@ 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; }
///
@ -94,13 +79,8 @@ 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_;
@ -116,13 +96,8 @@ 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
@ -192,31 +167,18 @@ public:
void TranslateAndInsert(char, LyXText *);
///
string const deadkey(char, KmodInfo);
#if 0
///
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