fset: add alt-v and input "v" to toggle help bar, rename option fset.look.help_bar to fset.look.show_help_bar

This commit is contained in:
Sébastien Helleu 2017-06-02 22:28:36 +02:00
parent bb5523d912
commit feace6be0b
6 changed files with 78 additions and 64 deletions

View File

@ -41,7 +41,7 @@ struct t_gui_bar_item *fset_bar_item_fset = NULL;
void
fset_bar_item_update ()
{
if (weechat_config_boolean (fset_config_look_help_bar))
if (weechat_config_boolean (fset_config_look_show_help_bar))
weechat_bar_item_update (FSET_BAR_ITEM_NAME);
}

View File

@ -721,15 +721,16 @@ fset_buffer_input_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
const char *input_data)
{
char *actions[][2] = { { "t", "toggle" },
{ "-", "add -1" },
{ "+", "add 1" },
{ "r", "reset" },
{ "u", "unset" },
{ "s", "set" },
{ "a", "append" },
{ ",", "mark 1" },
{ NULL, NULL } };
char *actions[][2] = { { "t", "toggle" },
{ "-", "add -1" },
{ "+", "add 1" },
{ "r", "reset" },
{ "u", "unset" },
{ "s", "set" },
{ "a", "append" },
{ ",", "mark 1" },
{ "v", "toggle_bar" },
{ NULL, NULL } };
char str_command[64];
const char *ptr_input;
int i;
@ -843,20 +844,21 @@ fset_buffer_set_callbacks ()
void
fset_buffer_set_keys ()
{
char *keys[][2] = { { "meta-meta2-1~", "go 0" },
{ "meta-meta2-4~", "go end" },
{ "meta- ", "toggle" },
{ "meta--", "add -1" },
{ "meta-+", "add 1" },
{ "meta-fmeta-r", "reset" },
{ "meta-fmeta-u", "unset" },
{ "meta-ctrl-J", "set" },
{ "meta-ctrl-M", "set" },
{ "meta-fmeta-a", "append" },
{ "meta-,", "mark 1" },
{ "meta2-a", "mark -1" },
{ "meta2-b", "mark 1" },
{ NULL, NULL } };
char *keys[][2] = { { "meta-meta2-1~", "go 0" },
{ "meta-meta2-4~", "go end" },
{ "meta- ", "toggle" },
{ "meta--", "add -1" },
{ "meta-+", "add 1" },
{ "meta-fmeta-r", "reset" },
{ "meta-fmeta-u", "unset" },
{ "meta-ctrl-J", "set" },
{ "meta-ctrl-M", "set" },
{ "meta-fmeta-a", "append" },
{ "meta-,", "mark 1" },
{ "meta2-a", "mark -1" },
{ "meta2-b", "mark 1" },
{ "meta-v", "toggle_bar" },
{ NULL, NULL } };
char str_key[64], str_command[64];
int i;

View File

@ -112,6 +112,12 @@ fset_command_fset (const void *pointer, void *data,
return WEECHAT_RC_OK;
}
if (weechat_strcasecmp (argv[1], "-toggle_bar") == 0)
{
weechat_config_option_set (fset_config_look_show_help_bar, "toggle", 1);
return WEECHAT_RC_OK;
}
if (weechat_strcasecmp (argv[1], "-refresh") == 0)
{
fset_bar_item_update ();
@ -461,6 +467,7 @@ fset_command_init ()
"fset",
N_("fast set WeeChat and plugins options"),
N_("-bar"
" || -toggle_bar"
" || -refresh"
" || -up|-down [<number>]"
" || -go <line>|end"
@ -472,39 +479,43 @@ fset_command_init ()
" || -append"
" || -mark [<number>]"
" || filter"),
N_(" -bar: add the fset bar\n"
"-refresh: force the refresh of the \"fset\" bar item\n"
" -up: move the selected line up by \"number\" lines\n"
" -down: move the selected line down by \"number\" lines\n"
" -go: select a line by number, first line number is 0 "
N_(" -bar: add the help bar\n"
"-toggle_bar: toggle the help bar\n"
" -refresh: force the refresh of the \"fset\" bar item\n"
" -up: move the selected line up by \"number\" lines\n"
" -down: move the selected line down by \"number\" lines\n"
" -go: select a line by number, first line number is 0 "
"(\"end\" to select the last line)\n"
" -toggle: toggle the boolean value\n"
" -add: add \"value\", which can be a negative number "
" -toggle: toggle the boolean value\n"
" -add: add \"value\", which can be a negative number "
"(only for integers and colors)\n"
" -reset: reset the value of option\n"
" -unset: unset the option\n"
" -set: add the /set command in input to edit the value of "
" -reset: reset the value of option\n"
" -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"
" -append: add the /set command to append something in the value "
" -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 on the option and move \"number\" lines "
" -mark: toggle mark on the option and move \"number\" lines "
"(up/down, default is 1: one line down)\n"
" filter: set a new filter to see only matching options (this "
" filter: set a new filter to see only matching options (this "
"filter can be used as input in fset buffer as well); allowed "
"formats are:\n"
" * show all options (no filter)\n"
" f:xxx show only configuration file \"xxx\"\n"
" t:xxx show only type \"xxx\" (beginning of type "
" * show all options (no filter)\n"
" f:xxx show only configuration file \"xxx\"\n"
" t:xxx show only type \"xxx\" (beginning of type "
"name is allowed, both English and translated types are allowed)\n"
" d show only changed options\n"
" d:xxx show only changed options with \"xxx\" in name\n"
" d=xxx show only changed options with \"xxx\" in value\n"
" d==xxx show only changed options with exact value \"xxx\"\n"
" =xxx show only options with \"xxx\" in value\n"
" ==xxx show only options with exact value \"xxx\"\n"
" s:x,y sort options by fields x,y "
" d show only changed options\n"
" d:xxx show only changed options with \"xxx\" in "
"name\n"
" d=xxx show only changed options with \"xxx\" in "
"value\n"
" d==xxx show only changed options with exact value "
"\"xxx\"\n"
" =xxx show only options with \"xxx\" in value\n"
" ==xxx show only options with exact value \"xxx\"\n"
" s:x,y sort options by fields x,y "
"(see /help fset.look.sort)\n"
" s: reset sort to its default value "
" s: reset sort to its default value "
"(see /help fset.look.sort)\n"
"\n"
"The lines with options are displayed using string evaluation "
@ -553,6 +564,7 @@ fset_command_init ()
" shift+up mark/unmark option and move one line up\n"
" $ refresh options (keep marked options)\n"
" $$ refresh options (unmark all options)\n"
" v toggle help bar\n"
" q close fset buffer\n"
"\n"
"Note: spaces at beginning of input are ignored, so for example "

View File

@ -36,8 +36,8 @@ struct t_config_file *fset_config_file = NULL;
struct t_config_option *fset_config_look_auto_unmark;
struct t_config_option *fset_config_look_condition_catch_set;
struct t_config_option *fset_config_look_help_bar;
struct t_config_option *fset_config_look_marked_string;
struct t_config_option *fset_config_look_show_help_bar;
struct t_config_option *fset_config_look_show_plugin_description;
struct t_config_option *fset_config_look_sort;
struct t_config_option *fset_config_look_unmarked_string;
@ -81,12 +81,12 @@ char *fset_config_eval_format_option_current = NULL;
/*
* Callback for changes on option "fset.look.help_bar".
* Callback for changes on option "fset.look.show_help_bar".
*/
void
fset_config_change_help_bar_cb (const void *pointer, void *data,
struct t_config_option *option)
fset_config_change_show_help_bar_cb (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) pointer;
@ -283,15 +283,6 @@ fset_config_init ()
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
fset_config_look_help_bar = weechat_config_new_option (
fset_config_file, ptr_section,
"help_bar", "boolean",
N_("display help bar in fset buffer (description of option, "
"allowed values and default value)"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL,
&fset_config_change_help_bar_cb, NULL, NULL,
NULL, NULL, NULL);
fset_config_look_marked_string = weechat_config_new_option (
fset_config_file, ptr_section,
"marked_string", "string",
@ -301,6 +292,15 @@ fset_config_init ()
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
fset_config_look_show_help_bar = weechat_config_new_option (
fset_config_file, ptr_section,
"show_help_bar", "boolean",
N_("display help bar in fset buffer (description of option, "
"allowed values and default value)"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL,
&fset_config_change_show_help_bar_cb, NULL, NULL,
NULL, NULL, NULL);
fset_config_look_show_plugin_description = weechat_config_new_option (
fset_config_file, ptr_section,
"show_plugin_description", "boolean",

View File

@ -26,8 +26,8 @@ extern struct t_config_file *fset_config_file;
extern struct t_config_option *fset_config_look_auto_unmark;
extern struct t_config_option *fset_config_look_condition_catch_set;
extern struct t_config_option *fset_config_look_help_bar;
extern struct t_config_option *fset_config_look_marked_string;
extern struct t_config_option *fset_config_look_show_help_bar;
extern struct t_config_option *fset_config_look_show_plugin_description;
extern struct t_config_option *fset_config_look_sort;
extern struct t_config_option *fset_config_look_unmarked_string;

View File

@ -58,7 +58,7 @@ fset_add_bar ()
{
weechat_bar_new (
FSET_BAR_NAME, "off", "0", "window",
"${fset.look.help_bar} "
"${fset.look.show_help_bar} "
"&& ${buffer.full_name} == " FSET_PLUGIN_NAME "." FSET_BAR_NAME,
"top", "horizontal", "vertical", "3", "3",
"default", "cyan", "default", "on",
@ -98,7 +98,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
fset_command_init ();
if (weechat_config_boolean (fset_config_look_help_bar))
if (weechat_config_boolean (fset_config_look_show_help_bar))
fset_add_bar ();
fset_bar_item_update ();