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