]> git.lyx.org Git - lyx.git/blobdiff - src/chset.C
Added html export for LinuxDoc and DocBook. LinuxDoc import now available in file...
[lyx.git] / src / chset.C
index d83a7451162d079f40cebb0df99d1b734ca5daed..965616d811d33f0d71811f8902a461e6ca338e6d 100644 (file)
@@ -13,6 +13,8 @@ using std::ifstream;
 #include "support/LSubstring.h"
 #include "debug.h"
 
+using std::make_pair;
+
 bool CharacterSet::loadFile(string const & fname)
 {
        map_.clear();
@@ -23,11 +25,11 @@ bool CharacterSet::loadFile(string const & fname)
        
        // open definition file
        lyxerr[Debug::KBMAP]
-               << "Reading keymap file " << fname << ".cdef" << endl;
+               << "Reading character set file " << fname << ".cdef" << endl;
        string filename = LibFileSearch("kbd", fname.c_str(), "cdef");
        ifstream ifs(filename.c_str());
        if (!ifs) {
-               lyxerr << "Unable to open keymap file" << endl;
+               lyxerr << "Unable to open character set file" << endl;
                return true;            // no definition, use 7-bit ascii
        }
        name_ = fname;
@@ -35,6 +37,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 +59,20 @@ bool CharacterSet::loadFile(string const & fname)
 }
 
 
-bool CharacterSet::encodeString(string & str) const
+pair<bool, int> CharacterSet::encodeString(string & 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);
 }