]> git.lyx.org Git - features.git/commitdiff
remove hard-wired association LaTeX macro <-> mathed inset
authorAndré Pönitz <poenitz@gmx.net>
Thu, 11 Jul 2002 09:34:58 +0000 (09:34 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 11 Jul 2002 09:34:58 +0000 (09:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4599 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_amsarrayinset.h
src/mathed/math_factory.C
src/mathed/math_hullinset.C
src/mathed/math_mathmlstream.C
src/mathed/math_mathmlstream.h
src/mathed/math_parser.C
src/mathed/math_support.C
src/mathed/math_support.h

index 4c45fe2d49967290437db9266bde463274cae08e..55900da11b242488783899074966e63a4029dd94 100644 (file)
@@ -8,6 +8,10 @@
 #pragma interface
 #endif
 
+//
+// used for [pbvV]matrix, psmatrix etc
+//
+
 
 class MathAMSArrayInset : public MathGridInset {
 public:
index 6fa68eaf20600f37f899d7c2d198dc0f36cbc097..24921d8df89e5b70cca3d617312421abee2ffff9 100644 (file)
@@ -53,112 +53,6 @@ typedef std::map<string, latexkeys> WordList;
 WordList theWordList;
 
 
-struct key_type {
-       ///
-       string name;
-       ///
-       string inset;
-       ///
-       string extra;
-};
-
-
-key_type wordlist_array[] =
-{
-       {"!",  "space", ""},
-       {",",  "space", ""},
-       {":",  "space", ""},
-       {";",  "space", ""},
-       {"Vmatrix",  "matrix", ""},
-       {"acute",  "decoration", ""},
-       {"bar",  "decoration", ""},
-       {"begin",  "begin", ""},
-       {"bf",  "oldfont", ""},
-       {"bmatrix",  "matrix", ""},
-       {"acute",  "decoration", ""},
-       {"breve",  "decoration", ""},
-       {"cal",  "oldfont", ""},
-       {"cdots",  "dots", ""},
-       {"check",  "decoration", ""},
-       {"ddot",  "decoration", ""},
-       {"dddot",  "decoration", ""},
-       {"ddots",  "dots", ""},
-       {"displaystyle",  "style", ""},
-       {"dot",  "decoration", ""},
-       {"dotsb",  "dots", ""},
-       {"dotsc",  "dots", ""},
-       {"dotsi",  "dots", ""},
-       {"dotsm",  "dots", ""},
-       {"dotso",  "dots", ""},
-       {"end",  "end", ""},
-       {"fbox",  "fbox", ""},
-       {"frak",  "font", ""},
-       {"grave",  "decoration", ""},
-       {"hat",  "decoration", ""},
-       {"it",  "oldfont", ""},
-       {"label",  "label", ""},
-       {"ldots",  "dots", ""},
-       {"left",  "left", ""},
-       {"lyxnegspace",  "space", ""},
-       {"lyxposspace",  "space", ""},
-       {"mathbb",  "font", ""},
-       {"mathbf",  "font", ""},
-       {"mathcal",  "font", ""},
-       {"mathfrak",  "font", ""},
-       {"mathit",  "font", ""},
-       {"mathnormal",  "font", ""},
-       {"mathring",  "decoration", ""},
-       {"mathrm",  "font", ""},
-       {"mathsf",  "font", ""},
-       {"mathtt",  "font", ""},
-       {"matrix",  "matrix", ""},
-       {"mbox",  "mbox", ""},
-       {"newcommand",  "newcommand", ""},
-       {"overbrace",  "decoration", ""},
-       {"overleftarrow",  "decoration", ""},
-       {"overline",  "decoration", ""},
-       {"overrightarrow",  "decoration", ""},
-       {"overleftrightarrow", "decoration", ""},
-       {"pageref",  "ref", ""},
-       {"parbox",  "parbox", ""},
-       {"pmatrix",  "matrix", ""},
-       {"prettyref",  "ref", ""},
-       {"protect",  "protect", ""},
-       {"qquad",  "space", ""},
-       {"quad",  "space", ""},
-       {"ref",  "ref", ""},
-       {"right",  "right", ""},
-       {"rm",  "oldfont", ""},
-       {"scriptscriptstyle",  "style", ""},
-       {"scriptstyle",  "style", ""},
-       {"text",    "font", "mathtext"},
-       {"textbf",  "font", "mathtext"},
-       {"textipa", "font", "mathtext"},
-       {"textit",  "font", "mathtext"},
-       {"textmd",  "font", "mathtext"},
-       {"textrm",  "font", "mathtext"},
-       {"textsl",  "font", "mathtext"},
-       {"textup",  "font", "mathtext"},
-       {"textstyle",  "style", ""},
-       {"tilde",  "decoration", ""},
-       {"tt",  "oldfont", ""},
-       {"underbar",  "decoration", ""},
-       {"underbrace",  "decoration", ""},
-       {"underleftarrow", "decoration", ""},
-       {"underline",  "decoration", ""},
-       {"underrightarrow", "decoration", ""},
-       {"underleftrightarrow", "decoration", ""},
-       {"underset",  "underset", ""},
-       {"vdots",  "dots", ""},
-       {"vec",  "decoration", ""},
-       {"vmatrix",  "matrix", ""},
-       {"vpageref",  "ref", ""},
-       {"vref",  "ref", ""},
-       {"widehat",  "decoration", ""},
-       {"widetilde",  "decoration", ""}
-};
-
-
 bool math_font_available(string & name)
 {
        LyXFont f;
@@ -179,9 +73,15 @@ bool math_font_available(string & name)
 }
 
 
-void readSymbols(string const & filename)
+void initSymbols()
 {
+       string const filename = LibFileSearch(string(), "symbols");
        lyxerr[Debug::MATHED] << "read symbols from " << filename << "\n";
+       if (filename.empty()) {
+               lyxerr << "Could not find symbols file\n";
+               return;
+       }
+
        std::ifstream fs(filename.c_str());
        while (fs) {
                int charid     = 0;
@@ -189,40 +89,51 @@ void readSymbols(string const & filename)
                latexkeys tmp;
                string line;
                getline(fs, line);
+               if (line.size() > 1 && line[0] == '#')
+                       continue;
                istringstream is(line);
-               is      >> tmp.name
-                               >> tmp.inset
-                               >> charid
-                               >> fallbackid
-                               >> tmp.extra
-                               >> tmp.xmlname;
-               if (!is)
+               is >> tmp.name >> tmp.inset;
+               if (isFontName(tmp.inset)) 
+                       is >> charid >> fallbackid >> tmp.extra >> tmp.xmlname;
+               else
+                       is >> tmp.extra;
+               if (!is) {
+                       lyxerr[Debug::MATHED] << "skipping line '" << line << "'\n";
+                       lyxerr[Debug::MATHED]
+                               << tmp.name << ' ' << tmp.inset << ' ' << tmp.extra << "\n";
                        continue;
+               }
 
-               // tmp.inset _is_ the fontname here.
-               // create fallbacks if necessary
-               if (tmp.extra == "func" || tmp.extra == "funclim" || tmp.extra=="special") {
-                       lyxerr[Debug::MATHED] << "symbol abuse for " << tmp.name << "\n";
-                       tmp.draw = tmp.name;
-               } else if (math_font_available(tmp.inset)) {
-                       lyxerr[Debug::MATHED] << "symbol available for " << tmp.name << "\n";
-                       tmp.draw += char(charid);
-               } else if (fallbackid) {
-                       if (tmp.inset == "cmex")
-                               tmp.inset  = "lyxsymbol";
-                       else
-                               tmp.inset  = "lyxboldsymbol";
-                       lyxerr[Debug::MATHED] << "symbol fallback for " << tmp.name << "\n";
-                       tmp.draw += char(fallbackid); 
+               if (isFontName(tmp.inset)) {
+                       // tmp.inset _is_ the fontname here.
+                       // create fallbacks if necessary
+                       if (tmp.extra=="func" || tmp.extra=="funclim" || tmp.extra=="special") {
+                               lyxerr[Debug::MATHED] << "symbol abuse for " << tmp.name << "\n";
+                               tmp.draw = tmp.name;
+                       } else if (math_font_available(tmp.inset)) {
+                               lyxerr[Debug::MATHED] << "symbol available for " << tmp.name << "\n";
+                               tmp.draw += char(charid);
+                       } else if (fallbackid) {
+                               if (tmp.inset == "cmex")
+                                       tmp.inset  = "lyxsymbol";
+                               else
+                                       tmp.inset  = "lyxboldsymbol";
+                               lyxerr[Debug::MATHED] << "symbol fallback for " << tmp.name << "\n";
+                               tmp.draw += char(fallbackid); 
+                       } else {
+                               lyxerr[Debug::MATHED] << "faking " << tmp.name << "\n";
+                               tmp.draw = tmp.name;
+                               tmp.inset = "lyxtex";
+                       }
                } else {
-                       lyxerr[Debug::MATHED] << "faking " << tmp.name << "\n";
-                       tmp.draw = tmp.name;
-                       tmp.inset = "lyxtex";
+                       // it's a proper inset
+                       lyxerr[Debug::MATHED] << "inset " << tmp.inset << " used for "
+                               << tmp.name << "\n";
                }
 
                if (theWordList.find(tmp.name) != theWordList.end())
                        lyxerr[Debug::MATHED] << "readSymbols: inset " << tmp.name
-                              << " already exists.\n";
+                               << " already exists.\n";
                else
                        theWordList[tmp.name] = tmp;
                lyxerr[Debug::MATHED] << "read symbol '" << tmp.name
@@ -234,26 +145,6 @@ void readSymbols(string const & filename)
 }
 
 
-void initSymbols()
-{
-       unsigned const n = sizeof(wordlist_array) / sizeof(wordlist_array[0]);
-       for (key_type * p = wordlist_array; p != wordlist_array + n; ++p) {
-               latexkeys tmp;
-               tmp.name  = p->name;
-               tmp.inset = p->inset;
-               tmp.draw  = p->name;
-               theWordList[p->name] = tmp;
-       }
-
-       lyxerr[Debug::MATHED] << "reading symbols file\n";
-       string const file = LibFileSearch(string(), "symbols");
-       if (file.empty())
-               lyxerr << "Could not find symbols file\n";
-       else
-               readSymbols(file);
-}
-
-
 } // namespace anon
 
 
index 739a945f5c636ecc5c74684a8398f6c330e50ad0..11833f0ed6fd55ab2f757fcdc896babdad1df373 100644 (file)
@@ -259,6 +259,7 @@ string MathHullInset::label(row_type row) const
 
 void MathHullInset::label(row_type row, string const & label)
 {
+       lyxerr << "setting label '" << label << "' for row " << row << endl;
        label_[row] = label;
 }
 
index 7d5f9a9e3ac13e1c56c5d533ead9ece3d6c52c5c..42ab2c1125e796f77534a95bcf95134645c1fa9e 100644 (file)
@@ -233,6 +233,13 @@ NormalStream & operator<<(NormalStream & ns, char c)
 }
 
 
+NormalStream & operator<<(NormalStream & ns, int i)
+{
+       ns.os() << i;
+       return ns;
+}
+
+
 
 //////////////////////////////////////////////////////////////////////
 
index 715e08c88f4690fd298098ef736361fb3911c25a..6425e27d3bb8ec8ff6e99f2ec92caa19c81e3541 100644 (file)
@@ -93,6 +93,8 @@ NormalStream & operator<<(NormalStream &, MathArray const &);
 NormalStream & operator<<(NormalStream &, char const *);
 ///
 NormalStream & operator<<(NormalStream &, char);
+///
+NormalStream & operator<<(NormalStream &, int);
 
 
 
index 0b93d3e99eb8b1a7ebee1df1d0b5df66273c4591..e4cf20698eb95ac83f7c6516a658cbc176b03440 100644 (file)
@@ -249,8 +249,6 @@ private:
        void error(string const & msg);
        /// dump contents to screen
        void dump() const;
-
-private:
        ///
        void tokenize(istream & is);
        ///
@@ -656,7 +654,7 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags,
 
                if (flags & FLAG_OPTION) {
                        if (t.cat() == catOther && t.character() == '[') {
-                               // skip the bracket and collect everything to the clsing bracket
+                               // skip the bracket and collect everything to the closing bracket
                                flags |= FLAG_BRACK_LAST;
                                continue;
                        }
index a02fa2ccfdcfb1d4f0f46c9a2750093fe9729b0a..b67f6bf45f4a49a18793e8e2e5bf4d5665f3a14c 100644 (file)
@@ -589,21 +589,34 @@ fontinfo fontinfos[] = {
 };
 
 
-fontinfo * searchFont(string const & name)
+fontinfo * lookupFont(string const & name)
 {
-       int const n = sizeof(fontinfos) / sizeof(fontinfo);
        //lyxerr << "searching font '" << name << "'\n"; 
+       int const n = sizeof(fontinfos) / sizeof(fontinfo);
        for (int i = 0; i < n; ++i)
                if (fontinfos[i].cmd_ == name) {
                        //lyxerr << "found '" << i << "'\n"; 
                        return fontinfos + i;
                }
+       return 0;
+}
+
+
+fontinfo * searchFont(string const & name)
+{
+       fontinfo * f = lookupFont(name);
+       return f ? f : fontinfos;
        // this should be mathnormal
-       return fontinfos;
        //return searchFont("mathnormal");
 }
 
 
+bool isFontName(string const & name)
+{
+       return lookupFont(name);
+}
+
+
 LyXFont getFont(string const & name)
 {
        LyXFont font;
index 2cd35476cfb6716ebf119b5ca0c2ae9d82dc2303..5092aa48c225463cadcb0f41e11e694b7fb64a76 100644 (file)
@@ -41,5 +41,6 @@ void math_font_max_dim(LyXFont const &, int & asc, int & desc);
 
 void augmentFont(LyXFont & f, string const & cmd);
 
+bool isFontName(string const & name);
 
 #endif