]> git.lyx.org Git - lyx.git/blobdiff - src/Encoding.cpp
Allow using \binom without amsmath and add support for \brace and \brack
[lyx.git] / src / Encoding.cpp
index cacb31de4f33be56b80fed475bf416eb3639b2d7..3aa31d0099ab9a771afa860f54b42203706677cf 100644 (file)
@@ -261,7 +261,7 @@ const char * EncodingException::what() const throw()
 
 Encoding::Encoding(string const & n, string const & l, string const & i,
                   bool f, Encoding::Package p)
-       : Name_(n), LatexName_(l), iconvName_(i), fixedwidth_(f), package_(p)
+       : name_(n), latexName_(l), iconvName_(i), fixedwidth_(f), package_(p)
 {
        if (n == "ascii") {
                // ASCII can encode 128 code points and nothing else
@@ -323,7 +323,7 @@ void Encoding::init() const
 }
 
 
-docstring const Encoding::latexChar(char_type c) const
+docstring Encoding::latexChar(char_type c) const
 {
        // assure the used encoding is properly initialized
        init();
@@ -337,26 +337,25 @@ docstring const Encoding::latexChar(char_type c) const
        CharInfoMap::const_iterator const it = unicodesymbols.find(c);
        if (it == unicodesymbols.end())
                throw EncodingException(c);
-       else
-               return it->second.command;
+       return it->second.command;
 }
 
 
-set<char_type> Encoding::getSymbolsList() const
+vector<char_type> Encoding::symbolsList() const
 {
        // assure the used encoding is properly initialized
        init();
 
        // first all encodable characters
-       CharSet symbols = encodable_;
+       vector<char_type> symbols(encodable_.begin(), encodable_.end());
        // add those below start_encodable_
        for (char_type c = 0; c < start_encodable_; ++c)
-               symbols.insert(c);
+               symbols.push_back(c);
        // now the ones from the unicodesymbols file
        CharInfoMap::const_iterator const end = unicodesymbols.end();
        CharInfoMap::const_iterator it = unicodesymbols.begin();
        for (; it != end; ++it)
-               symbols.insert(it->first);
+               symbols.push_back(it->first);
        return symbols;
 }
 
@@ -373,7 +372,7 @@ void Encodings::validate(char_type c, LaTeXFeatures & features)
 }
 
 
-bool Encodings::isComposeChar_hebrew(char_type c)
+bool Encodings::isHebrewComposeChar(char_type c)
 {
        return c <= 0x05c2 && c >= 0x05b0 && c != 0x05be && c != 0x05c0;
 }
@@ -383,7 +382,7 @@ bool Encodings::isComposeChar_hebrew(char_type c)
 // they are hamza, alef_madda, alef_hamza, waw_hamza, alef_hamza_under,
 // alef, tah_marbota, dal, thal, rah, zai, wow, alef_maksoura
 
-bool Encodings::is_arabic_special(char_type c)
+bool Encodings::isArabicSpecialChar(char_type c)
 {
        return (c >= 0x0621 && c <= 0x0625) || (c >= 0x0630 && c <= 0x0632)
                || c == 0x0627 || c == 0x0629 || c == 0x062f || c == 0x0648
@@ -391,26 +390,22 @@ bool Encodings::is_arabic_special(char_type c)
 }
 
 
-bool Encodings::isComposeChar_arabic(char_type c)
+bool Encodings::isArabicComposeChar(char_type c)
 {
        return c >= 0x064b && c <= 0x0652;
 }
 
 
-bool Encodings::is_arabic(char_type c)
+bool Encodings::isArabicChar(char_type c)
 {
        return c >= arabic_start && c <= arabic_end
                && arabic_table[c-arabic_start][0];
 }
 
 
-char_type Encodings::transformChar(char_type c,
-                                     Encodings::Letter_Form form)
+char_type Encodings::transformChar(char_type c, Encodings::LetterForm form)
 {
-       if (!is_arabic(c))
-               return c;
-
-       return arabic_table[c-arabic_start][form];
+       return isArabicChar(c) ? arabic_table[c-arabic_start][form] : c;
 }
 
 
@@ -441,14 +436,14 @@ bool Encodings::isKnownScriptChar(char_type const c, string & preamble)
 }
 
 
-Encoding const * Encodings::getFromLyXName(string const & name) const
+Encoding const * Encodings::fromLyXName(string const & name) const
 {
        EncodingList::const_iterator const it = encodinglist.find(name);
        return it != encodinglist.end() ? &it->second : 0;
 }
 
 
-Encoding const * Encodings::getFromLaTeXName(string const & name) const
+Encoding const * Encodings::fromLaTeXName(string const & name) const
 {
        // We don't use find_if because it makes copies of the pairs in
        // the map.
@@ -557,11 +552,10 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
                                fixedwidth = true;
                        else if (width == "variable")
                                fixedwidth = false;
-                       else {
+                       else
                                lex.printError("Encodings::read: "
                                               "Unknown width: `$$Token'");
-                        }
-                        
+
                        lex.next();
                        string const p = lex.getString();
                        Encoding::Package package = Encoding::none;
@@ -571,15 +565,14 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
                                package = Encoding::inputenc;
                        else if (p == "CJK")
                                package = Encoding::CJK;
-                       else {
+                       else
                                lex.printError("Encodings::read: "
                                               "Unknown package: `$$Token'");
-                        }
-                        
+
                        LYXERR(Debug::INFO, "Reading encoding " << name);
                        encodinglist[name] = Encoding(name, latexname,
-                                                     iconvname, fixedwidth,
-                                                     package);
+                               iconvname, fixedwidth, package);
+
                        if (lex.lex() != et_end)
                                lex.printError("Encodings::read: "
                                               "missing end");