diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-01-13 17:03:40 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-01-13 17:03:40 +0100 |
commit | 0e6b33b5bea34ecb89e579ced947b87863466cf6 (patch) | |
tree | a6ede11ca22c9cf78d40fbbb9b7d5830e7cb51cd | |
parent | b8a42996c106567765896335bec664ecf0d95321 (diff) | |
download | weechat-0e6b33b5bea34ecb89e579ced947b87863466cf6.zip |
Add keyword "input_pos" to get/set cursor position in plugin API functions buffer_get_integer and buffer_set
-rw-r--r-- | doc/en/weechat_plugin_api.en.txt | 6 | ||||
-rw-r--r-- | doc/fr/weechat_plugin_api.fr.txt | 6 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 9 | ||||
-rw-r--r-- | src/gui/gui-input.c | 16 | ||||
-rw-r--r-- | src/gui/gui-input.h | 1 |
5 files changed, 36 insertions, 2 deletions
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index e31f2943f..173c9ddcf 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -6291,7 +6291,7 @@ def my_input_cb(data, buffer, input_data): return weechat.WEECHAT_RC_OK def my_close_cb(data, buffer): - weechat.prnt("", "Buffer '%s' will be closed!" % weechat.buffer_get_strinf(buffer, "name")) + weechat.prnt("", "Buffer '%s' will be closed!" % weechat.buffer_get_string(buffer, "name")) return weechat.WEECHAT_RC_OK buffer = weechat.buffer_new("my_buffer", "my_input_cb", "", "my_close_cb", "") @@ -6598,6 +6598,7 @@ Arguments: *** 2: forward search (direction: newest messages) ** 'text_search_exact': 1 if text search is case sensitive ** 'text_search_found': 1 if text found, otherwise 0 +** 'input_pos': cursor position in buffer input Return value: @@ -6804,6 +6805,9 @@ Arguments: | input | any string | set new value for buffer input +| input_pos | position | + set cursor position in buffer input + | input_get_unknown_commands | "0" or "1" | "0" to disable unknown commands on this buffer (default behaviour), "1" to get unknown commands, for example if user type "/unknowncmd", buffer will diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 353835db0..df6d92ecf 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -6382,7 +6382,7 @@ def my_input_cb(data, buffer, input_data): return weechat.WEECHAT_RC_OK def my_close_cb(data, buffer): - weechat.prnt("", "Le tampon '%s' va être fermé !" % weechat.buffer_get_strinf(buffer, "name")) + weechat.prnt("", "Le tampon '%s' va être fermé !" % weechat.buffer_get_string(buffer, "name")) return weechat.WEECHAT_RC_OK buffer = weechat.buffer_new("mon_buffer", "my_input_cb", "", "my_close_cb", "") @@ -6690,6 +6690,7 @@ Paramètres : *** 2 : recherche avant (vers les messages les plus récents) ** 'text_search_exact' : 1 si la recherche de texte est sensible à la casse ** 'text_search_found' : 1 si du texte a été trouvé, sinon 0 +** 'input_pos': position du curseur dans la zone de saisie Valeur de retour : @@ -6902,6 +6903,9 @@ Paramètres : | input | toute chaîne | change le contenu de la zone de saisie +| input_pos | position | + change la position du curseur dans la zone de saisie + | input_get_unknown_commands | "0" ou "1" | "0" pour désactiver les commandes inconnues sur ce tampon (comportement par défaut), "1" pour recevoir les commandes inconnues, par exemple si diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 5c5f6ac9a..b3e82e5d3 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -664,6 +664,8 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property) return buffer->text_search_exact; else if (string_strcasecmp (property, "text_search_found") == 0) return buffer->text_search_found; + else if (string_strcasecmp (property, "input_pos") == 0) + return buffer->input_buffer_pos; } return 0; @@ -1073,6 +1075,13 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property, gui_input_insert_string (buffer, value, 0); gui_input_text_changed_modifier_and_signal (buffer); } + else if (string_strcasecmp (property, "input_pos") == 0) + { + error = NULL; + number = strtol (value, &error, 10); + if (error && !error[0]) + gui_input_set_pos (buffer, number); + } else if (string_strcasecmp (property, "input_get_unknown_commands") == 0) { error = NULL; diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index aef4a6a2c..e184a2e14 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -173,6 +173,22 @@ gui_input_move (struct t_gui_buffer *buffer, char *target, const char *source, } /* + * gui_input_set_pos: set position in input line + */ + +void +gui_input_set_pos (struct t_gui_buffer *buffer, int pos) +{ + if ((pos >= 0) && (buffer->input_buffer_pos != pos)) + { + buffer->input_buffer_pos = pos; + if (buffer->input_buffer_pos > buffer->input_buffer_length) + buffer->input_buffer_pos = buffer->input_buffer_length; + gui_input_text_cursor_moved_signal (); + } +} + +/* * gui_input_insert_string: insert a string into the input buffer * if pos == -1, string is inserted at cursor position * return: number of chars inserted diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h index 20314a912..9586b04ee 100644 --- a/src/gui/gui-input.h +++ b/src/gui/gui-input.h @@ -33,6 +33,7 @@ extern void gui_input_paste_pending_signal (); extern void gui_input_text_changed_modifier_and_signal (struct t_gui_buffer *buffer); extern void gui_input_move (struct t_gui_buffer *buffer, char *target, const char *source, int size); +extern void gui_input_set_pos (struct t_gui_buffer *buffer, int pos); extern int gui_input_insert_string (struct t_gui_buffer *buffer, const char *string, int pos); extern void gui_input_clipboard_paste (struct t_gui_buffer *buffer); |