terminal keycodes

This commit is contained in:
Vadim Lopatin 2016-06-06 12:02:18 +03:00
parent 312662f828
commit d54c0a7249
1 changed files with 48 additions and 22 deletions

View File

@ -449,7 +449,32 @@ class TerminalWidget : WidgetGroup, OnScrollHandler {
return true; return true;
} }
if (event.action == KeyAction.KeyDown) { if (event.action == KeyAction.KeyDown) {
dstring flsgsstr;
dstring flsgsstr2;
dstring flsgsstr3;
if ((event.flags & KeyFlag.MainFlags) == KeyFlag.Menu) {
flsgsstr = "1;1";
flsgsstr2 = ";1";
flsgsstr3 = "1";
}
if ((event.flags & KeyFlag.MainFlags) == KeyFlag.Shift) {
flsgsstr = "1;2";
flsgsstr2 = ";2";
flsgsstr3 = "2";
}
if ((event.flags & KeyFlag.MainFlags) == KeyFlag.Alt) {
flsgsstr = "1;3";
flsgsstr2 = ";3";
flsgsstr3 = "3";
}
if ((event.flags & KeyFlag.MainFlags) == KeyFlag.Control) {
flsgsstr = "1;5";
flsgsstr2 = ";5";
flsgsstr3 = ";5";
}
switch (event.keyCode) { switch (event.keyCode) {
case KeyCode.ESC:
return handleTextInput("\x1b");
case KeyCode.RETURN: case KeyCode.RETURN:
return handleTextInput("\n"); return handleTextInput("\n");
case KeyCode.TAB: case KeyCode.TAB:
@ -457,55 +482,56 @@ class TerminalWidget : WidgetGroup, OnScrollHandler {
case KeyCode.BACK: case KeyCode.BACK:
return handleTextInput("\t"); return handleTextInput("\t");
case KeyCode.F1: case KeyCode.F1:
return handleTextInput("\x1bOP"); return handleTextInput("\x1bO" ~ flsgsstr3 ~ "P");
case KeyCode.F2: case KeyCode.F2:
return handleTextInput("\x1bOQ"); return handleTextInput("\x1bO" ~ flsgsstr3 ~ "Q");
case KeyCode.F3: case KeyCode.F3:
return handleTextInput("\x1bOR"); return handleTextInput("\x1bO" ~ flsgsstr3 ~ "R");
case KeyCode.F4: case KeyCode.F4:
return handleTextInput("\x1bOS"); return handleTextInput("\x1bO" ~ flsgsstr3 ~ "S");
case KeyCode.F5: case KeyCode.F5:
return handleTextInput("\x1b[15~"); return handleTextInput("\x1b[15" ~ flsgsstr2 ~ "~");
case KeyCode.F6: case KeyCode.F6:
return handleTextInput("\x1b[17~"); return handleTextInput("\x1b[17" ~ flsgsstr2 ~ "~");
case KeyCode.F7: case KeyCode.F7:
return handleTextInput("\x1b[18~"); return handleTextInput("\x1b[18" ~ flsgsstr2 ~ "~");
case KeyCode.F8: case KeyCode.F8:
return handleTextInput("\x1b[19~"); return handleTextInput("\x1b[19" ~ flsgsstr2 ~ "~");
case KeyCode.F9: case KeyCode.F9:
return handleTextInput("\x1b[20~"); return handleTextInput("\x1b[20" ~ flsgsstr2 ~ "~");
case KeyCode.F10: case KeyCode.F10:
return handleTextInput("\x1b[21~"); return handleTextInput("\x1b[21" ~ flsgsstr2 ~ "~");
case KeyCode.F11: case KeyCode.F11:
return handleTextInput("\x1b[23~"); return handleTextInput("\x1b[23" ~ flsgsstr2 ~ "~");
case KeyCode.F12: case KeyCode.F12:
return handleTextInput("\x1b[24~"); return handleTextInput("\x1b[24" ~ flsgsstr2 ~ "~");
case KeyCode.LEFT: case KeyCode.LEFT:
return handleTextInput("\x1b[D"); return handleTextInput("\x1b[" ~ flagsstr ~ "D");
case KeyCode.RIGHT: case KeyCode.RIGHT:
return handleTextInput("\x1b[C"); return handleTextInput("\x1b[" ~ flagsstr ~ "C");
case KeyCode.UP: case KeyCode.UP:
return handleTextInput("\x1b[A"); return handleTextInput("\x1b[" ~ flagsstr ~ "A");
case KeyCode.DOWN: case KeyCode.DOWN:
return handleTextInput("\x1b[B"); return handleTextInput("\x1b[" ~ flagsstr ~ "B");
case KeyCode.INS: case KeyCode.INS:
return handleTextInput("\x1b[2~"); return handleTextInput("\x1b[2" ~ flsgsstr2 ~ "~");
case KeyCode.DEL: case KeyCode.DEL:
return handleTextInput("\x1b[3~"); return handleTextInput("\x1b[3" ~ flsgsstr2 ~ "~");
case KeyCode.HOME: case KeyCode.HOME:
return handleTextInput("\x1b[1~"); return handleTextInput("\x1b[" ~ flagsstr ~ "H");
case KeyCode.END: case KeyCode.END:
return handleTextInput("\x1b[4~"); return handleTextInput("\x1b[" ~ flagsstr ~ "F");
case KeyCode.PAGEUP: case KeyCode.PAGEUP:
return handleTextInput("\x1b[5~"); return handleTextInput("\x1b[5" ~ flsgsstr2 ~ "~");
case KeyCode.PAGEDOWN: case KeyCode.PAGEDOWN:
return handleTextInput("\x1b[6~"); return handleTextInput("\x1b[6" ~ flsgsstr2 ~ "~");
default: default:
break; break;
} }
} }
if (event.action == KeyAction.KeyUp) { if (event.action == KeyAction.KeyUp) {
switch (event.keyCode) { switch (event.keyCode) {
case KeyCode.ESC:
case KeyCode.RETURN: case KeyCode.RETURN:
case KeyCode.TAB: case KeyCode.TAB:
case KeyCode.BACK: case KeyCode.BACK: