Mercurial > pidgin
changeset 15780:567097a973c6
Do some funky stuff with the escape key.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 09 Mar 2007 01:44:18 +0000 |
parents | c9f0d675196a |
children | 8afc77eb6c1f |
files | console/libgnt/gntkeys.c console/libgnt/gntmain.c |
diffstat | 2 files changed, 35 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/console/libgnt/gntkeys.c Wed Mar 07 15:38:44 2007 +0000 +++ b/console/libgnt/gntkeys.c Fri Mar 09 01:44:18 2007 +0000 @@ -34,7 +34,7 @@ void gnt_keys_refine(char *text) { - if (*text == 27 && *(text + 1) == '[' && *(text + 3) == '\0' && + if (*text == 27 && *(text + 1) == '[' && (*(text + 2) >= 'A' && *(text + 2) <= 'D')) { /* Apparently this is necessary for urxvt and screen and xterm */ if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0 ||
--- a/console/libgnt/gntmain.c Wed Mar 07 15:38:44 2007 +0000 +++ b/console/libgnt/gntmain.c Fri Mar 09 01:44:18 2007 +0000 @@ -51,6 +51,20 @@ GntWM *wm; static GntClipboard *clipboard; +#define HOLDING_ESCAPE (escape_stuff.timer != 0) + +static struct { + int timer; +} escape_stuff; + +static gboolean +escape_timeout(gpointer data) +{ + gnt_wm_process_input(wm, "\033"); + escape_stuff.timer = 0; + return FALSE; +} + /** * Mouse support: * - bring a window on top if you click on its taskbar @@ -180,7 +194,7 @@ io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) { char keys[256]; - int rd = read(STDIN_FILENO, keys, sizeof(keys) - 1); + int rd = read(STDIN_FILENO, keys + HOLDING_ESCAPE, sizeof(keys) - 1 - HOLDING_ESCAPE); char *k; if (rd < 0) { @@ -197,16 +211,31 @@ raise(SIGABRT); } + rd += HOLDING_ESCAPE; keys[rd] = 0; - gnt_keys_refine(keys); - if (mouse_enabled && detect_mouse_action(keys)) return TRUE; + if (HOLDING_ESCAPE) + keys[0] = '\033'; k = keys; while (rd) { char back; - int p = MAX(1, gnt_keys_find_combination(k)); + int p; + + if (k[0] == '\033' && rd == 1) { + if (escape_stuff.timer) { + gnt_wm_process_input(wm, "\033\033"); + g_source_remove(escape_stuff.timer); + escape_stuff.timer = 0; + break; + } + escape_stuff.timer = g_timeout_add(250, escape_timeout, NULL); + break; + } + + gnt_keys_refine(k); + p = MAX(1, gnt_keys_find_combination(k)); back = k[p]; k[p] = '\0'; gnt_wm_process_input(wm, k); /* XXX: */ @@ -223,6 +252,7 @@ { int result; channel = g_io_channel_unix_new(STDIN_FILENO); + g_io_channel_set_close_on_unref(channel, TRUE); #if 0 g_io_channel_set_encoding(channel, NULL, NULL);