core: improve mouse support: process utf-8 codes, add option weechat.look.mouse_timer_delay, remove key meta2-M, fix problem with iso chars when grabbing mouse codes
This commit is contained in:
parent
17037e32d8
commit
51ef22c284
@ -1,15 +1,15 @@
|
||||
WeeChat ChangeLog
|
||||
=================
|
||||
Sébastien Helleu <flashcode@flashtux.org>
|
||||
v0.3.6-dev, 2011-07-27
|
||||
v0.3.6-dev, 2011-07-28
|
||||
|
||||
|
||||
Version 0.3.6 (under dev!)
|
||||
--------------------------
|
||||
|
||||
* core: allow buffer name in /buffer close
|
||||
* core: add support of mouse: new command /mouse, new option weechat.look.mouse
|
||||
and new key context "mouse" (task #5435)
|
||||
* core: add support of mouse: new command /mouse, new key context "mouse",
|
||||
new options weechat.look.mouse and weechat.look.mouse_timer_delay (task #5435)
|
||||
* core: add command /cursor (free movement of cursor on screen), with key
|
||||
context "search"
|
||||
* core: automatic scroll direction in /bar scroll (x/y is now optional)
|
||||
|
@ -478,6 +478,11 @@
|
||||
** Typ: boolesch
|
||||
** Werte: on, off (Standardwert: `off`)
|
||||
|
||||
* *weechat.look.mouse_timer_delay*
|
||||
** Beschreibung: `delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay before processing event`
|
||||
** Typ: integer
|
||||
** Werte: 1 .. 10000 (Standardwert: `100`)
|
||||
|
||||
* *weechat.look.nickmode*
|
||||
** Beschreibung: `Nickmode ((half)op/voice [@%+]) vor dem Nicknamen anzeigen`
|
||||
** Typ: boolesch
|
||||
|
@ -478,6 +478,11 @@
|
||||
** type: boolean
|
||||
** values: on, off (default value: `off`)
|
||||
|
||||
* *weechat.look.mouse_timer_delay*
|
||||
** description: `delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay before processing event`
|
||||
** type: integer
|
||||
** values: 1 .. 10000 (default value: `100`)
|
||||
|
||||
* *weechat.look.nickmode*
|
||||
** description: `display nick mode ((half)op/voice) before each nick`
|
||||
** type: boolean
|
||||
|
@ -478,6 +478,11 @@
|
||||
** type: booléen
|
||||
** valeurs: on, off (valeur par défaut: `off`)
|
||||
|
||||
* *weechat.look.mouse_timer_delay*
|
||||
** description: `délai (en millisecondes) pour capturer un évènement de la souris: WeeChat attendra ce délai avant de traiter l'évènement`
|
||||
** type: entier
|
||||
** valeurs: 1 .. 10000 (valeur par défaut: `100`)
|
||||
|
||||
* *weechat.look.nickmode*
|
||||
** description: `afficher le mode du pseudo ((half)op/voice) devant chaque utilisateur`
|
||||
** type: booléen
|
||||
|
@ -478,6 +478,11 @@
|
||||
** tipo: bool
|
||||
** valori: on, off (valore predefinito: `off`)
|
||||
|
||||
* *weechat.look.mouse_timer_delay*
|
||||
** descrizione: `delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay before processing event`
|
||||
** tipo: intero
|
||||
** valori: 1 .. 10000 (valore predefinito: `100`)
|
||||
|
||||
* *weechat.look.nickmode*
|
||||
** descrizione: `mostra modalità nick ((half)op/voice) prima di ogni nick`
|
||||
** tipo: bool
|
||||
|
7
po/cs.po
7
po/cs.po
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat 0.3.6-dev\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: 2011-07-05 15:37+0200\n"
|
||||
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -2348,6 +2348,11 @@ msgstr ""
|
||||
msgid "enable mouse support at startup (to enable it now, see /help mouse)"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr "zobrazit mód přezdívky ((částečný)op/voice) před každou přezdívkou"
|
||||
|
||||
|
7
po/de.po
7
po/de.po
@ -22,7 +22,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat 0.3.6-dev\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: 2011-07-14 20:53+0100\n"
|
||||
"Last-Translator: Nils Görs\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -2474,6 +2474,11 @@ msgstr ""
|
||||
msgid "enable mouse support at startup (to enable it now, see /help mouse)"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr "Nickmode ((half)op/voice [@%+]) vor dem Nicknamen anzeigen"
|
||||
|
||||
|
7
po/es.po
7
po/es.po
@ -21,7 +21,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat 0.3.6-dev\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: 2011-07-05 15:37+0200\n"
|
||||
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -2380,6 +2380,11 @@ msgstr ""
|
||||
msgid "enable mouse support at startup (to enable it now, see /help mouse)"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr "mostrar modo del usuario ((semi-)op/voz) antes de cada usuario"
|
||||
|
||||
|
11
po/fr.po
11
po/fr.po
@ -21,8 +21,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat 0.3.6-dev\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"PO-Revision-Date: 2011-07-27 12:56+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: 2011-07-28 14:58+0200\n"
|
||||
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
"Language: French\n"
|
||||
@ -2457,6 +2457,13 @@ msgstr ""
|
||||
"activer le support de la souris au démarrage (pour l'activer maintenant, "
|
||||
"voir /help mouse)"
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
"délai (en millisecondes) pour capturer un évènement de la souris: WeeChat "
|
||||
"attendra ce délai avant de traiter l'évènement"
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr "afficher le mode du pseudo ((half)op/voice) devant chaque utilisateur"
|
||||
|
||||
|
7
po/hu.po
7
po/hu.po
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat 0.3.6-dev\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: 2011-05-15 10:51+0200\n"
|
||||
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -2004,6 +2004,11 @@ msgstr ""
|
||||
msgid "enable mouse support at startup (to enable it now, see /help mouse)"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr "a felhasználó módjának ((fél)operátor/voice) mutatása a név előtt"
|
||||
|
||||
|
7
po/it.po
7
po/it.po
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat 0.3.6-dev\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: 2011-07-16 11:32+0200\n"
|
||||
"Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -2402,6 +2402,11 @@ msgstr ""
|
||||
msgid "enable mouse support at startup (to enable it now, see /help mouse)"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr "mostra modalità nick ((half)op/voice) prima di ogni nick"
|
||||
|
||||
|
7
po/pl.po
7
po/pl.po
@ -21,7 +21,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat 0.3.6-dev\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: 2011-07-05 15:38+0200\n"
|
||||
"Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -2377,6 +2377,11 @@ msgstr ""
|
||||
msgid "enable mouse support at startup (to enable it now, see /help mouse)"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr "wyświetl atrybut nicku ((half)op/voice) przed każdym nickiem"
|
||||
|
||||
|
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat 0.3.6-dev\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: 2011-05-15 10:52+0200\n"
|
||||
"Last-Translator: Ivan Sichmann Freitas <ivansichfreitas@gmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -2355,6 +2355,11 @@ msgstr ""
|
||||
msgid "enable mouse support at startup (to enable it now, see /help mouse)"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr ""
|
||||
|
||||
|
7
po/ru.po
7
po/ru.po
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat 0.3.6-dev\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: 2011-05-15 10:52+0200\n"
|
||||
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -2021,6 +2021,11 @@ msgstr ""
|
||||
msgid "enable mouse support at startup (to enable it now, see /help mouse)"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr "отображать режим ника (op/voice) перед каждым ником"
|
||||
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2011-07-27 12:55+0200\n"
|
||||
"POT-Creation-Date: 2011-07-28 15:34+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1760,6 +1760,11 @@ msgstr ""
|
||||
msgid "enable mouse support at startup (to enable it now, see /help mouse)"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"delay (in milliseconds) to grab a mouse event: WeeChat will wait this delay "
|
||||
"before processing event"
|
||||
msgstr ""
|
||||
|
||||
msgid "display nick mode ((half)op/voice) before each nick"
|
||||
msgstr ""
|
||||
|
||||
|
@ -3112,12 +3112,6 @@ COMMAND_CALLBACK(mouse)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
if (string_strcasecmp (argv[1], "grab") == 0)
|
||||
{
|
||||
gui_mouse_grab_init ();
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,7 @@ struct t_config_option *config_look_item_time_format;
|
||||
struct t_config_option *config_look_jump_current_to_previous_buffer;
|
||||
struct t_config_option *config_look_jump_previous_buffer_when_closing;
|
||||
struct t_config_option *config_look_mouse;
|
||||
struct t_config_option *config_look_mouse_timer_delay;
|
||||
struct t_config_option *config_look_nickmode;
|
||||
struct t_config_option *config_look_nickmode_empty;
|
||||
struct t_config_option *config_look_paste_max_lines;
|
||||
@ -1801,6 +1802,12 @@ config_weechat_init_options ()
|
||||
"mouse", "boolean",
|
||||
N_("enable mouse support at startup (to enable it now, see /help mouse)"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
config_look_mouse_timer_delay = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"mouse_timer_delay", "integer",
|
||||
N_("delay (in milliseconds) to grab a mouse event: WeeChat will "
|
||||
"wait this delay before processing event"),
|
||||
NULL, 1, 10000, "100", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
config_look_nickmode = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"nickmode", "boolean",
|
||||
|
@ -134,6 +134,7 @@ extern struct t_config_option *config_look_item_time_format;
|
||||
extern struct t_config_option *config_look_jump_current_to_previous_buffer;
|
||||
extern struct t_config_option *config_look_jump_previous_buffer_when_closing;
|
||||
extern struct t_config_option *config_look_mouse;
|
||||
extern struct t_config_option *config_look_mouse_timer_delay;
|
||||
extern struct t_config_option *config_look_nickmode;
|
||||
extern struct t_config_option *config_look_nickmode_empty;
|
||||
extern struct t_config_option *config_look_paste_max_lines;
|
||||
|
@ -203,7 +203,6 @@ gui_key_default_bindings (int context)
|
||||
BIND(/* m-9 */ "meta-9", "/buffer *9");
|
||||
BIND(/* m-< */ "meta-<", "/input jump_previously_visited_buffer");
|
||||
BIND(/* m-> */ "meta->", "/input jump_next_visited_buffer");
|
||||
BIND(/* mouse */ "meta2-M", "/mouse grab");
|
||||
BIND(/* m-m */ "meta-m", "/mouse toggle");
|
||||
|
||||
/* bind meta-j + {01..99} to switch to buffers # > 10 */
|
||||
|
@ -31,7 +31,11 @@
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "../../core/wee-config.h"
|
||||
#include "../../core/wee-hook.h"
|
||||
#include "../../core/wee-utf8.h"
|
||||
#include "../../plugins/plugin.h"
|
||||
#include "../gui-chat.h"
|
||||
#include "../gui-key.h"
|
||||
#include "../gui-mouse.h"
|
||||
|
||||
|
||||
@ -69,6 +73,22 @@ gui_mouse_display_state ()
|
||||
_("Mouse is enabled") : _("Mouse is disabled"));
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_mouse_grab_timer_cb: timer for grabbing mouse code
|
||||
*/
|
||||
|
||||
int
|
||||
gui_mouse_grab_timer_cb (void *data, int remaining_calls)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
gui_mouse_grab_end ();
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_mouse_grab_init: init "grab mouse" mode
|
||||
*/
|
||||
@ -77,37 +97,72 @@ void
|
||||
gui_mouse_grab_init ()
|
||||
{
|
||||
gui_mouse_grab = 1;
|
||||
|
||||
if (gui_mouse_event_timer)
|
||||
unhook (gui_mouse_event_timer);
|
||||
|
||||
gui_mouse_event_timer = hook_timer (NULL,
|
||||
CONFIG_INTEGER(config_look_mouse_timer_delay),
|
||||
0, 1,
|
||||
&gui_mouse_grab_timer_cb, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_mouse_grab_code2key: get key name with a mouse code
|
||||
* *extra_chars is set with first char following the
|
||||
* end of mouse code (this can point to the '\0' or
|
||||
* other chars)
|
||||
*/
|
||||
|
||||
const char *
|
||||
gui_mouse_grab_code2key (const char *code)
|
||||
gui_mouse_grab_code2key (const char *code, char **extra_chars)
|
||||
{
|
||||
int x, y;
|
||||
int x, y, code_utf8, length;
|
||||
double diff_x, diff_y, distance, angle, pi4;
|
||||
static char key[128];
|
||||
char button[2];
|
||||
char button[2], *ptr_code;
|
||||
|
||||
/* mouse code must have at least 3 chars */
|
||||
if (strlen (code) < 3)
|
||||
return NULL;
|
||||
*extra_chars = NULL;
|
||||
|
||||
key[0] = '\0';
|
||||
|
||||
/* ignore code '#' (button released) if it's received as first event */
|
||||
if ((gui_mouse_event_index == 0) && (code[0] == '#'))
|
||||
return key;
|
||||
/*
|
||||
* mouse code must have at least:
|
||||
* one code (for event) + X + Y == 3 bytes or 3 UTF-8 chars
|
||||
*/
|
||||
code_utf8 = utf8_is_valid (code, NULL);
|
||||
length = (code_utf8) ? utf8_strlen (code) : (int)strlen (code);
|
||||
if (length < 3)
|
||||
return NULL;
|
||||
|
||||
/* get coordinates and button */
|
||||
if (code_utf8)
|
||||
{
|
||||
/* get coordinates using UTF-8 chars in code */
|
||||
x = utf8_char_int (code + 1) - 33;
|
||||
ptr_code = utf8_next_char (code + 1);
|
||||
if (!ptr_code)
|
||||
return NULL;
|
||||
y = utf8_char_int (ptr_code) - 33;
|
||||
*extra_chars = utf8_next_char (ptr_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get coordinates using ISO chars in code */
|
||||
x = ((unsigned char)code[1]) - 33;
|
||||
y = ((unsigned char)code[2]) - 33;
|
||||
*extra_chars = (char *)code + 3;
|
||||
}
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
y = ((unsigned char)code[2]) - 33;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
|
||||
/* ignore code '#' (button released) if it's received as first event */
|
||||
if ((gui_mouse_event_index == 0) && (code[0] == '#'))
|
||||
return NULL;
|
||||
|
||||
/* set data in "gui_mouse_event_xxx" */
|
||||
gui_mouse_event_x[gui_mouse_event_index] = x;
|
||||
gui_mouse_event_y[gui_mouse_event_index] = y;
|
||||
if (gui_mouse_event_index == 0)
|
||||
@ -129,7 +184,7 @@ gui_mouse_grab_code2key (const char *code)
|
||||
}
|
||||
|
||||
if (code[0] != '#')
|
||||
return key;
|
||||
return NULL;
|
||||
|
||||
/* add button/wheel */
|
||||
switch (gui_mouse_event_button)
|
||||
@ -239,5 +294,40 @@ gui_mouse_grab_code2key (const char *code)
|
||||
void
|
||||
gui_mouse_grab_end ()
|
||||
{
|
||||
const char *mouse_key;
|
||||
char *extra_chars;
|
||||
int i;
|
||||
|
||||
gui_mouse_grab = 0;
|
||||
|
||||
/* end mouse event timer */
|
||||
if (gui_mouse_event_timer)
|
||||
{
|
||||
unhook (gui_mouse_event_timer);
|
||||
gui_mouse_event_timer = NULL;
|
||||
}
|
||||
|
||||
/* get key from mouse code and execute command (if found) */
|
||||
mouse_key = gui_mouse_grab_code2key (gui_key_combo_buffer, &extra_chars);
|
||||
if (mouse_key && mouse_key[0])
|
||||
{
|
||||
(void) gui_key_focus (mouse_key,
|
||||
GUI_KEY_CONTEXT_MOUSE);
|
||||
gui_mouse_reset_event ();
|
||||
}
|
||||
|
||||
gui_key_combo_buffer[0] = '\0';
|
||||
|
||||
/*
|
||||
* if extra chars, use them as new input (this can happen if used typed
|
||||
* something and that mouse timer was not reached yet
|
||||
*/
|
||||
if (extra_chars && extra_chars[0])
|
||||
{
|
||||
for (i = 0; extra_chars[i]; i++)
|
||||
{
|
||||
gui_key_buffer_add ((unsigned char)extra_chars[i]);
|
||||
}
|
||||
gui_key_flush ();
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ char *gui_key_context_string[GUI_KEY_NUM_CONTEXTS] =
|
||||
|
||||
int gui_key_verbose = 0; /* 1 to see some messages */
|
||||
|
||||
char gui_key_combo_buffer[256]; /* buffer used for combos */
|
||||
char gui_key_combo_buffer[1024]; /* buffer used for combos */
|
||||
int gui_key_grab = 0; /* 1 if grab mode enabled (alt-k) */
|
||||
int gui_key_grab_count = 0; /* number of keys pressed in grab mode */
|
||||
int gui_key_grab_command = 0; /* grab command bound to key? */
|
||||
@ -187,7 +187,7 @@ gui_key_grab_init (int grab_command, const char *delay)
|
||||
int
|
||||
gui_key_grab_end_timer_cb (void *data, int remaining_calls)
|
||||
{
|
||||
char *expanded_key;
|
||||
char *expanded_key, *expanded_key2;
|
||||
struct t_gui_key *ptr_key;
|
||||
|
||||
/* make C compiler happy */
|
||||
@ -196,14 +196,35 @@ gui_key_grab_end_timer_cb (void *data, int remaining_calls)
|
||||
|
||||
/* get expanded name (for example: \x01+U => ctrl-u) */
|
||||
expanded_key = gui_key_get_expanded_name (gui_key_combo_buffer);
|
||||
|
||||
if (expanded_key)
|
||||
{
|
||||
/*
|
||||
* the expanded_key should be valid UTF-8 at this point,
|
||||
* but some mouse codes can return ISO chars (for coordinates),
|
||||
* then we will convert them to UTF-8 string
|
||||
*/
|
||||
if (!utf8_is_valid (expanded_key, NULL))
|
||||
{
|
||||
expanded_key2 = string_iconv_to_internal ("iso-8859-1",
|
||||
expanded_key);
|
||||
if (expanded_key2)
|
||||
{
|
||||
free (expanded_key);
|
||||
expanded_key = expanded_key2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* conversion failed, then just replace invalid chars by '?' */
|
||||
utf8_normalize (expanded_key, '?');
|
||||
}
|
||||
}
|
||||
/* add expanded key to input buffer */
|
||||
if (gui_current_window->buffer->input)
|
||||
{
|
||||
gui_input_insert_string (gui_current_window->buffer, expanded_key, -1);
|
||||
if (gui_key_grab_command)
|
||||
{
|
||||
/* add command bound to key (if found) */
|
||||
ptr_key = gui_key_search (gui_keys[GUI_KEY_CONTEXT_DEFAULT],
|
||||
gui_key_combo_buffer);
|
||||
if (ptr_key)
|
||||
@ -734,7 +755,7 @@ gui_key_focus_command (const char *key, int context,
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_key_focus: treat key pressed in cursor or mouse mode,
|
||||
* gui_key_focus: process key pressed in cursor or mouse mode,
|
||||
* looking for keys: "{area}key" in context "cursor" or "mouse"
|
||||
* return 1 if a command was executed, otherwise 0
|
||||
*/
|
||||
@ -748,6 +769,13 @@ gui_key_focus (const char *key, int context)
|
||||
{
|
||||
gui_cursor_get_info (gui_mouse_event_x[0], gui_mouse_event_y[0],
|
||||
&cursor_info);
|
||||
if (gui_mouse_debug)
|
||||
{
|
||||
gui_chat_printf (NULL, "Mouse: %s, (%d,%d) -> (%d,%d)",
|
||||
key,
|
||||
gui_mouse_event_x[0], gui_mouse_event_y[0],
|
||||
gui_mouse_event_x[1], gui_mouse_event_y[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -761,7 +789,7 @@ gui_key_focus (const char *key, int context)
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_key_pressed: treat new key pressed
|
||||
* gui_key_pressed: process new key pressed
|
||||
* return: 1 if key should be added to input buffer
|
||||
* 0 otherwise
|
||||
*/
|
||||
@ -771,8 +799,7 @@ gui_key_pressed (const char *key_str)
|
||||
{
|
||||
int i, first_key, context, length, length_key;
|
||||
struct t_gui_key *ptr_key;
|
||||
char **commands;
|
||||
const char *mouse_key;
|
||||
char **commands, *pos;
|
||||
|
||||
/* add key to buffer */
|
||||
first_key = (gui_key_combo_buffer[0] == '\0');
|
||||
@ -796,20 +823,20 @@ gui_key_pressed (const char *key_str)
|
||||
/* mode "mouse grab" (mouse event pending) */
|
||||
if (gui_mouse_grab)
|
||||
{
|
||||
mouse_key = gui_mouse_grab_code2key (gui_key_combo_buffer);
|
||||
if (mouse_key)
|
||||
pos = strstr (gui_key_combo_buffer, "\x1B[M");
|
||||
if (pos)
|
||||
{
|
||||
gui_key_combo_buffer[0] = '\0';
|
||||
strcat (gui_key_combo_buffer, mouse_key);
|
||||
pos[0] = '\0';
|
||||
gui_mouse_grab_end ();
|
||||
if (gui_key_combo_buffer[0])
|
||||
gui_mouse_grab_init ();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp (gui_key_combo_buffer, "\x01[[M") == 0)
|
||||
{
|
||||
(void) gui_key_focus (gui_key_combo_buffer,
|
||||
GUI_KEY_CONTEXT_MOUSE);
|
||||
gui_key_combo_buffer[0] = '\0';
|
||||
gui_mouse_reset_event ();
|
||||
}
|
||||
}
|
||||
gui_mouse_grab_init ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ extern struct t_gui_key *gui_key_bind (struct t_gui_buffer *buffer,
|
||||
const char *command);
|
||||
extern int gui_key_unbind (struct t_gui_buffer *buffer, int context,
|
||||
const char *key, int send_signal);
|
||||
extern int gui_key_focus (const char *key, int context);
|
||||
extern int gui_key_pressed (const char *key_str);
|
||||
extern void gui_key_free (struct t_gui_key **keys,
|
||||
struct t_gui_key **last_key,
|
||||
@ -104,5 +105,6 @@ extern void gui_key_print_log (struct t_gui_buffer *buffer);
|
||||
/* key functions (GUI dependent) */
|
||||
|
||||
extern void gui_key_default_bindings ();
|
||||
extern void gui_key_flush ();
|
||||
|
||||
#endif /* __WEECHAT_GUI_KEY_H */
|
||||
|
@ -35,6 +35,8 @@
|
||||
int gui_mouse_enabled = 0; /* 1 if mouse support is enabled */
|
||||
int gui_mouse_debug = 0; /* debug mode for mouse */
|
||||
int gui_mouse_grab = 0; /* 1 if grab mouse code enabled */
|
||||
struct t_hook *gui_mouse_event_timer = NULL; /* timer to detect entire */
|
||||
/* mouse event */
|
||||
int gui_mouse_event_index = 0; /* index for x/y in array (0 or 1) */
|
||||
int gui_mouse_event_x[2] = { 0, 0 }; /* position of latest mouse event: */
|
||||
/* (on click, on release) */
|
||||
|
@ -25,6 +25,7 @@
|
||||
extern int gui_mouse_enabled;
|
||||
extern int gui_mouse_debug;
|
||||
extern int gui_mouse_grab;
|
||||
extern struct t_hook *gui_mouse_event_timer;
|
||||
extern int gui_mouse_event_index;
|
||||
extern int gui_mouse_event_x[2];
|
||||
extern int gui_mouse_event_y[2];
|
||||
@ -41,7 +42,6 @@ extern void gui_mouse_enable ();
|
||||
extern void gui_mouse_disable ();
|
||||
extern void gui_mouse_display_state ();
|
||||
extern void gui_mouse_grab_init ();
|
||||
extern const char *gui_mouse_grab_code2key (const char *code);
|
||||
extern void gui_mouse_grab_end ();
|
||||
|
||||
#endif /* __WEECHAT_GUI_MOUSE_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user