MCPcopy Create free account
hub / github.com/deskflow/deskflow / parseKey

Method parseKey

src/lib/deskflow/KeyMap.cpp:1108–1138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1106}
1107
1108bool KeyMap::parseKey(const std::string &x, KeyID &key)
1109{
1110 // initialize tables
1111 initKeyNameMaps();
1112
1113 // parse the key
1114 key = kKeyNone;
1115 if (s_nameToKeyMap->contains(x)) {
1116 key = s_nameToKeyMap->find(x)->second;
1117 }
1118 // XXX -- we're assuming ASCII encoding here
1119 else if (x.size() == 1) {
1120 if (!isgraph(x[0])) {
1121 // unknown key
1122 return false;
1123 }
1124 key = (KeyID)x[0];
1125 } else if (x.size() == 6 && x[0] == '\\' && x[1] == 'u') {
1126 // escaped unicode (\uXXXX where XXXX is a hex number)
1127 char *end;
1128 key = (KeyID)strtol(x.c_str() + 2, &end, 16);
1129 if (*end != '\0') {
1130 return false;
1131 }
1132 } else if (!x.empty()) {
1133 // unknown key
1134 return false;
1135 }
1136
1137 return true;
1138}
1139
1140bool KeyMap::parseModifiers(std::string &x, KeyModifierMask &mask)
1141{

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.80
containsMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected