Revision 907cb5d765157ac901255f8d5d413f5721014464

sadrul at pidgin.im sadrul at pidgin.im
Thu Mar 8 20:29:14 EST 2007


o   -----------------------------------------------------------------
|   Revision: 907cb5d765157ac901255f8d5d413f5721014464
|   Ancestor: 505bfd90eccc1a91b5578ff0dee7f540b51a128e
|   Author: sadrul at pidgin.im
|   Date: 2007-03-09T01:44:18
|   Branch: im.pidgin.pidgin
|   
|   Modified files:
|           console/libgnt/gntkeys.c console/libgnt/gntmain.c
|   
|   ChangeLog: 
|   
|   Do some funky stuff with the escape key.
|   
|   ============================================================
|   --- console/libgnt/gntkeys.c	20c6aff3696da93e30bf21d300eece61728d4095
|   +++ console/libgnt/gntkeys.c	873063136d49f87602326492a9b5f9281b23c5b1
|   @@ -34,7 +34,7 @@ void gnt_keys_refine(char *text)
|    
|    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 ||
|   ============================================================
|   --- console/libgnt/gntmain.c	bf8d185025d3c9de518c82ad3b15250b8969292d
|   +++ console/libgnt/gntmain.c	04fd84cde349738be547682f08b1afe625df2eed
|   @@ -51,6 +51,20 @@ static GntClipboard *clipboard;
|    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, GIOConditi
|    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 @@ io_invoke(GIOChannel *source, GIOConditi
|    		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 @@ setup_io()
|    {
|    	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);

To get the patch for this revision, please do this:
mtn log --last 1 --diffs --from 907cb5d765157ac901255f8d5d413f5721014464


More information about the Commits mailing list