diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-11-09 11:12:55 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-11-09 11:12:55 +0000 |
| commit | 4b518ee6b97d0db39f5daf8a327f3515ce6e92a5 (patch) | |
| tree | c49d384bddab1e41677b592ac415a46ec26ce147 /src/keys.cc | |
| parent | a7ed017ef384cce66f60b986282521a8380ea58f (diff) | |
Add support for function keys F1-F12
Diffstat (limited to 'src/keys.cc')
| -rw-r--r-- | src/keys.cc | 28 |
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); |
