diff --git a/src/command/command.c b/src/command/command.c index 7849dde9..27c8e078 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -105,6 +105,7 @@ static char * _inpblock_autocomplete(ProfWin *window, const char * const input); static char * _time_autocomplete(ProfWin *window, const char * const input); static char * _receipts_autocomplete(ProfWin *window, const char * const input); static char * _help_autocomplete(ProfWin *window, const char * const input); +static char * _wins_autocomplete(ProfWin *window, const char * const input); GHashTable *commands = NULL; @@ -697,14 +698,16 @@ static struct cmd_t command_defs[] = CMD_TAG_UI) CMD_SYN( "/wins tidy", + "/wins autotidy on|off", "/wins prune", "/wins swap ") CMD_DESC( "Manage windows. " "Passing no argument will list all currently active windows and information about their usage.") CMD_ARGS( - { "tidy", "Move windows so there are no gaps." }, - { "prune", "Close all windows with no unread messages, and then tidy so there are no gaps." }, + { "tidy", "Move windows so there are no gaps." }, + { "autotidy on|off", "Automatically remove gaps when closing windows." }, + { "prune", "Close all windows with no unread messages, and then tidy so there are no gaps." }, { "swap ", "Swap windows, target may be an empty position." }) CMD_NOEXAMPLES }, @@ -893,19 +896,6 @@ static struct cmd_t command_defs[] = CMD_NOEXAMPLES }, - { "/winstidy", - cmd_winstidy, parse_args, 1, 1, &cons_winstidy_setting, - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/winstidy on|off") - CMD_DESC( - "Auto tidy windows, when a window is closed, windows will be moved to fill the gap.") - CMD_ARGS( - { "on|off", "Enable or disable auto window tidy." }) - CMD_NOEXAMPLES - }, - { "/time", cmd_time, parse_args, 1, 3, &cons_time_setting, CMD_TAGS( @@ -1872,6 +1862,7 @@ cmd_init(void) wins_ac = autocomplete_new(); autocomplete_add(wins_ac, "prune"); autocomplete_add(wins_ac, "tidy"); + autocomplete_add(wins_ac, "autotidy"); autocomplete_add(wins_ac, "swap"); roster_ac = autocomplete_new(); @@ -2534,8 +2525,8 @@ _cmd_complete_parameters(ProfWin *window, const char * const input) } } - gchar *cmds[] = { "/prefs", "/disco", "/close", "/wins", "/subject", "/room" }; - Autocomplete completers[] = { prefs_ac, disco_ac, close_ac, wins_ac, subject_ac, room_ac }; + gchar *cmds[] = { "/prefs", "/disco", "/close", "/subject", "/room" }; + Autocomplete completers[] = { prefs_ac, disco_ac, close_ac, subject_ac, room_ac }; for (i = 0; i < ARRAY_SIZE(cmds); i++) { result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE); @@ -2574,6 +2565,7 @@ _cmd_complete_parameters(ProfWin *window, const char * const input) g_hash_table_insert(ac_funcs, "/inpblock", _inpblock_autocomplete); g_hash_table_insert(ac_funcs, "/time", _time_autocomplete); g_hash_table_insert(ac_funcs, "/receipts", _receipts_autocomplete); + g_hash_table_insert(ac_funcs, "/wins", _wins_autocomplete); int len = strlen(input); char parsed[len+1]; @@ -3462,6 +3454,24 @@ _statuses_autocomplete(ProfWin *window, const char * const input) return NULL; } +static char * +_wins_autocomplete(ProfWin *window, const char * const input) +{ + char *result = NULL; + + result = autocomplete_param_with_func(input, "/wins autotidy", prefs_autocomplete_boolean_choice); + if (result) { + return result; + } + + result = autocomplete_param_with_ac(input, "/wins", wins_ac, TRUE); + if (result) { + return result; + } + + return NULL; +} + static char * _receipts_autocomplete(ProfWin *window, const char * const input) { diff --git a/src/command/commands.c b/src/command/commands.c index e3374ddd..61c0373b 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -747,6 +747,17 @@ cmd_wins(ProfWin *window, const char * const command, gchar **args) cons_show("Same source and target window supplied."); } } + } else if (strcmp(args[0], "autotidy") == 0) { + if (g_strcmp0(args[1], "on") == 0) { + cons_show("Window autotidy enabled"); + prefs_set_boolean(PREF_WINS_AUTO_TIDY, TRUE); + ui_tidy_wins(); + } else if (g_strcmp0(args[1], "off") == 0) { + cons_show("Window autotidy disabled"); + prefs_set_boolean(PREF_WINS_AUTO_TIDY, FALSE); + } else { + cons_bad_cmd_usage(command); + } } else { cons_bad_cmd_usage(command); } @@ -754,18 +765,6 @@ cmd_wins(ProfWin *window, const char * const command, gchar **args) return TRUE; } -gboolean -cmd_winstidy(ProfWin *window, const char * const command, gchar **args) -{ - gboolean result = _cmd_set_boolean_preference(args[0], command, "Wins Auto Tidy", PREF_WINS_AUTO_TIDY); - - if (result && g_strcmp0(args[0], "on") == 0) { - ui_tidy_wins(); - } - - return result; -} - gboolean cmd_win(ProfWin *window, const char * const command, gchar **args) { diff --git a/src/command/commands.h b/src/command/commands.h index c158f606..89f923ff 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -129,7 +129,6 @@ gboolean cmd_vercheck(ProfWin *window, const char * const command, gchar **args) gboolean cmd_who(ProfWin *window, const char * const command, gchar **args); gboolean cmd_win(ProfWin *window, const char * const command, gchar **args); gboolean cmd_wins(ProfWin *window, const char * const command, gchar **args); -gboolean cmd_winstidy(ProfWin *window, const char * const command, gchar **args); gboolean cmd_xa(ProfWin *window, const char * const command, gchar **args); gboolean cmd_alias(ProfWin *window, const char * const command, gchar **args); gboolean cmd_xmlconsole(ProfWin *window, const char * const command, gchar **args); diff --git a/src/ui/console.c b/src/ui/console.c index 2b05448b..80bfe9f5 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -923,9 +923,9 @@ void cons_winstidy_setting(void) { if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) - cons_show("Window Auto Tidy (/winstidy) : ON"); + cons_show("Window Auto Tidy (/wins) : ON"); else - cons_show("Window Auto Tidy (/winstidy) : OFF"); + cons_show("Window Auto Tidy (/wins) : OFF"); } void