Add keyword "input_pos" to get/set cursor position in plugin API functions buffer_get_integer and buffer_set
parent
b8a42996c1
commit
0e6b33b5be
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -172,6 +172,22 @@ gui_input_move (struct t_gui_buffer *buffer, char *target, const char *source,
|
|||
memmove (target, source, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue