]> git.lyx.org Git - lyx.git/blobdiff - src/Encoding.cpp
make frontend::Application a bit slimmer
[lyx.git] / src / Encoding.cpp
index ae03c09b4869006f41363bf09f4bdca4e2112c66..6a610c1998465ce815024b450cc5fe43319eaef8 100644 (file)
@@ -23,6 +23,8 @@
 #include "support/lstrings.h"
 #include "support/unicode.h"
 
+#include <boost/cstdint.hpp>
+
 #include <sstream>
 
 #ifndef CXX_GLOBAL_CSTD
@@ -401,6 +403,25 @@ bool Encodings::isCombiningChar(char_type c)
 }
 
 
+bool Encodings::isKnownScriptChar(char_type const c, string & preamble)
+{
+       CharInfoMap::const_iterator const it = unicodesymbols.find(c);
+
+       if (it == unicodesymbols.end())
+               return false;
+
+       if (it->second.preamble != "textgreek" &&
+           it->second.preamble != "textcyr")
+               return false;
+
+       if (preamble.empty()) {
+               preamble = it->second.preamble;
+               return true;
+       }
+       return it->second.preamble == preamble;
+}
+
+
 Encoding const * Encodings::getFromLyXName(string const & name) const
 {
        EncodingList::const_iterator it = encodinglist.find(name);
@@ -485,11 +506,9 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
                if (!info.preamble.empty())
                        info.feature = info.preamble[0] != '\\';
 
-               LYXERR(Debug::INFO)
-                       << "Read unicode symbol " << symbol << " '"
+               LYXERR(Debug::INFO, "Read unicode symbol " << symbol << " '"
                        << to_utf8(info.command) << "' '" << info.preamble
-                       << "' " << info.combining << ' ' << info.feature
-                       << endl;
+                       << "' " << info.combining << ' ' << info.feature);
                unicodesymbols[symbol] = info;
        }
 
@@ -519,20 +538,19 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
                        string const iconvname = lex.getString();
                        lex.next();
                        string const width = lex.getString();
-                       bool fixedwidth;;
+                       bool fixedwidth = false;
                        if (width == "fixed")
                                fixedwidth = true;
                        else if (width == "variable")
                                fixedwidth = false;
                        else {
-                                fixedwidth = false;
                                lex.printError("Encodings::read: "
                                               "Unknown width: `$$Token'");
                         }
                         
                        lex.next();
                        string const p = lex.getString();
-                       Encoding::Package package;
+                       Encoding::Package package = Encoding::none;
                        if (p == "none")
                                 package = Encoding::none;
                        else if (p == "inputenc")
@@ -540,12 +558,11 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
                        else if (p == "CJK")
                                package = Encoding::CJK;
                        else {
-                                package = Encoding::none;
                                lex.printError("Encodings::read: "
                                               "Unknown package: `$$Token'");
                         }
                         
-                       LYXERR(Debug::INFO) << "Reading encoding " << name << endl;
+                       LYXERR(Debug::INFO, "Reading encoding " << name);
                        encodinglist[name] = Encoding(name, latexname,
                                                      iconvname, fixedwidth,
                                                      package);