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

Method formatKey

src/lib/deskflow/KeyMap.cpp:1078–1106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1076}
1077
1078std::string KeyMap::formatKey(KeyID key, KeyModifierMask mask)
1079{
1080 // initialize tables
1081 initKeyNameMaps();
1082
1083 std::string x;
1084 for (int32_t i = 0; i < kKeyModifierNumBits; ++i) {
1085 KeyModifierMask mod = (1u << i);
1086 if ((mask & mod) != 0 && s_modifierToNameMap->contains(mod)) {
1087 x += s_modifierToNameMap->find(mod)->second;
1088 x += "+";
1089 }
1090 }
1091 if (key != kKeyNone) {
1092 if (s_keyToNameMap->contains(key)) {
1093 x += s_keyToNameMap->find(key)->second;
1094 }
1095 // XXX -- we're assuming ASCII here
1096 else if (key >= 33 && key < 127) {
1097 x += (char)key;
1098 } else {
1099 x += deskflow::string::sprintf("\\u%04x", key);
1100 }
1101 } else if (!x.empty()) {
1102 // remove trailing '+'
1103 x.erase(x.size() - 1);
1104 }
1105 return x;
1106}
1107
1108bool KeyMap::parseKey(const std::string &x, KeyID &key)
1109{

Callers

nothing calls this directly

Calls 6

sprintfFunction · 0.85
sizeMethod · 0.80
containsMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected