[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Lost] [Patch] vterm Kontrolltasten angepasst
* vterm: Tastenkombinationen zum wechseln der Terminals auf Alt + Fn, scrollen
mit Shift + "Pfeil hoch" und "Pfeil runter" respektiv shift + "Page up"
und "Page Down"
Index: trunk/src/modules/include/kbd.h
===================================================================
--- trunk.orig/src/modules/include/kbd.h
+++ trunk/src/modules/include/kbd.h
@@ -65,7 +65,7 @@
#define KEYCODE_F4 62
#define KEYCODE_F5 63
#define KEYCODE_F6 64
-#define KEYCODE_F7 64
+#define KEYCODE_F7 65
#define KEYCODE_F8 66
#define KEYCODE_F9 67
#define KEYCODE_F10 68
@@ -77,6 +77,7 @@
#define KEYCODE_ARROW_LEFT 105
#define KEYCODE_ARROW_RIGHT 106
+#define KEYCODE_SCROLL_LOCK 70
#endif // ifndef _KBD_H_
Index: trunk/src/modules/vterm/input.c
===================================================================
--- trunk.orig/src/modules/vterm/input.c
+++ trunk/src/modules/vterm/input.c
@@ -112,11 +112,12 @@ static void rpc_kbd_callback(pid_t pid,
static void send_key_to_vterm(vterminal_t* vterm, uint8_t keycode,
bool down)
{
- static bool st_shift = FALSE;
- static bool st_control = FALSE;
- static bool st_alt = FALSE;
- static bool st_altgr = FALSE;
-
+ static struct modifiers modifiers = {
+ .shift = FALSE,
+ .control = FALSE,
+ .alt = FALSE,
+ .altgr = FALSE
+ };
keymap_entry_t* e;
wchar_t c = 0;
@@ -124,20 +125,20 @@ static void send_key_to_vterm(vterminal_
switch (keycode) {
case KEYCODE_SHIFT_LEFT:
case KEYCODE_SHIFT_RIGHT:
- st_shift = down;
+ modifiers.shift = down;
return;
case KEYCODE_CONTROL_LEFT:
case KEYCODE_CONTROL_RIGHT:
- st_control = down;
+ modifiers.control = down;
return;
case KEYCODE_ALT:
- st_alt = down;
+ modifiers.alt = down;
return;
case KEYCODE_ALTGR:
- st_altgr = down;
+ modifiers.altgr = down;
return;
}
@@ -146,6 +147,11 @@ static void send_key_to_vterm(vterminal_
return;
}
+ // Umschalten zwischen virtuellen Terminals (Alt + Fn), scrollen usw.
+ if (vterm_process_raw_input(keycode, &modifiers)) {
+ return;
+ }
+
// FIXME: Ist nur temporaer da, damit Pfeiltasten und andere Spezialtasten
// funktionieren wie bisher.
switch (keycode) {
@@ -164,11 +170,11 @@ static void send_key_to_vterm(vterminal_
// Zeichen auswaehlen
e = keymap_get(keycode);
// TODO: AltGr+Shift
- if (st_shift) {
+ if (modifiers.shift) {
c = e->shift;
- } else if (st_altgr) {
+ } else if (modifiers.altgr) {
c = e->altgr;
- } else if (st_control) {
+ } else if (modifiers.control) {
c = e->ctrl;
} else {
c = e->normal;
Index: trunk/src/modules/vterm/keymap.c
===================================================================
--- trunk.orig/src/modules/vterm/keymap.c
+++ trunk/src/modules/vterm/keymap.c
@@ -52,41 +52,41 @@ keymap_entry_t keymap[] = {
{ '^', 0, 0, 0 },
{ '\b', 0, 0, 0 },
{ '\t', 0, 0, 0 },
- { 'q', 'Q', 0, 0 },
- { 'w', 'W', 0, 0 },
- { 'e', 'E', 0, 0 },
- { 'r', 'R', 0, 0 },
- { 't', 'T', 0, 0 }, // 20
- { 'z', 'Z', 0, 0 },
- { 'u', 'U', 0, 0 },
- { 'i', 'I', 0, 0 },
- { 'o', 'O', 0, 0 },
- { 'p', 'P', 0, 0 },
+ { 'q', 'Q', 0, 17 },
+ { 'w', 'W', 0, 23 },
+ { 'e', 'E', 0, 5 },
+ { 'r', 'R', 0, 18 },
+ { 't', 'T', 0, 20 }, // 20
+ { 'z', 'Z', 0, 26 },
+ { 'u', 'U', 0, 21 },
+ { 'i', 'I', 0, 9 },
+ { 'o', 'O', 0, 15 },
+ { 'p', 'P', 0, 16 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ '\n', 0, 0, 0 },
{ 0, 0, 0, 0 },
- { 'a', 'A', 0, 0 }, // 30
- { 's', 'S', 0, 0 },
- { 'd', 'D', 0, 0 },
- { 'f', 'F', 0, 0 },
- { 'g', 'G', 0, 0 },
- { 'h', 'H', 0, 0 },
- { 'j', 'J', 0, 0 },
- { 'k', 'K', 0, 0 },
- { 'l', 'L', 0, 0 },
+ { 'a', 'A', 0, 1 }, // 30
+ { 's', 'S', 0, 19 },
+ { 'd', 'D', 0, 4 },
+ { 'f', 'F', 0, 6 },
+ { 'g', 'G', 0, 7 },
+ { 'h', 'H', 0, 8 },
+ { 'j', 'J', 0, 10 },
+ { 'k', 'K', 0, 11 },
+ { 'l', 'L', 0, 12 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, // 40
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
- { 'y', 'Y', 0, 0 },
- { 'x', 'X', 0, 0 },
- { 'c', 'C', 0, 0 },
- { 'v', 'V', 0, 0 },
- { 'b', 'B', 0, 0 },
- { 'n', 'N', 0, 0 },
- { 'm', 'M', 0, 0 }, // 50
+ { 'y', 'Y', 0, 25 },
+ { 'x', 'X', 0, 24 },
+ { 'c', 'C', 0, 3 },
+ { 'v', 'V', 0, 22 },
+ { 'b', 'B', 0, 2 },
+ { 'n', 'N', 0, 14 },
+ { 'm', 'M', 0, 13 }, // 50
{ ',', ';', 0, 0 },
{ '.', ':', 0, 0 },
{ '-', '_', 0, 0 },
Index: trunk/src/modules/vterm/term.c
===================================================================
--- trunk.orig/src/modules/vterm/term.c
+++ trunk/src/modules/vterm/term.c
@@ -39,6 +39,7 @@
#include "lostio.h"
#include <collections.h>
#include <syscall.h>
+#include <kbd.h>
// FIXME: Muesste der irgendwo deklariert sein?
char* strnstr(const char* s, const char* find, size_t slen);
@@ -59,8 +60,7 @@ void vterm_change(vterminal_t* vterm);
void init_vterminals(unsigned int count)
{
- char shortcuts[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '\'',
- '^'};
+ char shortcuts[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
// Liste fuer alle vterms erstellen
vterm_list = list_create();
@@ -159,73 +159,7 @@ static void input_buffer_append(vtermina
*/
static void input_process_char(vterminal_t* vterm, char c)
{
- static bool wait_command = FALSE;
-
- if (wait_command == TRUE) {
- wait_command = FALSE;
- switch (c) {
- // ESC wird momentan zum einleiten von Befehlen Benutzt
- case '\033':
- // Wenn schon einmal ESC gedrueckt wurde, wird ein ESC
- // weitergeleitet.
- input_buffer_append(vterm, c);
- break;
-
- // ESC + s => Scroll lock
- case 's':
- vterm->output.scroll_lock = !vterm->output.scroll_lock;
- break;
-
- // ESC + u => Scroll up
- case 'u':
- screen_scroll(&(vterm->output), -10);
- break;
-
- // ESC + d => Scroll down
- case 'd':
- screen_scroll(&(vterm->output), 10);
- break;
-
- // Alles andere => Terminalwechsel
- default: {
- vterminal_t* vterm_switch = NULL;
- int i = 0;
-
- // Passendes Terminal suchen
- while ((vterm_switch = list_get_element_at(vterm_list, i++))) {
- if (vterm_switch->shortcut == c) {
- break;
- }
- }
-
- // Wenn kein passendes Terminal gefunden werden konnte, wird
- // das Zeichen normal ausgegeben
- if (vterm_switch == NULL) {
- input_buffer_append(vterm, c);
- break;
- }
-
- // Ansonsten wird jetzt gewechselt
- vterm_change(vterm_switch);
- break;
- }
- }
- } else {
- switch (c) {
- // ESC wird momentan zum einleiten von Befehlen Benutzt
- case '\033':
- // Das naechste Zeichen wird zum identifizieren des neuen
- // Terminals benutzt.
- wait_command = TRUE;
-
- break;
-
- // Alles andere
- default:
- input_buffer_append(vterm, c);
- break;
- }
- }
+ input_buffer_append(vterm, c);
}
/**
@@ -244,3 +178,77 @@ void vterm_process_input(char* data, siz
}
}
+/**
+ * Zu einem virtuellen Terminal anhand seines Shortcuts
+ *
+ * @param shortcut Shortcut des Terminals
+ */
+void vterm_switch_to(char shortcut) {
+ vterminal_t* vterm_switch = NULL;
+ int i = 0;
+
+ // Passendes Terminal suchen
+ while ((vterm_switch = list_get_element_at(vterm_list, i++))) {
+ if (vterm_switch->shortcut == shortcut) {
+ break;
+ }
+ }
+
+ if (vterm_switch) {
+ vterm_change(vterm_switch);
+ }
+}
+
+/**
+ * Eingaben verarbeiten, falls sie eine der Kontroll-Tastenkombinationen
+ * beinhaltet.
+ *
+ * @param vterm Handle
+ * @param keycode Keycode
+ * @param modifiers Struktur mit Status der Modifier-Tasten
+ *
+ * @return TRUE wenn der Keycode benutzt wurde, sonst FALSE
+ */
+bool vterm_process_raw_input(uint8_t keycode, struct modifiers* modifiers)
+{
+ if (modifiers->shift) {
+ switch (keycode) {
+ case KEYCODE_PAGE_UP:
+ screen_scroll(&(current_vterm->output), -10);
+ return TRUE;
+
+ case KEYCODE_ARROW_UP:
+ screen_scroll(&(current_vterm->output), -1);
+ return TRUE;
+
+ case KEYCODE_PAGE_DOWN:
+ screen_scroll(&(current_vterm->output), 10);
+ return TRUE;
+
+ case KEYCODE_ARROW_DOWN:
+ screen_scroll(&(current_vterm->output), 1);
+ return TRUE;
+ }
+ } else if (modifiers->alt) {
+ switch (keycode) {
+ case KEYCODE_F1: vterm_switch_to(1); return TRUE;
+ case KEYCODE_F2: vterm_switch_to(2); return TRUE;
+ case KEYCODE_F3: vterm_switch_to(3); return TRUE;
+ case KEYCODE_F4: vterm_switch_to(4); return TRUE;
+ case KEYCODE_F5: vterm_switch_to(5); return TRUE;
+ case KEYCODE_F6: vterm_switch_to(6); return TRUE;
+ case KEYCODE_F7: vterm_switch_to(7); return TRUE;
+ case KEYCODE_F8: vterm_switch_to(8); return TRUE;
+ case KEYCODE_F9: vterm_switch_to(9); return TRUE;
+ case KEYCODE_F10: vterm_switch_to(10); return TRUE;
+ case KEYCODE_F11: vterm_switch_to(11); return TRUE;
+ case KEYCODE_F12: vterm_switch_to(12); return TRUE;
+ }
+ } else if (keycode == KEYCODE_SCROLL_LOCK) {
+ current_vterm->output.scroll_lock = !current_vterm->output.scroll_lock;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
Index: trunk/src/modules/vterm/vterm.h
===================================================================
--- trunk.orig/src/modules/vterm/vterm.h
+++ trunk/src/modules/vterm/vterm.h
@@ -165,6 +165,13 @@ typedef struct {
size_t utf8_buffer_offset;
} vterminal_t;
+/// Status der Modifiertasten
+struct modifiers {
+ bool shift;
+ bool control;
+ bool altgr;
+ bool alt;
+};
extern vterminal_t* current_vterm;
@@ -219,3 +226,6 @@ void vt100_process_output(vterminal_t* v
/// UTF8-String in Codepage437-String verwandeln
int utf8_to_cp437(vterminal_t* vterm, const char* str, size_t len, char* buf);
+/// Eigaben in der Verwaltung fuer die virtuellen Terminals verarbeiten
+bool vterm_process_raw_input(uint8_t keycode, struct modifiers* modifiers);
+