mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-20 15:01:58 +00:00
*** empty log message ***
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2664 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0db77361d9
commit
8c39ec9370
@ -1,3 +1,7 @@
|
|||||||
|
2001-08-17 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* math_hash.C: Use std::map instead of faking it
|
||||||
|
|
||||||
2001-09-02 Dekel Tsur <dekelts@tau.ac.il>
|
2001-09-02 Dekel Tsur <dekelts@tau.ac.il>
|
||||||
|
|
||||||
* math_hash.C (in_word_set): Initialize symbol table even when
|
* math_hash.C (in_word_set): Initialize symbol table even when
|
||||||
|
@ -6,20 +6,12 @@
|
|||||||
#include "support/filetools.h" // LibFileSearch
|
#include "support/filetools.h" // LibFileSearch
|
||||||
#include "support/lyxfunctional.h"
|
#include "support/lyxfunctional.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using std::endl;
|
|
||||||
|
|
||||||
bool operator<(const latexkeys & a, const latexkeys & b)
|
|
||||||
{
|
|
||||||
return string(a.name) < string(b.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// This lists needs to remain sorted all the time!
|
|
||||||
|
|
||||||
struct latexkeys_a {
|
struct latexkeys_a {
|
||||||
///
|
///
|
||||||
char const * name;
|
char const * name;
|
||||||
@ -141,13 +133,39 @@ latexkeys_a wordlist_array[] =
|
|||||||
{"{", LM_TK_SPECIAL, '{'},
|
{"{", LM_TK_SPECIAL, '{'},
|
||||||
{"|", LM_TK_UNDEF, '|'},
|
{"|", LM_TK_UNDEF, '|'},
|
||||||
{"}", LM_TK_SPECIAL, '}'},
|
{"}", LM_TK_SPECIAL, '}'},
|
||||||
{"", LM_TK_SPECIAL, 0}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
std::vector<latexkeys> wordlist;
|
std::map<string, latexkeys> wordlist;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MathTokenEnum tokenEnum(const string & font)
|
||||||
|
{
|
||||||
|
if (font == "cmr")
|
||||||
|
return LM_TK_CMR;
|
||||||
|
if (font == "cmsy")
|
||||||
|
return LM_TK_CMSY;
|
||||||
|
if (font == "cmm")
|
||||||
|
return LM_TK_CMM;
|
||||||
|
if (font == "cmex")
|
||||||
|
return LM_TK_CMEX;
|
||||||
|
if (font == "msa")
|
||||||
|
return LM_TK_MSA;
|
||||||
|
if (font == "msb")
|
||||||
|
return LM_TK_MSB;
|
||||||
|
return LM_TK_SYM;
|
||||||
|
}
|
||||||
|
|
||||||
|
MathSymbolTypes symbolType(const string & type)
|
||||||
|
{
|
||||||
|
if (type == "mathrel")
|
||||||
|
return LMB_RELATION;
|
||||||
|
if (type == "mathbin")
|
||||||
|
return LMB_OPERATOR;
|
||||||
|
return LMB_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
bool initialized = false;
|
|
||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
@ -156,84 +174,53 @@ void ReadSymbols(string const & filename)
|
|||||||
{
|
{
|
||||||
LyXLex lex(0, 0);
|
LyXLex lex(0, 0);
|
||||||
lex.setFile(filename);
|
lex.setFile(filename);
|
||||||
while (lex.isOK()) {
|
while (lex.isOK() && lex.next()) {
|
||||||
latexkeys tmp;
|
latexkeys tmp;
|
||||||
string font;
|
tmp.name = lex.getString();
|
||||||
string type;
|
|
||||||
|
|
||||||
if (lex.next())
|
if (lex.next())
|
||||||
tmp.name = lex.getString();
|
tmp.token = tokenEnum(lex.getString());
|
||||||
else
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (lex.next())
|
|
||||||
font = lex.getString();
|
|
||||||
if (lex.next())
|
if (lex.next())
|
||||||
tmp.latex_font_id = lex.getInteger();
|
tmp.latex_font_id = lex.getInteger();
|
||||||
if (lex.next())
|
if (lex.next())
|
||||||
tmp.id = lex.getInteger();
|
tmp.id = lex.getInteger();
|
||||||
if (lex.next())
|
if (lex.next())
|
||||||
type = lex.getString();
|
tmp.type = symbolType(lex.getString());
|
||||||
|
wordlist[tmp.name] = tmp;
|
||||||
if (font == "cmr")
|
|
||||||
tmp.token = LM_TK_CMR;
|
|
||||||
else if (font == "cmsy")
|
|
||||||
tmp.token = LM_TK_CMSY;
|
|
||||||
else if (font == "cmm")
|
|
||||||
tmp.token = LM_TK_CMM;
|
|
||||||
else if (font == "cmex")
|
|
||||||
tmp.token = LM_TK_CMEX;
|
|
||||||
else if (font == "msa")
|
|
||||||
tmp.token = LM_TK_MSA;
|
|
||||||
else if (font == "msb")
|
|
||||||
tmp.token = LM_TK_MSB;
|
|
||||||
else
|
|
||||||
tmp.token = LM_TK_SYM;
|
|
||||||
|
|
||||||
if (type == "mathrel")
|
|
||||||
tmp.type = LMB_RELATION;
|
|
||||||
else if (type == "mathbin")
|
|
||||||
tmp.type = LMB_OPERATOR;
|
|
||||||
else
|
|
||||||
tmp.type = LMB_NONE;
|
|
||||||
|
|
||||||
wordlist.push_back(tmp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InitSymbols()
|
void initSymbols()
|
||||||
{
|
{
|
||||||
for (latexkeys_a * p = wordlist_array; !string(p->name).empty(); ++p) {
|
unsigned const n = sizeof(wordlist_array) / sizeof(wordlist_array[0]);
|
||||||
|
for (latexkeys_a * p = wordlist_array; p != wordlist_array + n; ++p) {
|
||||||
latexkeys tmp;
|
latexkeys tmp;
|
||||||
tmp.name = p->name;
|
tmp.name = p->name;
|
||||||
tmp.token = p->token;
|
tmp.token = p->token;
|
||||||
tmp.id = p->id;
|
tmp.id = p->id;
|
||||||
tmp.type = LMB_NONE;
|
tmp.type = LMB_NONE;
|
||||||
tmp.latex_font_id = 0;
|
tmp.latex_font_id = 0;
|
||||||
wordlist.push_back(tmp);
|
wordlist[p->name] = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
lyxerr[Debug::MATHED] << "Reading symbols file\n";
|
lyxerr[Debug::MATHED] << "Reading symbols file\n";
|
||||||
string const file = LibFileSearch(string(), "symbols");
|
string const file = LibFileSearch(string(), "symbols");
|
||||||
if (file.empty())
|
if (file.empty())
|
||||||
lyxerr << "Could not find symbols file" << endl;
|
lyxerr << "Could not find symbols file\n";
|
||||||
else
|
else
|
||||||
ReadSymbols(file);
|
ReadSymbols(file);
|
||||||
|
|
||||||
std::sort(wordlist.begin(), wordlist.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
latexkeys const * in_word_set(string const & str)
|
latexkeys const * in_word_set(string const & str)
|
||||||
{
|
{
|
||||||
|
static bool initialized = false;
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
InitSymbols();
|
initSymbols();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<latexkeys>::iterator it =
|
std::map<string, latexkeys>::iterator it = wordlist.find(str);
|
||||||
std::find_if(wordlist.begin(), wordlist.end(),
|
return (it != wordlist.end()) ? &(it->second) : 0;
|
||||||
lyx::compare_memfun(&latexkeys::Name, str));
|
|
||||||
return (it != wordlist.end()) ? &(*it) : 0;
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "math_defs.h"
|
#include "math_defs.h"
|
||||||
#include "symbol_def.h"
|
#include "symbol_def.h"
|
||||||
|
|
||||||
class MathArray;
|
|
||||||
class MathMatrixInset;
|
class MathMatrixInset;
|
||||||
class MathMacroTemplate;
|
class MathMacroTemplate;
|
||||||
class LyXLex;
|
class LyXLex;
|
||||||
@ -129,8 +128,6 @@ struct latexkeys {
|
|||||||
unsigned char latex_font_id;
|
unsigned char latex_font_id;
|
||||||
///
|
///
|
||||||
MathSymbolTypes type;
|
MathSymbolTypes type;
|
||||||
///
|
|
||||||
string const & Name() const { return name;}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user