10 #include "support/filetools.h"
11 #include "support/LRegex.h"
12 #include "support/LSubstring.h"
15 bool CharacterSet::loadFile(string const & fname)
20 if (fname.empty() || fname == "ascii")
21 return true; // ascii 7-bit
23 // open definition file
25 << "Reading keymap file " << fname << ".cdef" << endl;
26 string filename = LibFileSearch("kbd", fname.c_str(), "cdef");
27 ifstream ifs(filename.c_str());
29 lyxerr << "Unable to open keymap file" << endl;
30 return true; // no definition, use 7-bit ascii
37 LRegex reg("^([12][0-9][0-9])[ \t]+\"([^ ]+)\".*");
38 while(getline(ifs, line)) {
39 if (reg.exact_match(line)) {
40 LRegex::SubMatches const & sub = reg.exec(line);
41 n = atoi(line.substr(sub[1].first,
42 sub[1].second).c_str());
43 str = LSubstring(line, sub[2].first, sub[2].second);
44 if (lyxerr.debugging(Debug::KBMAP))
45 lyxerr << "Chardef: " << n
46 << " to [" << str << "]" << endl;
50 lyxerr[Debug::KBMAP] << "End of parsing of .cdef file." << endl;
55 bool CharacterSet::encodeString(string & str) const
57 Cdef::const_iterator cit = map_.find(str);
58 if (cit != map_.end()) return true;
63 string const & CharacterSet::getName() const