1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 17:23:15 +02:00

fset: add key/input to set new value for an option (alt-f,alt-n or input "n", command /fset -setnew)

This commit is contained in:
Sébastien Helleu
2017-06-21 20:49:36 +02:00
parent d2a9d839a1
commit 0f8db0fa2e
4 changed files with 39 additions and 19 deletions
+17 -14
View File
@@ -73,6 +73,7 @@ fset_buffer_set_title ()
"alt+f,alt+r(r)=reset, "
"alf+f,alt+u(u)=unset, "
"alt+enter(s)=set, "
"alt+f,alt+n(n)=set new value, "
"alt+f,alt+a(a)=append, "
"alt+','=mark/unmark, "
"shift+down=mark and move down, "
@@ -952,22 +953,23 @@ fset_buffer_input_cb (const void *pointer, void *data,
const char *input_data)
{
char *actions[][2] = {
{ "<<", "/fset -go 0" },
{ ">>", "/fset -go end" },
{ "<", "/fset -left" },
{ ">", "/fset -right" },
{ "t", "/fset -toggle" },
{ "-", "/fset -add -1" },
{ "+", "/fset -add 1" },
{ "r", "/fset -reset" },
{ "u", "/fset -unset" },
{ "s", "/fset -set" },
{ "a", "/fset -append" },
{ ",", "/fset -mark 1" },
{ "<<", "/fset -go 0" },
{ ">>", "/fset -go end" },
{ "<", "/fset -left" },
{ ">", "/fset -right" },
{ "t", "/fset -toggle" },
{ "-", "/fset -add -1" },
{ "+", "/fset -add 1" },
{ "r", "/fset -reset" },
{ "u", "/fset -unset" },
{ "s", "/fset -set" },
{ "n", "/fset -setnew" },
{ "a", "/fset -append" },
{ ",", "/fset -mark 1" },
{ "p", "/mute /set fset.look.show_plugins_desc toggle", },
{ "v", "/mute /set fset.look.show_help_bar toggle" },
{ "x", "/fset -format" },
{ NULL, NULL },
{ "x", "/fset -format" },
{ NULL, NULL },
};
const char *ptr_input;
int i;
@@ -1135,6 +1137,7 @@ fset_buffer_set_keys ()
{ "meta-fmeta-u", "/fset -unset" },
{ "meta-ctrl-J", "/fset -set" },
{ "meta-ctrl-M", "/fset -set" },
{ "meta-fmeta-n", "/fset -setnew" },
{ "meta-fmeta-a", "/fset -append" },
{ "meta-,", "/fset -mark" },
{ "meta2-a", "/fset -up; /fset -mark" },
+12
View File
@@ -358,6 +358,13 @@ fset_command_fset (const void *pointer, void *data,
return WEECHAT_RC_OK;
}
if (weechat_strcasecmp (argv[1], "-setnew") == 0)
{
fset_command_get_option (&ptr_fset_option, &ptr_option);
fset_option_set (ptr_fset_option, ptr_option, buffer, -1);
return WEECHAT_RC_OK;
}
if (weechat_strcasecmp (argv[1], "-append") == 0)
{
fset_command_get_option (&ptr_fset_option, &ptr_option);
@@ -587,6 +594,7 @@ fset_command_init ()
" || -reset"
" || -unset"
" || -set"
" || -setnew"
" || -append"
" || -mark"
" || -format"
@@ -610,6 +618,8 @@ fset_command_init ()
" -unset: unset the option\n"
" -set: add the /set command in input to edit the value of "
"option (move the cursor at the beginning of value)\n"
" -setnew: add the /set command in input to edit a new value "
"for the option\n"
" -append: add the /set command to append something in the value "
"of option (move the cursor at the end of value)\n"
" -mark: toggle mark\n"
@@ -719,6 +729,7 @@ fset_command_init ()
" alt+f, alt+r r reset value\n"
" alt+f, alt+u u unset value\n"
" alt+enter s set value\n"
" alt+f, alt+n n set new value\n"
" alt+f, alt+a a append to value\n"
" alt+',' , mark/unmark option\n"
" shift+up move one line up and mark/unmark option\n"
@@ -784,6 +795,7 @@ fset_command_init ()
" || -reset"
" || -unset"
" || -set"
" || -setnew"
" || -append"
" || -mark"
" || -format"
+9 -4
View File
@@ -1136,13 +1136,18 @@ fset_option_unset_value (struct t_fset_option *fset_option,
/*
* Sets the value of an option.
*
* If set_mode == -1, edit an empty value.
* If set_mode == 0, edit the current value.
* If set_mode == 1, append to the current value (move the cursor at the end of
* value)
*/
void
fset_option_set (struct t_fset_option *fset_option,
struct t_config_option *option,
struct t_gui_buffer *buffer,
int append)
int set_mode)
{
int use_mute, add_quotes, input_pos;
char str_input[4096], str_pos[32];
@@ -1160,15 +1165,15 @@ fset_option_set (struct t_fset_option *fset_option,
(use_mute) ? "/mute " : "",
fset_option->name,
(add_quotes) ? "\"" : "",
(fset_option->value) ? fset_option->value : "",
(set_mode != -1) ? ((fset_option->value) ? fset_option->value : "") : "",
(add_quotes) ? "\"" : "");
weechat_buffer_set (buffer, "input", str_input);
input_pos = ((use_mute) ? 6 : 0) + /* "/mute " */
5 + /* "/set " */
weechat_utf8_strlen (fset_option->name) + 1 +
((add_quotes) ? 1 : 0) +
((append) ? ((fset_option->value) ?
weechat_utf8_strlen (fset_option->value) : 0) : 0);
((set_mode == 1) ? ((fset_option->value) ?
weechat_utf8_strlen (fset_option->value) : 0) : 0);
snprintf (str_pos, sizeof (str_pos), "%d", input_pos);
weechat_buffer_set (buffer, "input_pos", str_pos);
}
+1 -1
View File
@@ -83,7 +83,7 @@ extern void fset_option_unset_value (struct t_fset_option *fset_option,
extern void fset_option_set (struct t_fset_option *fset_option,
struct t_config_option *option,
struct t_gui_buffer *buffer,
int append);
int set_mode);
extern void fset_option_toggle_mark (struct t_fset_option *fset_option,
struct t_config_option *option);
extern void fset_option_mark_options_matching_filter (const char *filter,