diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-06-17 10:03:04 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-06-26 21:55:48 +0200 |
commit | f62022e8125ad1f36c0c8f6f7db44e153d68a05e (patch) | |
tree | 3719ddf7a218569af92c45783799df7400f9c657 | |
parent | 54dd19da92a2200e226232a78c901719f96d332c (diff) | |
download | weechat-f62022e8125ad1f36c0c8f6f7db44e153d68a05e.zip |
core: add variables "_chat_focused_line_bol" and "_chat_focused_line_eol" in focus data (closes #1955)
These variables are the same as "_chat_bol" and "_chat_eol" except that they
stop at the beginning of the focused line (not the whole message displayed, in
case message has multiple lines separated by "\n").
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | doc/en/weechat_plugin_api.en.adoc | 14 | ||||
-rw-r--r-- | doc/fr/weechat_plugin_api.fr.adoc | 14 | ||||
-rw-r--r-- | doc/it/weechat_plugin_api.it.adoc | 16 | ||||
-rw-r--r-- | doc/ja/weechat_plugin_api.ja.adoc | 16 | ||||
-rw-r--r-- | doc/sr/weechat_plugin_api.sr.adoc | 18 | ||||
-rw-r--r-- | src/gui/gui-focus.c | 8 | ||||
-rw-r--r-- | src/gui/gui-focus.h | 2 | ||||
-rw-r--r-- | src/gui/gui-window.c | 22 | ||||
-rw-r--r-- | src/gui/gui-window.h | 2 |
10 files changed, 93 insertions, 20 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index b470586da..bc5dfcf95 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -15,6 +15,7 @@ For a list of important changes that require manual actions, please look at rele New features:: + * core: add variables "_chat_focused_line_bol" and "_chat_focused_line_eol" in focus data (issue #1955) * api: add info "buffer" (issue #1962) Bug fixes:: diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index b450ef8d2..d6d264fa5 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -12902,7 +12902,7 @@ This function is not available in scripting API. ==== hook_focus -_Updated in 1.5._ +_Updated in 1.5, 4.0.0, 4.1.0._ Hook a focus: mouse event or key pressed in cursor mode (free movement of cursor). @@ -13017,16 +13017,22 @@ Content of hashtable sent to callback (keys and values are of type "string"): | _chat_line_message | Message of line. | "Hello world!" | "" -| _chat_focused_line | Line at (x,y) _(WeeChat ≥ 4.0.0)_. +| _chat_focused_line | Line at (x, y) _(WeeChat ≥ 4.0.0)_. | "Hello world!" | "" +| _chat_focused_line_bol | Text from beginning of line to (x-1, y) _(WeeChat ≥ 4.1.0)_. +| "Hello" | "" + +| _chat_focused_line_eol | Text from (x, y) to end of line _(WeeChat ≥ 4.1.0)_. +| "llo world!" | "" + | _chat_word | Word at (x,y). | "Hello" | "" -| _chat_bol | Text from beginning of line to (x-1, y). +| _chat_bol | Text from beginning of message to (x-1, y). | "He" | "" -| _chat_eol | Text from (x, y) to the end of line. +| _chat_eol | Text from (x, y) to the end of message. | "llo world!" | "" | _bar_name | Name of bar. diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index dc76d8667..d2a4b001b 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -13192,7 +13192,7 @@ Cette fonction n'est pas disponible dans l'API script. ==== hook_focus -_Mis à jour dans la 1.5._ +_Mis à jour dans la 1.5, 4.0.0, 4.1.0._ Accrocher un focus : évènement souris ou touche du clavier pressée dans le mode "curseur" (mouvement libre du curseur). @@ -13312,16 +13312,22 @@ valeurs sont de type "string") : | _chat_line_message | Message de la ligne. | "Hello world!" | "" -| _chat_focused_line | Ligne à la position (x,y) _(WeeChat ≥ 4.0.0)_. +| _chat_focused_line | Ligne à la position (x, y) _(WeeChat ≥ 4.0.0)_. | "Hello world!" | "" +| _chat_focused_line_bol | Texte du début de la ligne jusqu'à (x-1, y) _(WeeChat ≥ 4.1.0)_. +| "Hello" | "" + +| _chat_focused_line_eol | Texte de (x, y) jusqu'à la fin de la ligne _(WeeChat ≥ 4.1.0)_. +| "llo world!" | "" + | _chat_word | Mot à la position (x,y). | "Hello" | "" -| _chat_bol | Texte du début de ligne jusqu'à (x-1, y). +| _chat_bol | Texte du début du message jusqu'à (x-1, y). | "He" | "" -| _chat_eol | Texte de (x, y) jusqu'à la fin de la ligne. +| _chat_eol | Texte de (x, y) jusqu'à la fin du message. | "llo world!" | "" | _bar_name | Nom de la barre. diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index 21faf71b4..4e0d4960d 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -13486,7 +13486,7 @@ Questa funzione non è disponibile nelle API per lo scripting. ==== hook_focus // TRANSLATION MISSING -_Updated in 1.5._ +_Updated in 1.5, 4.0.0, 4.1.0._ Hook sul foucus: evento del mouse o tasto premuto nella modalità cursore (movimento libero del cursore). @@ -13606,18 +13606,26 @@ Contenuto della tabella hash inviata alla callback (tasti e valori sono di tipo | "Hello world!" | "" // TRANSLATION MISSING -| _chat_focused_line | Line at (x,y) _(WeeChat ≥ 4.0.0)_. +| _chat_focused_line | Line at (x, y) _(WeeChat ≥ 4.0.0)_. | "Hello world!" | "" +// TRANSLATION MISSING +| _chat_focused_line_bol | Text from beginning of line to (x-1, y) _(WeeChat ≥ 4.1.0)_. +| "Hello" | "" + +// TRANSLATION MISSING +| _chat_focused_line_eol | Text from (x, y) to end of line _(WeeChat ≥ 4.1.0)_. +| "llo world!" | "" + | _chat_word | Parola a (x,y). | "Hello" | "" // TRANSLATION MISSING -| _chat_bol | Text from beginning of line to (x-1, y). +| _chat_bol | Text from beginning of message to (x-1, y). | "He" | "" // TRANSLATION MISSING -| _chat_eol | Text from (x, y) to the end of line. +| _chat_eol | Text from (x, y) to the end of message. | "llo world!" | "" | _bar_name | Nome della barra. diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index a91911069..0a79e0e09 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -13051,7 +13051,7 @@ struct t_hook *my_hdata = weechat_hook_hdata ("my_hdata", ==== hook_focus -_WeeChat バージョン 1.5 で更新。_ +_WeeChat バージョン 1.5, 4.0.0, 4.1.0 で更新。_ フォーカス (マウスイベントやカーソルモード (カーソルが自由に移動出来る状態) でキーが押されたこと) をフック。 @@ -13168,18 +13168,26 @@ info を使う前にエリアが一致していることを確認して下さい | "Hello world!" | "" // TRANSLATION MISSING -| _chat_focused_line | Line at (x,y) _(WeeChat ≥ 4.0.0)_. +| _chat_focused_line | Line at (x, y) _(WeeChat ≥ 4.0.0)_. | "Hello world!" | "" +// TRANSLATION MISSING +| _chat_focused_line_bol | Text from beginning of line to (x-1, y) _(WeeChat ≥ 4.1.0)_. +| "Hello" | "" + +// TRANSLATION MISSING +| _chat_focused_line_eol | Text from (x, y) to end of line _(WeeChat ≥ 4.1.0)_. +| "llo world!" | "" + | _chat_word | (x,y) の位置にある単語 | "Hello" | "" // TRANSLATION MISSING -| _chat_bol | Text from beginning of line to (x-1, y). +| _chat_bol | Text from beginning of message to (x-1, y). | "He" | "" // TRANSLATION MISSING -| _chat_eol | Text from (x, y) to the end of line. +| _chat_eol | Text from (x, y) to the end of message. | "llo world!" | "" | _bar_name | バーの名前 diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc index adc3f536e..6074d2cf7 100644 --- a/doc/sr/weechat_plugin_api.sr.adoc +++ b/doc/sr/weechat_plugin_api.sr.adoc @@ -12482,7 +12482,7 @@ struct t_hook *my_hdata = weechat_hook_hdata ("my_hdata", ==== hook_focus -_Ажурирано у верзији 1.5._ +_Ажурирано у верзији 1.5, 4.0.0, 4.1.0._ Качи се на фокус: догађај миша или тастер притиснут у режиму померања курсора. @@ -12584,16 +12584,26 @@ struct t_hook *weechat_hook_focus (const char *area, | _chat_line_message | Порука линије. | "Hello world!" | "" -| _chat_focused_line | Линија на (x,y) _(WeeChat ≥ 4.0.0)_. +| _chat_focused_line | Линија на (x, y) _(WeeChat ≥ 4.0.0)_. | "Здраво свима!" | "" +// TRANSLATION MISSING +| _chat_focused_line_bol | Text from beginning of line to (x-1, y) _(WeeChat ≥ 4.1.0)_. +| "Hello" | "" + +// TRANSLATION MISSING +| _chat_focused_line_eol | Text from (x, y) to end of line _(WeeChat ≥ 4.1.0)_. +| "llo world!" | "" + | _chat_word | Реч на (x,y). | "Здраво" | "" -| _chat_bol | Текст од почетка линије до (x-1, y). +// TRANSLATION MISSING +| _chat_bol | Text from beginning of message to (x-1, y). | "Зд" | "" -| _chat_eol | Тест од (x, y) до краја линије. +// TRANSLATION MISSING +| _chat_eol | Text from (x, y) to the end of message. | "раво свете!" | "" | _bar_name | Име траке. diff --git a/src/gui/gui-focus.c b/src/gui/gui-focus.c index 85362a10c..d00e091c5 100644 --- a/src/gui/gui-focus.c +++ b/src/gui/gui-focus.c @@ -72,6 +72,8 @@ gui_focus_get_info (int x, int y) &focus_info->chat_line_x, &focus_info->chat_word, &focus_info->chat_focused_line, + &focus_info->chat_focused_line_bol, + &focus_info->chat_focused_line_eol, &focus_info->chat_bol, &focus_info->chat_eol); @@ -102,6 +104,10 @@ gui_focus_free_info (struct t_gui_focus_info *focus_info) free (focus_info->chat_word); if (focus_info->chat_focused_line) free (focus_info->chat_focused_line); + if (focus_info->chat_focused_line_bol) + free (focus_info->chat_focused_line_bol); + if (focus_info->chat_focused_line_eol) + free (focus_info->chat_focused_line_eol); if (focus_info->chat_bol) free (focus_info->chat_bol); if (focus_info->chat_eol) @@ -242,6 +248,8 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key) } HASHTABLE_SET_STR_NOT_NULL("_chat_word", focus_info->chat_word); HASHTABLE_SET_STR_NOT_NULL("_chat_focused_line", focus_info->chat_focused_line); + HASHTABLE_SET_STR_NOT_NULL("_chat_focused_line_bol", focus_info->chat_focused_line_bol); + HASHTABLE_SET_STR_NOT_NULL("_chat_focused_line_eol", focus_info->chat_focused_line_eol); HASHTABLE_SET_STR_NOT_NULL("_chat_bol", focus_info->chat_bol); HASHTABLE_SET_STR_NOT_NULL("_chat_eol", focus_info->chat_eol); diff --git a/src/gui/gui-focus.h b/src/gui/gui-focus.h index ad0793ad9..fde69e142 100644 --- a/src/gui/gui-focus.h +++ b/src/gui/gui-focus.h @@ -32,6 +32,8 @@ struct t_gui_focus_info int chat_line_x; /* x in line */ char *chat_word; /* word at (x,y) */ char *chat_focused_line; /* line at (x,y) */ + char *chat_focused_line_bol; /* beg. of focused line until (x,y) */ + char *chat_focused_line_eol; /* (x,y) until end of focused line */ char *chat_bol; /* beginning of line until (x,y) */ char *chat_eol; /* (x,y) until end of line */ struct t_gui_bar_window *bar_window; /* bar window found */ diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index f8040fe27..013704f41 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -137,6 +137,8 @@ gui_window_get_context_at_xy (struct t_gui_window *window, int *line_x, char **word, char **focused_line, + char **focused_line_beginning, + char **focused_line_end, char **beginning, char **end) { @@ -150,6 +152,8 @@ gui_window_get_context_at_xy (struct t_gui_window *window, *line_x = -1; *word = NULL; *focused_line = NULL; + *focused_line_beginning = NULL; + *focused_line_end = NULL; *beginning = NULL; *end = NULL; @@ -287,6 +291,24 @@ gui_window_get_context_at_xy (struct t_gui_window *window, free (str_temp); } } + if (line_start) + { + str_temp = string_strndup (line_start, ptr_data - line_start); + if (str_temp) + { + *focused_line_beginning = gui_color_decode (str_temp, NULL); + free (str_temp); + } + } + if (line_end) + { + str_temp = string_strndup (ptr_data, line_end - ptr_data); + if (str_temp) + { + *focused_line_end = gui_color_decode (str_temp, NULL); + free (str_temp); + } + } } } } diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h index 3ef0700cd..6e1b2eb76 100644 --- a/src/gui/gui-window.h +++ b/src/gui/gui-window.h @@ -139,6 +139,8 @@ extern void gui_window_get_context_at_xy (struct t_gui_window *window, int *line_x, char **word, char **focused_line, + char **focused_line_beginning, + char **focused_line_end, char **beginning, char **end); extern void gui_window_ask_refresh (int refresh); |