]> git.lyx.org Git - lyx.git/blobdiff - src/chset.C
small changes to ButtonController usage
[lyx.git] / src / chset.C
index 60c935e41fc4b39ea1d431338f78299369ed1198..cf3a3b1c4434174569c263b7e1f941039201a100 100644 (file)
@@ -5,7 +5,6 @@
 #endif
 
 #include <fstream>
-using std::ifstream;
 
 #include "chset.h"
 #include "support/filetools.h"
@@ -13,10 +12,16 @@ using std::ifstream;
 #include "support/LSubstring.h"
 #include "debug.h"
 
+using std::ifstream;
+using std::getline;
+using std::pair;
+using std::make_pair;
+using std::endl;
+
 bool CharacterSet::loadFile(string const & fname)
 {
        map_.clear();
-       name_.clear();
+       name_.erase();
        
        if (fname.empty() || fname == "ascii") 
                return true;    // ascii 7-bit
@@ -35,6 +40,10 @@ bool CharacterSet::loadFile(string const & fname)
        string str;
        int n;
        string line;
+       // Ok, I'll be the first to admit that this is probably not
+       // the fastest way to parse the cdef files, but I though it
+       // was a bit neat. Anyway it is wrong to use the lyxlex parse
+       // without the use of a keyword table.     
        LRegex reg("^([12][0-9][0-9])[ \t]+\"([^ ]+)\".*");
        while(getline(ifs, line)) {
                if (reg.exact_match(line)) {
@@ -53,11 +62,20 @@ bool CharacterSet::loadFile(string const & fname)
 }
 
 
-bool CharacterSet::encodeString(string & str) const
+pair<bool, int> CharacterSet::encodeString(string const & str) const
 {
+       lyxerr[Debug::KBMAP] << "Checking if we know [" << str << "]" << endl;
+       bool ret = false;
+       int val = 0;
        Cdef::const_iterator cit = map_.find(str);
-       if (cit != map_.end()) return true;
-       return false;
+       if (cit != map_.end()) {
+               ret =  true;
+               val = (*cit).second;
+       }
+       lyxerr[Debug::KBMAP] << "   "
+                            << (ret ? "yes we" : "no we don't")
+                            <<  " know [" << str << "]" << endl;
+       return make_pair(ret, val);
 }