diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-10-05 18:15:28 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-10-05 18:15:28 +0200 |
commit | b9dd668d90704c0b66300fe8a6f4f41de5c1d2aa (patch) | |
tree | 7c82d653cf0b527fc7833c1e3779bfc83e16c620 | |
parent | 971e464e860866a80415ecf57857c8eb7d1e75aa (diff) | |
download | weechat-b9dd668d90704c0b66300fe8a6f4f41de5c1d2aa.zip |
core: add modifiers control/alt ("ctrl" and "alt") for mouse events
-rw-r--r-- | doc/asciidoc.conf | 3 | ||||
-rw-r--r-- | doc/de/weechat_user.de.txt | 74 | ||||
-rw-r--r-- | doc/en/weechat_user.en.txt | 69 | ||||
-rw-r--r-- | doc/fr/weechat_user.fr.txt | 70 | ||||
-rw-r--r-- | doc/it/weechat_user.it.txt | 75 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-mouse.c | 101 |
6 files changed, 275 insertions, 117 deletions
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf index 29105d575..73b4bff24 100644 --- a/doc/asciidoc.conf +++ b/doc/asciidoc.conf @@ -1,7 +1,10 @@ [replacements] @k\(C-\)=<span class="key ctrl">Ctrl</span><span class="keyplus">+</span> +@k\(-C-\)=<span class="key ctrl">Ctrl</span> @k\(A-\)=<span class="key alt">Alt</span><span class="keyplus">+</span> +@k\(-A-\)=<span class="key alt">Alt</span> @k\(S-\)=<span class="key shift">Shift</span><span class="keyplus">+</span> +@k\(-S-\)=<span class="key shift">Shift</span> @k\(l\)=<span class="key">l</span><span class="keyplus"> (L)</span> @k\(([A-Za-z0-9_&\=])\)=<span class="key">\1</span> @k\(([a-z0-9_&\=][^)]*)\)=<span class="key">\1</span> diff --git a/doc/de/weechat_user.de.txt b/doc/de/weechat_user.de.txt index 61f015e37..ede163903 100644 --- a/doc/de/weechat_user.de.txt +++ b/doc/de/weechat_user.de.txt @@ -659,35 +659,71 @@ WeeChat definiert sind (siehe <<key_bindings_mouse_context,Tasten für "mouse"-K Man kann mit dem Befehl `/key` im Kontext "mouse" aber auch eigene Befehle zuweisen und löschen (für die Syntax, siehe <<command_weechat_key,/key Befehl>>). -Auflistung von Events die unterstützt werden: +// TRANSLATION MISSING +Event name consists of a modifier (optional), a button/wheel name and a gesture +(optional). Different elements are separated by "-". -[width="80%",cols="3m,4",options="header"] +// TRANSLATION MISSING +List of modifiers: + +[width="50%",cols="3m,4",options="header"] |======================================== -| Event | Beschreibung -| button1 | linker Mausknopf wird gedrückt -| button2 | rechter Mausknopf wird gedrückt -| button3 | mittlerer Mausknopf wird gedrückt (häufig der Druck auf das Mausrad) -| button4 ... button9 | ein zusätzlicher Mausknopf wird gedrückt -| wheelup | Mausrad wird nach oben gescrollt -| wheeldown | Mausrad wird nach unten gescrollt -| buttonX-gesture-up ^(1)^ | Mausgeste mit einer Länge von 3 bis 19 Zeichen -| buttonX-gesture-up-long ^(1)^ | Mausgeste mit einer Länge von 20 und mehr Zeichen -| buttonX-gesture-down ^(1)^ | Mausgeste mit einer Länge von 3 bis 19 Zeichen -| buttonX-gesture-down-long ^(1)^ | Mausgeste mit einer Länge von 20 und mehr Zeichen -| buttonX-gesture-left ^(1)^ | Mausgeste mit einer Länge von 3 bis 39 Zeichen -| buttonX-gesture-left-long ^(1)^ | Mausgeste mit einer Länge von 40 und mehr Zeichen -| buttonX-gesture-right ^(1)^ | Mausgeste mit einer Länge von 3 bis 39 Zeichen -| buttonX-gesture-right-long ^(1)^ | Mausgeste mit einer Länge von 40 und mehr Zeichen +| Modifier | Description +| ctrl | key @k(-C-) +| alt | key @k(-A-) +| ctrl-alt | keys @k(-C-) and @k(-A-) |======================================== -[NOTE] -^(1)^ "X" muss durch die Nummer des Mausknopfes ersetzt werden (1 bis 9) die für die Mausgeste genutzt werden soll. +// TRANSLATION MISSING +List of buttons/wheel: + +[width="50%",cols="3m,4",options="header"] +|======================================== +| Button/wheel | Description +| button1 | linker Mausknopf wird gedrückt +| button2 | rechter Mausknopf wird gedrückt +| button3 | mittlerer Mausknopf wird gedrückt (häufig der Druck auf das Mausrad) +| button4 ... button9 | ein zusätzlicher Mausknopf wird gedrückt +| wheelup | Mausrad wird nach oben gescrollt +| wheeldown | Mausrad wird nach unten gescrollt +|======================================== + +// TRANSLATION MISSING +List of gestures (only for buttons, not wheel): + +[width="50%",cols="3m,4",options="header"] +|======================================== +| Gesture | Distance +| gesture-up | 3 ... 19 +| gesture-up-long | ≥ 20 +| gesture-down | 3 ... 19 +| gesture-down-long | ≥ 20 +| gesture-left | 3 ... 39 +| gesture-left-long | ≥ 40 +| gesture-right | 3 ... 39 +| gesture-right-long | ≥ 40 +|======================================== + +// TRANSLATION MISSING +Example of events: + +* `button1` +* `ctrl-button1` +* `button1-gesture-right` +* `alt-button2-gesture-down-long` +* `wheelup` +* `ctrl-alt-wheeldown` [TIP] Wird eine Funktion im "mouse"-Kontext hinzufügt ist es möglich mehrere Events mittels `*` abzufangen. Zum Beispiel: `button1-gesture-*` fängt alle Mausgesten ab, die mit der linken Maustaste eingeleitet werden. +// TRANSLATION MISSING +[TIP] +You can find an event name with command `/input grab_mouse` then doing event +with mouse. This will insert event name on command line. + [[command_line]] Befehlszeile ~~~~~~~~~~~~ diff --git a/doc/en/weechat_user.en.txt b/doc/en/weechat_user.en.txt index b2a3d0f63..22dba7a60 100644 --- a/doc/en/weechat_user.en.txt +++ b/doc/en/weechat_user.en.txt @@ -658,35 +658,66 @@ Many default mouse events are already defined by WeeChat (see You can change or add bindings with the command `/key` using context "mouse" (for syntax, see <<command_weechat_key,command /key>>). -List of events supported: +Event name consists of a modifier (optional), a button/wheel name and a gesture +(optional). Different elements are separated by "-". -[width="80%",cols="3m,4",options="header"] +List of modifiers: + +[width="50%",cols="3m,4",options="header"] |======================================== -| Event | Description -| button1 | click on left button -| button2 | click on right button -| button3 | click on middle button (often click on wheel) -| button4 ... button9 | click on extra buttons -| wheelup | wheel (up) -| wheeldown | wheel (down) -| buttonX-gesture-up ^(1)^ | gesture with distance between 3 and 19 -| buttonX-gesture-up-long ^(1)^ | gesture with distance greater than or equal to 20 -| buttonX-gesture-down ^(1)^ | gesture with distance between 3 and 19 -| buttonX-gesture-down-long ^(1)^ | gesture with distance greater than or equal to 20 -| buttonX-gesture-left ^(1)^ | gesture with distance between 3 and 39 -| buttonX-gesture-left-long ^(1)^ | gesture with distance greater than or equal to 40 -| buttonX-gesture-right ^(1)^ | gesture with distance between 3 and 39 -| buttonX-gesture-right-long ^(1)^ | gesture with distance greater than or equal to 40 +| Modifier | Description +| ctrl | key @k(-C-) +| alt | key @k(-A-) +| ctrl-alt | keys @k(-C-) and @k(-A-) |======================================== -[NOTE] -^(1)^ "X" is number of button used in gesture (1 to 9). +List of buttons/wheel: + +[width="50%",cols="3m,4",options="header"] +|======================================== +| Button/wheel | Description +| button1 | click on left button +| button2 | click on right button +| button3 | click on middle button (often click on wheel) +| button4 ... button9 | click on extra buttons +| wheelup | wheel (up) +| wheeldown | wheel (down) +|======================================== + +List of gestures (only for buttons, not wheel): + +[width="50%",cols="3m,4",options="header"] +|======================================== +| Gesture | Distance +| gesture-up | 3 ... 19 +| gesture-up-long | ≥ 20 +| gesture-down | 3 ... 19 +| gesture-down-long | ≥ 20 +| gesture-left | 3 ... 39 +| gesture-left-long | ≥ 40 +| gesture-right | 3 ... 39 +| gesture-right-long | ≥ 40 +|======================================== + +Example of events: + +* `button1` +* `ctrl-button1` +* `button1-gesture-right` +* `alt-button2-gesture-down-long` +* `wheelup` +* `ctrl-alt-wheeldown` +* ... [TIP] When binding a key in context "mouse", it's possible to match many events using `*` at beginning or end of name, for example `button1-gesture-*` will match any gesture made using left button. +[TIP] +You can find an event name with command `/input grab_mouse` then doing event +with mouse. This will insert event name on command line. + [[command_line]] Command line ~~~~~~~~~~~~ diff --git a/doc/fr/weechat_user.fr.txt b/doc/fr/weechat_user.fr.txt index 40fdbbd1e..0a80e1115 100644 --- a/doc/fr/weechat_user.fr.txt +++ b/doc/fr/weechat_user.fr.txt @@ -674,29 +674,56 @@ Vous pouvez modifier ou ajouter des associations avec la commande `/key` en utilisant le contexte "mouse" (pour la syntaxe voir <<command_weechat_key,la commande /key>>). -Liste des évènements supportés : +Un nom d'évènement consiste en un modifieur (facultatif), un bouton/roulette et +un geste (facultatif). Les différents éléments sont séparés par "-". -[width="80%",cols="3m,4",options="header"] +Liste des modifieurs : + +[width="50%",cols="3m,4",options="header"] |======================================== -| Evènement | Description -| button1 | clic sur le bouton gauche -| button2 | clic sur le bouton droit -| button3 | clic sur le bouton du milieu (souvent clic sur la roulette) -| button4 ... button9 | clic sur un bouton additionnel -| wheelup | roulette (haut) -| wheeldown | roulette (bas) -| buttonX-gesture-up ^(1)^ | geste avec distance entre 3 et 19 -| buttonX-gesture-up-long ^(1)^ | geste avec distance supérieure ou égale à 20 -| buttonX-gesture-down ^(1)^ | geste avec distance entre 3 et 19 -| buttonX-gesture-down-long ^(1)^ | geste avec distance supérieure ou égale à 20 -| buttonX-gesture-left ^(1)^ | geste avec distance entre 3 et 39 -| buttonX-gesture-left-long ^(1)^ | geste avec distance supérieure ou égale à 40 -| buttonX-gesture-right ^(1)^ | geste avec distance entre 3 et 39 -| buttonX-gesture-right-long ^(1)^ | geste avec distance supérieure ou égale à 40 +| Modifieur | Description +| ctrl | touche @k(-C-) +| alt | touche @k(-A-) +| ctrl-alt | touches @k(-C-) et @k(-A-) |======================================== -[NOTE] -^(1)^ "X" est le numéro du bouton utilisé pour le geste (1 à 9). +Liste des boutons/roulette : + +[width="50%",cols="3m,4",options="header"] +|======================================== +| Bouton/roulette | Description +| button1 | clic sur le bouton gauche +| button2 | clic sur le bouton droit +| button3 | clic sur le bouton du milieu (souvent clic sur la roulette) +| button4 ... button9 | clic sur un bouton additionnel +| wheelup | roulette (haut) +| wheeldown | roulette (bas) +|======================================== + +Liste des gestes (seulement pour les boutons, pas la roulette) : + +[width="50%",cols="3m,4",options="header"] +|======================================== +| Geste | Distance +| gesture-up | 3 ... 19 +| gesture-up-long | ≥ 20 +| gesture-down | 3 ... 19 +| gesture-down-long | ≥ 20 +| gesture-left | 3 ... 39 +| gesture-left-long | ≥ 40 +| gesture-right | 3 ... 39 +| gesture-right-long | ≥ 40 +|======================================== + +Exemple d'évènements : + +* `button1` +* `ctrl-button1` +* `button1-gesture-right` +* `alt-button2-gesture-down-long` +* `wheelup` +* `ctrl-alt-wheeldown` +* ... [TIP] Lors de l'association d'une touche dans le contexte "mouse", il est possible @@ -704,6 +731,11 @@ d'adresser plusieurs évènements en utilisant `*` au début ou la fin du nom, par exemple `button1-gesture-*` qui correspond à n'importe quel geste effectué avec le bouton gauche. +[TIP] +Vous pouvez trouver le nom de l'évènement avec la commande `/input grab_mouse` +puis en faisant l'action avec la souris. Cela insèrera le nom de l'évènement +sur la ligne de commande. + [[command_line]] Ligne de commande ~~~~~~~~~~~~~~~~~ diff --git a/doc/it/weechat_user.it.txt b/doc/it/weechat_user.it.txt index c2a654af9..ea6a49c15 100644 --- a/doc/it/weechat_user.it.txt +++ b/doc/it/weechat_user.it.txt @@ -669,35 +669,72 @@ Molti eventi del mouse predefiniti sono già definiti da WeeChat (consultare È possibile cambiare o aggiungere combinazioni con il comando `/key` usando il contesto "mouse" (per la sintassi, consultare <<command_weechat_key,comando /key>>). -List of events supported: +// TRANSLATION MISSING +Event name consists of a modifier (optional), a button/wheel name and a gesture +(optional). Different elements are separated by "-". + +// TRANSLATION MISSING +List of modifiers: -[width="80%",cols="3m,4",options="header"] +[width="50%",cols="3m,4",options="header"] |======================================== -| Evento | Descrizione -| button1 | click sul tasto sinistro -| button2 | click sul tasto destro -| button3 | click sul tasto centrale (spesso click sulla rotellina) -| button4 ... button9 | click sui pulsanti extra -| wheelup | rotellina (su) -| wheeldown | rotellina (giù) -| buttonX-gesture-up ^(1)^ | azione con distanza tra 3 and 19 -| buttonX-gesture-up-long ^(1)^ | azione con distanza maggiore o uguale a 20 -| buttonX-gesture-down ^(1)^ | azione con distanza tra 3 e 19 -| buttonX-gesture-down-long ^(1)^ | azione con distanza maggiore o uguale a 20 -| buttonX-gesture-left ^(1)^ | azione con distanza tra 3 e 39 -| buttonX-gesture-left-long ^(1)^ | azione con distanza maggiore o uguale a 40 -| buttonX-gesture-right ^(1)^ | azione con distanza tra 3 e 39 -| buttonX-gesture-right-long ^(1)^ | azione con distanza maggiore o uguale a 40 +| Modifier | Description +| ctrl | key @k(-C-) +| alt | key @k(-A-) +| ctrl-alt | keys @k(-C-) and @k(-A-) |======================================== -[NOTE] -^(1)^ "X" è il numero del pulsante usato nell'azione (da 1 a 9). +// TRANSLATION MISSING +List of buttons/wheel: + +[width="50%",cols="3m,4",options="header"] +|======================================== +| Button/wheel | Description +| button1 | click sul tasto sinistro +| button2 | click sul tasto destro +| button3 | click sul tasto centrale (spesso click sulla rotellina) +| button4 ... button9 | click sui pulsanti extra +| wheelup | rotellina (su) +| wheeldown | rotellina (giù) +|======================================== + +// TRANSLATION MISSING +List of gestures (only for buttons, not wheel): + +[width="50%",cols="3m,4",options="header"] +|======================================== +| Gesture | Distance +| gesture-up | 3 ... 19 +| gesture-up-long | ≥ 20 +| gesture-down | 3 ... 19 +| gesture-down-long | ≥ 20 +| gesture-left | 3 ... 39 +| gesture-left-long | ≥ 40 +| gesture-right | 3 ... 39 +| gesture-right-long | ≥ 40 +|======================================== + +// TRANSLATION MISSING +Example of events: + +* `button1` +* `ctrl-button1` +* `button1-gesture-right` +* `alt-button2-gesture-down-long` +* `wheelup` +* `ctrl-alt-wheeldown` +* ... [TIP] Quando si associa un tasto nel contesto "mouse", è possibile far corrispondere più eventi usando '*' all'inizio o alla fine del nome, ad esempio `button1-gesture-*` corrisponderà ad ogni azione compiuta col tasto sinistro. +// TRANSLATION MISSING +[TIP] +You can find an event name with command `/input grab_mouse` then doing event +with mouse. This will insert event name on command line. + [[command_line]] Riga di comando ~~~~~~~~~~~~~~~ diff --git a/src/gui/curses/gui-curses-mouse.c b/src/gui/curses/gui-curses-mouse.c index a25dfa93a..30fb0a0dc 100644 --- a/src/gui/curses/gui-curses-mouse.c +++ b/src/gui/curses/gui-curses-mouse.c @@ -46,6 +46,41 @@ #include "../gui-window.h" +#define MOUSE_CODE_BUTTON(code) ((code >= 32) && (code < 64)) +#define MOUSE_CODE_MOTION(code) ((code >= 64) && (code < 96)) +#define MOUSE_CODE_END(code) ((code == '#') || (code == '3') \ + || (code == '+') || (code == ';')) + +char *gui_mouse_wheel_codes[][2] = +{ { "`", "wheelup" }, + { "p", "ctrl-wheelup" }, + { "h", "alt-wheelup" }, + { "x", "ctrl-alt-wheelup" }, + { "a", "wheeldown" }, + { "q", "ctrl-wheeldown" }, + { "i", "alt-wheeldown" }, + { "y", "ctrl-alt-wheeldown" }, + { NULL, NULL } }; +char *gui_mouse_button_codes[][2] = +{ { " ", "button1" }, + { "\"", "button2" }, + { "!", "button3" }, + { "b", "button4" }, + { "c", "button5" }, + { "d", "button6" }, + { "e", "button7" }, + { "f", "button8" }, + { "g", "button9" }, + { "0", "ctrl-button1" }, + { "2", "ctrl-button2" }, + { "1", "ctrl-button3" }, + { "(", "alt-button1" }, + { "*", "alt-button2" }, + { ")", "alt-button3" }, + { "8", "ctrl-alt-button1" }, + { NULL, NULL } }; + + /* * gui_mouse_enable: enable mouse */ @@ -212,10 +247,10 @@ gui_mouse_event_init () const char * gui_mouse_event_code2key (const char *code) { - int x, y, code_utf8, length; + int i, x, y, code_utf8, length; double diff_x, diff_y, distance, angle, pi4; static char key[128]; - char button[2], *ptr_code; + char *ptr_code; key[0] = '\0'; @@ -249,12 +284,12 @@ gui_mouse_event_code2key (const char *code) if (y < 0) y = 0; - /* - * ignore code '#' (button released) or '@' (coordinates) if it's received - * as first event - */ - if ((gui_mouse_event_index == 0) && ((code[0] == '#') || (code[0] == '@'))) + /* ignore code if it's motion/end code received as first event */ + if ((gui_mouse_event_index == 0) + && (MOUSE_CODE_MOTION(code[0]) || MOUSE_CODE_END(code[0]))) + { return NULL; + } /* set data in "gui_mouse_event_xxx" */ gui_mouse_event_x[gui_mouse_event_index] = x; @@ -265,47 +300,31 @@ gui_mouse_event_code2key (const char *code) if (gui_mouse_event_index == 0) gui_mouse_event_index = 1; - if (code[0] == '`') - { - gui_mouse_event_x[1] = gui_mouse_event_x[0]; - gui_mouse_event_y[1] = gui_mouse_event_y[0]; - strcat (key, "wheelup"); - return key; - } - - if (code[0] == 'a') + /* + * browse wheel codes, if one code is found, return event name immediately + */ + for (i = 0; gui_mouse_wheel_codes[i][0]; i++) { - gui_mouse_event_x[1] = gui_mouse_event_x[0]; - gui_mouse_event_y[1] = gui_mouse_event_y[0]; - strcat (key, "wheeldown"); - return key; + if (code[0] == gui_mouse_wheel_codes[i][0][0]) + { + strcat (key, gui_mouse_wheel_codes[i][1]); + gui_mouse_event_x[1] = gui_mouse_event_x[0]; + gui_mouse_event_y[1] = gui_mouse_event_y[0]; + return key; + } } - if (code[0] != '#') + if (!MOUSE_CODE_END(code[0])) return NULL; - /* add button/wheel */ - switch (gui_mouse_event_button) + /* add name of button event */ + for (i = 0; gui_mouse_button_codes[i][0]; i++) { - case ' ': /* left button pressed */ - strcat (key, "button1"); - break; - case '"': /* right button pressed */ - strcat (key, "button2"); - break; - case '!': /* middle button pressed */ - strcat (key, "button3"); - break; - default: /* extra buttons: button4..button9 */ - if ((gui_mouse_event_button >= 'b') - && (gui_mouse_event_button <= 'g')) - { - button[0] = gui_mouse_event_button - ('b' - '4'); - button[1] = '\0'; - strcat (key, "button"); - strcat (key, button); - } + if (gui_mouse_event_button == gui_mouse_button_codes[i][0][0]) + { + strcat (key, gui_mouse_button_codes[i][1]); break; + } } /* |