summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/fset/fset-buffer.c31
-rw-r--r--src/plugins/fset/fset-command.c12
-rw-r--r--src/plugins/fset/fset-option.c13
-rw-r--r--src/plugins/fset/fset-option.h2
4 files changed, 39 insertions, 19 deletions
diff --git a/src/plugins/fset/fset-buffer.c b/src/plugins/fset/fset-buffer.c
index ede8239c4..3fd7966ba 100644
--- a/src/plugins/fset/fset-buffer.c
+++ b/src/plugins/fset/fset-buffer.c
@@ -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" },
diff --git a/src/plugins/fset/fset-command.c b/src/plugins/fset/fset-command.c
index f1e649252..6526065c9 100644
--- a/src/plugins/fset/fset-command.c
+++ b/src/plugins/fset/fset-command.c
@@ -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"
diff --git a/src/plugins/fset/fset-option.c b/src/plugins/fset/fset-option.c
index 8bfd20a96..5aecde6e8 100644
--- a/src/plugins/fset/fset-option.c
+++ b/src/plugins/fset/fset-option.c
@@ -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);
}
diff --git a/src/plugins/fset/fset-option.h b/src/plugins/fset/fset-option.h
index ff239f056..d1e3a35c5 100644
--- a/src/plugins/fset/fset-option.h
+++ b/src/plugins/fset/fset-option.h
@@ -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,