mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 17:23:15 +02:00
- new keyboard management: keys are setup in config file, new command /key was added and some new default keys were added
- added seconds in infobar time (optional with new config flag) - fixed some curses refreshs
This commit is contained in:
+206
-47
@@ -47,11 +47,11 @@ t_weechat_command weechat_commands[] =
|
||||
{ "buffer", N_("manage buffers"),
|
||||
N_("[action | number]"),
|
||||
N_("action: action to do:\n"
|
||||
" move: move buffer in the list (may be relative, for example -1)\n"
|
||||
" close: close buffer (for channel: same as /part without part message)\n"
|
||||
" list: list opened buffers (no parameter implies this list)\n"
|
||||
" notify: set notify level for buffer (0=never, 1=highlight, 2=1+msg, 3=2+join/part)\n"
|
||||
"number: jump to buffer by number"),
|
||||
" move: move buffer in the list (may be relative, for example -1)\n"
|
||||
" close: close buffer (for channel: same as /part without part message)\n"
|
||||
" list: list opened buffers (no parameter implies this list)\n"
|
||||
" notify: set notify level for buffer (0=never, 1=highlight, 2=1+msg, 3=2+join/part)\n"
|
||||
"number: jump to buffer by number"),
|
||||
0, MAX_ARGS, weechat_cmd_buffer, NULL },
|
||||
{ "clear", N_("clear window(s)"),
|
||||
N_("[-all]"),
|
||||
@@ -72,33 +72,40 @@ t_weechat_command weechat_commands[] =
|
||||
{ "help", N_("display help about commands"),
|
||||
N_("[command]"), N_("command: name of a WeeChat or IRC command"),
|
||||
0, 1, weechat_cmd_help, NULL },
|
||||
{ "key", N_("bind/unbind keys"),
|
||||
N_("[key function/command] [unbind key] [functions] [reset -yes]"),
|
||||
N_("key: bind this key to an internal function or a command (beginning by \"/\")\n"
|
||||
"unbind: unbind a key (if \"all\", default bindings are restored)\n"
|
||||
"functions: list internal functions for key bindings\n"
|
||||
"reset: restore bindings to the default values and delete ALL personal binding (use carefully!)"),
|
||||
0, MAX_ARGS, NULL, weechat_cmd_key },
|
||||
{ "perl", N_("list/load/unload Perl scripts"),
|
||||
N_("[load filename] | [autoload] | [reload] | [unload]"),
|
||||
N_("filename: Perl script (file) to load\n"
|
||||
"Without argument, /perl command lists all loaded Perl scripts."),
|
||||
"Without argument, /perl command lists all loaded Perl scripts."),
|
||||
0, 2, weechat_cmd_perl, NULL },
|
||||
{ "python", N_("list/load/unload Python scripts"),
|
||||
N_("[load filename] | [autoload] | [reload] | [unload]"),
|
||||
N_("filename: Python script (file) to load\n"
|
||||
"Without argument, /python command lists all loaded Python scripts."),
|
||||
"Without argument, /python command lists all loaded Python scripts."),
|
||||
0, 2, weechat_cmd_python, NULL },
|
||||
{ "server", N_("list, add or remove servers"),
|
||||
N_("[servername] | "
|
||||
"[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 "
|
||||
"[nick2 [nick3]]] [-username username] [-realname realname] "
|
||||
"[-command command] [-autojoin channel[,channel]] ] | "
|
||||
"[del servername]"),
|
||||
"[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 "
|
||||
"[nick2 [nick3]]] [-username username] [-realname realname] "
|
||||
"[-command command] [-autojoin channel[,channel]] ] | "
|
||||
"[del servername]"),
|
||||
N_("servername: server name, for internal & display use\n"
|
||||
"hostname: name or IP address of server\n"
|
||||
"port: port for server (integer)\n"
|
||||
"ipv6: use IPv6 protocol\n"
|
||||
"ssl: use SSL protocol\n"
|
||||
"password: password for server\n"
|
||||
"nick1: first nick for server\n"
|
||||
"nick2: alternate nick for server\n"
|
||||
"nick3: second alternate nick for server\n"
|
||||
"username: user name\n"
|
||||
"realname: real name of user"),
|
||||
"hostname: name or IP address of server\n"
|
||||
"port: port for server (integer)\n"
|
||||
"ipv6: use IPv6 protocol\n"
|
||||
"ssl: use SSL protocol\n"
|
||||
"password: password for server\n"
|
||||
"nick1: first nick for server\n"
|
||||
"nick2: alternate nick for server\n"
|
||||
"nick3: second alternate nick for server\n"
|
||||
"username: user name\n"
|
||||
"realname: real name of user"),
|
||||
0, MAX_ARGS, weechat_cmd_server, NULL },
|
||||
{ "save", N_("save config to disk"),
|
||||
N_("[file]"), N_("file: filename for writing config"),
|
||||
@@ -111,11 +118,10 @@ t_weechat_command weechat_commands[] =
|
||||
1, 1, NULL, weechat_cmd_unalias },
|
||||
{ "window", N_("manage windows"),
|
||||
N_("[list | splith | splitv | [merge [down | up | left | right | all]]]"),
|
||||
N_(
|
||||
"list: list opened windows (no parameter implies this list)\n"
|
||||
"splith: split current window horizontally\n"
|
||||
"splitv: split current window vertically\n"
|
||||
"merge: merge window with another"),
|
||||
N_("list: list opened windows (no parameter implies this list)\n"
|
||||
"splith: split current window horizontally\n"
|
||||
"splitv: split current window vertically\n"
|
||||
"merge: merge window with another"),
|
||||
0, 2, weechat_cmd_window, NULL },
|
||||
{ NULL, NULL, NULL, NULL, 0, 0, NULL, NULL }
|
||||
};
|
||||
@@ -877,6 +883,7 @@ weechat_cmd_buffer (int argc, char **argv)
|
||||
t_irc_channel *ptr_channel;
|
||||
long number;
|
||||
char *error;
|
||||
int target_buffer;
|
||||
|
||||
if ((argc == 0) || ((argc == 1) && (strcasecmp (argv[0], "list") == 0)))
|
||||
{
|
||||
@@ -1049,26 +1056,41 @@ weechat_cmd_buffer (int argc, char **argv)
|
||||
{
|
||||
/* jump to buffer by number */
|
||||
|
||||
error = NULL;
|
||||
number = strtol (argv[0], &error, 10);
|
||||
if ((error) && (error[0] == '\0'))
|
||||
if (argv[0][0] == '-')
|
||||
{
|
||||
if (!gui_switch_to_buffer_by_number (gui_current_window, (int) number))
|
||||
/* relative jump '-' */
|
||||
error = NULL;
|
||||
number = strtol (argv[0] + 1, &error, 10);
|
||||
if ((error) && (error[0] == '\0'))
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s buffer \"%s\" not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, argv[0], "buffer");
|
||||
return -1;
|
||||
target_buffer = gui_current_window->buffer->number - (int) number;
|
||||
if (target_buffer < 1)
|
||||
target_buffer = (last_gui_buffer) ? last_gui_buffer->number + target_buffer : 1;
|
||||
gui_switch_to_buffer_by_number (gui_current_window,
|
||||
target_buffer);
|
||||
}
|
||||
}
|
||||
else if (argv[0][0] == '+')
|
||||
{
|
||||
/* relative jump '+' */
|
||||
error = NULL;
|
||||
number = strtol (argv[0] + 1, &error, 10);
|
||||
if ((error) && (error[0] == '\0'))
|
||||
{
|
||||
target_buffer = gui_current_window->buffer->number + (int) number;
|
||||
if (last_gui_buffer && target_buffer > last_gui_buffer->number)
|
||||
target_buffer -= last_gui_buffer->number;
|
||||
gui_switch_to_buffer_by_number (gui_current_window,
|
||||
target_buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid number */
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL, _("%s incorrect buffer number\n"),
|
||||
WEECHAT_ERROR);
|
||||
return -1;
|
||||
/* absolute jump by number */
|
||||
error = NULL;
|
||||
number = strtol (argv[0], &error, 10);
|
||||
if ((error) && (error[0] == '\0'))
|
||||
gui_switch_to_buffer_by_number (gui_current_window, (int) number);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1322,6 +1344,138 @@ weechat_cmd_help (int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_key_display: display a key binding
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_cmd_key_display (t_gui_key *key, int new_key)
|
||||
{
|
||||
char *expanded_name;
|
||||
|
||||
expanded_name = gui_key_get_expanded_name (key->key);
|
||||
if (new_key)
|
||||
{
|
||||
gui_printf (NULL, _("New key binding:\n"));
|
||||
gui_printf (NULL, " %s", (expanded_name) ? expanded_name : key->key);
|
||||
}
|
||||
else
|
||||
gui_printf (NULL, " %20s", (expanded_name) ? expanded_name : key->key);
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, " => ");
|
||||
gui_printf (NULL, "%s\n",
|
||||
(key->function) ?
|
||||
gui_key_function_search_by_ptr (key->function) : key->command);
|
||||
if (expanded_name)
|
||||
free (expanded_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_key: bind/unbind keys
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_key (char *arguments)
|
||||
{
|
||||
char *pos;
|
||||
int i;
|
||||
t_gui_key *ptr_key;
|
||||
|
||||
if (arguments)
|
||||
{
|
||||
while (arguments[0] == ' ')
|
||||
arguments++;
|
||||
}
|
||||
|
||||
if (!arguments || (arguments[0] == '\0'))
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
gui_printf (NULL, _("Key bindings:\n"));
|
||||
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
weechat_cmd_key_display (ptr_key, 0);
|
||||
}
|
||||
}
|
||||
else if (strncasecmp (arguments, "unbind ", 7) == 0)
|
||||
{
|
||||
arguments += 7;
|
||||
while (arguments[0] == ' ')
|
||||
arguments++;
|
||||
if (gui_key_unbind (arguments))
|
||||
gui_printf (NULL, _("Key \"%s\" unbinded\n"), arguments);
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s unable to unbind key \"%s\"\n"),
|
||||
WEECHAT_ERROR, arguments);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (strcasecmp (arguments, "functions") == 0)
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
gui_printf (NULL, _("Internal key functions:\n"));
|
||||
i = 0;
|
||||
while (gui_key_functions[i].function_name)
|
||||
{
|
||||
gui_printf (NULL, " %s\n",
|
||||
gui_key_functions[i].function_name);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else if (strncasecmp (arguments, "reset", 5) == 0)
|
||||
{
|
||||
arguments += 5;
|
||||
while (arguments[0] == ' ')
|
||||
arguments++;
|
||||
if (strcmp (arguments, "-yes") == 0)
|
||||
{
|
||||
gui_key_free_all ();
|
||||
gui_key_init ();
|
||||
gui_printf (NULL, _("Default key bindings restored\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s \"-yes\" argument is required for keys reset (securuty reason)\n"),
|
||||
WEECHAT_ERROR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (arguments[0] == ' ')
|
||||
arguments++;
|
||||
pos = strchr (arguments, ' ');
|
||||
if (!pos)
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "key");
|
||||
return -1;
|
||||
}
|
||||
pos[0] = '\0';
|
||||
pos++;
|
||||
while (pos[0] == ' ')
|
||||
pos++;
|
||||
ptr_key = gui_key_bind (arguments, pos);
|
||||
if (ptr_key)
|
||||
weechat_cmd_key_display (ptr_key, 1);
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s unable to bind key \"%s\"\n"),
|
||||
WEECHAT_ERROR, arguments);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_perl: list/load/unload Perl scripts
|
||||
*/
|
||||
@@ -1892,11 +2046,11 @@ weechat_cmd_server (int argc, char **argv)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_set_cmd_display_option: display config option
|
||||
* weechat_cmd_set_display_option: display config option
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_set_cmd_display_option (t_config_option *option, char *prefix, void *value)
|
||||
weechat_cmd_set_display_option (t_config_option *option, char *prefix, void *value)
|
||||
{
|
||||
char *color_name, *pos_nickserv, *pos_pwd, *value2;
|
||||
|
||||
@@ -2039,7 +2193,7 @@ weechat_cmd_set (char *arguments)
|
||||
{
|
||||
ptr_option_value = config_get_server_option_ptr (ptr_server,
|
||||
weechat_options[CONFIG_SECTION_SERVER][i].option_name);
|
||||
weechat_set_cmd_display_option (&weechat_options[CONFIG_SECTION_SERVER][i],
|
||||
weechat_cmd_set_display_option (&weechat_options[CONFIG_SECTION_SERVER][i],
|
||||
ptr_server->name,
|
||||
ptr_option_value);
|
||||
}
|
||||
@@ -2080,7 +2234,7 @@ weechat_cmd_set (char *arguments)
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL,
|
||||
"%s", config_get_section (ptr_option));
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "]\n");
|
||||
weechat_set_cmd_display_option (ptr_option, NULL, NULL);
|
||||
weechat_cmd_set_display_option (ptr_option, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2104,7 +2258,8 @@ weechat_cmd_set (char *arguments)
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
section_displayed = 0;
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -2122,7 +2277,7 @@ weechat_cmd_set (char *arguments)
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "]\n");
|
||||
section_displayed = 1;
|
||||
}
|
||||
weechat_set_cmd_display_option (&weechat_options[i][j], NULL, NULL);
|
||||
weechat_cmd_set_display_option (&weechat_options[i][j], NULL, NULL);
|
||||
number_found++;
|
||||
}
|
||||
}
|
||||
@@ -2155,7 +2310,7 @@ weechat_cmd_set (char *arguments)
|
||||
weechat_options[CONFIG_SECTION_SERVER][i].option_name);
|
||||
if (ptr_option_value)
|
||||
{
|
||||
weechat_set_cmd_display_option (&weechat_options[CONFIG_SECTION_SERVER][i],
|
||||
weechat_cmd_set_display_option (&weechat_options[CONFIG_SECTION_SERVER][i],
|
||||
ptr_server->name,
|
||||
ptr_option_value);
|
||||
number_found++;
|
||||
@@ -2288,6 +2443,10 @@ weechat_cmd_window (int argc, char **argv)
|
||||
else
|
||||
gui_window_merge_auto (gui_current_window);
|
||||
}
|
||||
else if (strcasecmp (argv[0], "-1") == 0)
|
||||
gui_switch_to_previous_window ();
|
||||
else if (strcasecmp (argv[0], "+1") == 0)
|
||||
gui_switch_to_next_window ();
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
|
||||
@@ -69,6 +69,7 @@ extern int weechat_cmd_connect (int, char **);
|
||||
extern int weechat_cmd_debug (int, char **);
|
||||
extern int weechat_cmd_disconnect (int, char **);
|
||||
extern int weechat_cmd_help (int, char **);
|
||||
extern int weechat_cmd_key (char *);
|
||||
extern int weechat_cmd_perl (int, char **);
|
||||
extern int weechat_cmd_python (int, char **);
|
||||
extern int weechat_cmd_save (int, char **);
|
||||
|
||||
+19
-1
@@ -201,6 +201,23 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ((strcasecmp (completion->base_command, "key") == 0)
|
||||
&& (completion->base_command_arg == 1))
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"bind");
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"unbind");
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"functions");
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"reset");
|
||||
return;
|
||||
}
|
||||
if (((strcasecmp (completion->base_command, "perl") == 0)
|
||||
|| (strcasecmp (completion->base_command, "python") == 0))
|
||||
&& (completion->base_command_arg == 1))
|
||||
@@ -225,7 +242,8 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
{
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
|
||||
+56
-2
@@ -313,6 +313,47 @@ void wee_display_commands (int weechat_cmd, int irc_cmd)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* wee_display_key_functions: display WeeChat key functions
|
||||
*/
|
||||
|
||||
void wee_display_key_functions ()
|
||||
{
|
||||
int i;
|
||||
|
||||
printf (_("Internal key functions:\n"));
|
||||
printf ("\n");
|
||||
i = 0;
|
||||
while (gui_key_functions[i].function_name)
|
||||
{
|
||||
printf (" %s\n",
|
||||
gui_key_functions[i].function_name);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* wee_display_keys: display WeeChat default keys
|
||||
*/
|
||||
|
||||
void wee_display_keys ()
|
||||
{
|
||||
t_gui_key *ptr_key;
|
||||
char *expanded_name;
|
||||
|
||||
printf (_("%s default keys:\n"), PACKAGE_NAME);
|
||||
printf ("\n");
|
||||
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
expanded_name = gui_key_get_expanded_name (ptr_key->key);
|
||||
printf (" %20s => %s\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
(ptr_key->function) ? gui_key_function_search_by_ptr (ptr_key->function) : ptr_key->command);
|
||||
if (expanded_name)
|
||||
free (expanded_name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* wee_parse_args: parse command line args
|
||||
*/
|
||||
@@ -333,6 +374,12 @@ wee_parse_args (int argc, char *argv[])
|
||||
wee_display_config_options ();
|
||||
wee_shutdown (EXIT_SUCCESS);
|
||||
}
|
||||
else if ((strcmp (argv[i], "-f") == 0)
|
||||
|| (strcmp (argv[i], "--key-functions") == 0))
|
||||
{
|
||||
wee_display_key_functions ();
|
||||
wee_shutdown (EXIT_SUCCESS);
|
||||
}
|
||||
else if ((strcmp (argv[i], "-h") == 0)
|
||||
|| (strcmp (argv[i], "--help") == 0))
|
||||
{
|
||||
@@ -340,12 +387,18 @@ wee_parse_args (int argc, char *argv[])
|
||||
printf ("%s", WEE_USAGE2);
|
||||
wee_shutdown (EXIT_SUCCESS);
|
||||
}
|
||||
if ((strcmp (argv[i], "-i") == 0)
|
||||
else if ((strcmp (argv[i], "-i") == 0)
|
||||
|| (strcmp (argv[i], "--irc-commands") == 0))
|
||||
{
|
||||
wee_display_commands (0, 1);
|
||||
wee_shutdown (EXIT_SUCCESS);
|
||||
}
|
||||
else if ((strcmp (argv[i], "-k") == 0)
|
||||
|| (strcmp (argv[i], "--keys") == 0))
|
||||
{
|
||||
wee_display_keys ();
|
||||
wee_shutdown (EXIT_SUCCESS);
|
||||
}
|
||||
else if ((strcmp (argv[i], "-l") == 0)
|
||||
|| (strcmp (argv[i], "--license") == 0))
|
||||
{
|
||||
@@ -358,7 +411,7 @@ wee_parse_args (int argc, char *argv[])
|
||||
printf (PACKAGE_VERSION "\n");
|
||||
wee_shutdown (EXIT_SUCCESS);
|
||||
}
|
||||
if ((strcmp (argv[i], "-w") == 0)
|
||||
else if ((strcmp (argv[i], "-w") == 0)
|
||||
|| (strcmp (argv[i], "--weechat-commands") == 0))
|
||||
{
|
||||
wee_display_commands (1, 0);
|
||||
@@ -771,6 +824,7 @@ main (int argc, char *argv[])
|
||||
signal (SIGSEGV, my_sigsegv); /* crash dump when SIGSEGV is received */
|
||||
gui_pre_init (&argc, &argv); /* pre-initiliaze interface */
|
||||
wee_init_vars (); /* initialize some variables */
|
||||
gui_key_init (); /* init keyboard (default key bindings) */
|
||||
wee_parse_args (argc, argv); /* parse command line args */
|
||||
wee_create_home_dirs (); /* create WeeChat directories */
|
||||
wee_init_log (); /* init log file */
|
||||
|
||||
@@ -90,8 +90,10 @@
|
||||
|
||||
#define WEE_USAGE2 \
|
||||
" -c, --config display config file options\n" \
|
||||
" -h, --help this help screen\n" \
|
||||
" -f, --key-functions display WeeChat internal functions for keys\n" \
|
||||
" -h, --help this help\n" \
|
||||
" -i, --irc-commands display IRC commands\n" \
|
||||
" -k, --keys display WeeChat default keys\n" \
|
||||
" -l, --license display WeeChat license\n" \
|
||||
" -v, --version display WeeChat version\n" \
|
||||
" -w, --weechat-commands display WeeChat commands\n\n"
|
||||
|
||||
+88
-12
@@ -53,6 +53,7 @@ t_config_section config_sections[CONFIG_NUMBER_SECTIONS] =
|
||||
{ CONFIG_SECTION_IRC, "irc" },
|
||||
{ CONFIG_SECTION_DCC, "dcc" },
|
||||
{ CONFIG_SECTION_PROXY, "proxy" },
|
||||
{ CONFIG_SECTION_KEYS, "keys" },
|
||||
{ CONFIG_SECTION_ALIAS, "alias" },
|
||||
{ CONFIG_SECTION_SERVER, "server" }
|
||||
};
|
||||
@@ -82,6 +83,7 @@ char *cfg_look_no_nickname;
|
||||
char *cfg_look_completor;
|
||||
int cfg_look_infobar;
|
||||
char *cfg_look_infobar_timestamp;
|
||||
int cfg_look_infobar_seconds;
|
||||
int cfg_look_infobar_delay_highlight;
|
||||
|
||||
t_config_option weechat_options_look[] =
|
||||
@@ -170,7 +172,11 @@ t_config_option weechat_options_look[] =
|
||||
{ "look_infobar_timestamp", N_("timestamp for time in infobar"),
|
||||
N_("timestamp for time in infobar"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"%B, %A %d %Y - %H:%M", NULL, NULL, &cfg_look_infobar_timestamp, config_change_buffer_content },
|
||||
"%B, %A %d %Y", NULL, NULL, &cfg_look_infobar_timestamp, config_change_buffer_content },
|
||||
{ "look_infobar_seconds", N_("display seconds in infobar time"),
|
||||
N_("display seconds in infobar time"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_look_infobar_seconds, NULL, config_change_buffer_content },
|
||||
{ "look_infobar_delay_highlight", N_("delay (in seconds) for highlight messages in infobar"),
|
||||
N_("delay (in seconds) for highlight messages in infobar "
|
||||
"(0 = disable highlight notifications in infobar)"),
|
||||
@@ -202,6 +208,7 @@ int cfg_col_status_data_other;
|
||||
int cfg_col_status_more;
|
||||
int cfg_col_status_bg;
|
||||
int cfg_col_infobar;
|
||||
int cfg_col_infobar_delimiters;
|
||||
int cfg_col_infobar_highlight;
|
||||
int cfg_col_infobar_bg;
|
||||
int cfg_col_input;
|
||||
@@ -320,6 +327,10 @@ t_config_option weechat_options_colors[] =
|
||||
N_("color for info bar text"),
|
||||
OPTION_TYPE_COLOR, 0, 0, 0,
|
||||
"black", NULL, &cfg_col_infobar, NULL, &config_change_color },
|
||||
{ "col_infobar_delimiters", N_("color for infobar delimiters"),
|
||||
N_("color for infobar delimiters"),
|
||||
OPTION_TYPE_COLOR, 0, 0, 0,
|
||||
"blue", NULL, &cfg_col_infobar_delimiters, NULL, &config_change_color },
|
||||
{ "col_infobar_highlight", N_("color for info bar highlight notification"),
|
||||
N_("color for info bar highlight notification"),
|
||||
OPTION_TYPE_COLOR, 0, 0, 0,
|
||||
@@ -727,7 +738,7 @@ t_config_option weechat_options_server[] =
|
||||
t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] =
|
||||
{ weechat_options_look, weechat_options_colors, weechat_options_history,
|
||||
weechat_options_log, weechat_options_irc, weechat_options_dcc,
|
||||
weechat_options_proxy, NULL, weechat_options_server
|
||||
weechat_options_proxy, NULL, NULL, weechat_options_server
|
||||
};
|
||||
|
||||
|
||||
@@ -763,7 +774,8 @@ config_get_section (t_config_option *ptr_option)
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -1057,7 +1069,8 @@ config_option_search (char *option_name)
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -1220,7 +1233,8 @@ config_default_values ()
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -1375,8 +1389,22 @@ config_read ()
|
||||
if (pos2 != NULL)
|
||||
pos2[0] = '\0';
|
||||
|
||||
if (section == CONFIG_SECTION_ALIAS)
|
||||
if (section == CONFIG_SECTION_KEYS)
|
||||
{
|
||||
if (pos[0])
|
||||
{
|
||||
/* bind key (overwrite any binding with same key) */
|
||||
gui_key_bind (line, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* unbin key if no value given */
|
||||
gui_key_unbind (line);
|
||||
}
|
||||
}
|
||||
else if (section == CONFIG_SECTION_ALIAS)
|
||||
{
|
||||
/* create new alias */
|
||||
if (alias_new (line, pos))
|
||||
weelist_add (&index_commands, &last_index_command, line);
|
||||
}
|
||||
@@ -1493,6 +1521,8 @@ config_create_default ()
|
||||
time_t current_time;
|
||||
struct passwd *my_passwd;
|
||||
char *realname, *pos;
|
||||
t_gui_key *ptr_key;
|
||||
char *expanded_name, *function_name;
|
||||
|
||||
filename_length = strlen (weechat_home) + 64;
|
||||
filename =
|
||||
@@ -1520,7 +1550,8 @@ config_create_default ()
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
@@ -1550,6 +1581,27 @@ config_create_default ()
|
||||
}
|
||||
}
|
||||
|
||||
/* default key bindings */
|
||||
fprintf (file, "\n[keys]\n");
|
||||
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
expanded_name = gui_key_get_expanded_name (ptr_key->key);
|
||||
if (ptr_key->function)
|
||||
{
|
||||
function_name = gui_key_function_search_by_ptr (ptr_key->function);
|
||||
if (function_name)
|
||||
fprintf (file, "%s=%s\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
function_name);
|
||||
}
|
||||
else
|
||||
fprintf (file, "%s=%s\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
ptr_key->command);
|
||||
if (expanded_name)
|
||||
free (expanded_name);
|
||||
}
|
||||
|
||||
/* default aliases */
|
||||
/* TODO: remove comments when missing commands will be ok */
|
||||
fprintf (file, "\n[alias]\n");
|
||||
@@ -1560,20 +1612,20 @@ config_create_default ()
|
||||
fprintf (file, "C=clear\n");
|
||||
fprintf (file, "CL=clear\n");
|
||||
fprintf (file, "CLOSE=buffer close\n");
|
||||
fprintf (file, "# CHAT=dcc chat\n");
|
||||
fprintf (file, "CHAT=dcc chat\n");
|
||||
fprintf (file, "# GET=dcc get\n");
|
||||
fprintf (file, "# IG=ignore\n");
|
||||
fprintf (file, "J=join\n");
|
||||
fprintf (file, "K=kick\n");
|
||||
fprintf (file, "# KB=kickban\n");
|
||||
fprintf (file, "KB=kickban\n");
|
||||
fprintf (file, "# KN=knockout\n");
|
||||
fprintf (file, "LEAVE=part\n");
|
||||
fprintf (file, "M=msg\n");
|
||||
fprintf (file, "# MUB=unban *\n");
|
||||
fprintf (file, "MUB=unban *\n");
|
||||
fprintf (file, "N=names\n");
|
||||
fprintf (file, "Q=query\n");
|
||||
fprintf (file, "T=topic\n");
|
||||
fprintf (file, "# UB=unban\n");
|
||||
fprintf (file, "UB=unban\n");
|
||||
fprintf (file, "# UNIG=unignore\n");
|
||||
fprintf (file, "W=who\n");
|
||||
fprintf (file, "WC=part\n");
|
||||
@@ -1658,6 +1710,8 @@ config_write (char *config_name)
|
||||
time_t current_time;
|
||||
t_irc_server *ptr_server;
|
||||
t_weechat_alias *ptr_alias;
|
||||
t_gui_key *ptr_key;
|
||||
char *expanded_name, *function_name;
|
||||
|
||||
if (config_name)
|
||||
filename = strdup (config_name);
|
||||
@@ -1690,7 +1744,8 @@ config_write (char *config_name)
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
@@ -1737,6 +1792,27 @@ config_write (char *config_name)
|
||||
}
|
||||
}
|
||||
|
||||
/* keys section */
|
||||
fprintf (file, "\n[keys]\n");
|
||||
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
expanded_name = gui_key_get_expanded_name (ptr_key->key);
|
||||
if (ptr_key->function)
|
||||
{
|
||||
function_name = gui_key_function_search_by_ptr (ptr_key->function);
|
||||
if (function_name)
|
||||
fprintf (file, "%s=%s\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
function_name);
|
||||
}
|
||||
else
|
||||
fprintf (file, "%s=%s\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
ptr_key->command);
|
||||
if (expanded_name)
|
||||
free (expanded_name);
|
||||
}
|
||||
|
||||
/* alias section */
|
||||
fprintf (file, "\n[alias]\n");
|
||||
for (ptr_alias = weechat_alias; ptr_alias;
|
||||
|
||||
@@ -33,9 +33,10 @@
|
||||
#define CONFIG_SECTION_IRC 4
|
||||
#define CONFIG_SECTION_DCC 5
|
||||
#define CONFIG_SECTION_PROXY 6
|
||||
#define CONFIG_SECTION_ALIAS 7
|
||||
#define CONFIG_SECTION_SERVER 8
|
||||
#define CONFIG_NUMBER_SECTIONS 9
|
||||
#define CONFIG_SECTION_KEYS 7
|
||||
#define CONFIG_SECTION_ALIAS 8
|
||||
#define CONFIG_SECTION_SERVER 9
|
||||
#define CONFIG_NUMBER_SECTIONS 10
|
||||
|
||||
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
|
||||
#define OPTION_TYPE_INT 2 /* values: from min to max */
|
||||
@@ -97,6 +98,7 @@ extern char *cfg_look_no_nickname;
|
||||
extern char *cfg_look_completor;
|
||||
extern int cfg_look_infobar;
|
||||
extern char *cfg_look_infobar_timestamp;
|
||||
extern int cfg_look_infobar_seconds;
|
||||
extern int cfg_look_infobar_delay_highlight;
|
||||
|
||||
extern int cfg_col_title;
|
||||
@@ -120,6 +122,7 @@ extern int cfg_col_status_data_other;
|
||||
extern int cfg_col_status_more;
|
||||
extern int cfg_col_status_bg;
|
||||
extern int cfg_col_infobar;
|
||||
extern int cfg_col_infobar_delimiters;
|
||||
extern int cfg_col_infobar_highlight;
|
||||
extern int cfg_col_infobar_bg;
|
||||
extern int cfg_col_input;
|
||||
|
||||
Reference in New Issue
Block a user