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 /src/gui | |
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
Diffstat (limited to 'src/gui')
-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 |
3 files changed, 26 insertions, 0 deletions
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); |