summaryrefslogtreecommitdiff
path: root/src/keys.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-11-09 11:12:55 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-11-09 11:12:55 +0000
commit4b518ee6b97d0db39f5daf8a327f3515ce6e92a5 (patch)
treec49d384bddab1e41677b592ac415a46ec26ce147 /src/keys.cc
parenta7ed017ef384cce66f60b986282521a8380ea58f (diff)
Add support for function keys F1-F12
Diffstat (limited to 'src/keys.cc')
-rw-r--r--src/keys.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/keys.cc b/src/keys.cc
index 98909029..17789ccd 100644
--- a/src/keys.cc
+++ b/src/keys.cc
@@ -80,6 +80,29 @@ KeyList parse_keys(const String& str)
pos = end_pos;
continue;
}
+ if ((keyname[0] == 'f' or keyname[0] == 'F') and
+ keyname.length() <= 3)
+ {
+
+ int val = 0;
+ for (auto i = 1_byte; i < keyname.length(); ++i)
+ {
+ char c = keyname[i];
+ if (c >= '0' and c <= '9')
+ val = val*10 + c - '0';
+ else
+ {
+ val = -1;
+ break;
+ }
+ }
+ if (val >= 1 and val <= 12)
+ {
+ result.push_back(Key{ modifier, Key::F1 + (val - 1) });
+ pos = end_pos;
+ continue;
+ }
+ }
}
}
result.push_back({Key::Modifiers::None, Codepoint(str[pos])});
@@ -98,6 +121,11 @@ String key_to_str(Key key)
named = true;
res = it->first;
}
+ else if (key.key >= Key::F1 and key.key < Key::F12)
+ {
+ named = true;
+ res = "F" + to_string((int)(Codepoint)key.key - (int)(Codepoint)Key::F1 + 1);
+ }
else
res = codepoint_to_str(key.key);