From 8ba2d2694756da38b680befff88fdaea1b5ef8bf Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 23 Jan 2014 19:56:33 +0000 Subject: [PATCH] Added skeleton /alias command --- src/command/command.c | 20 ++++++++++++++++++-- src/command/commands.c | 7 +++++++ src/command/commands.h | 1 + src/ui/console.c | 7 +++++++ src/ui/ui.h | 1 + 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index ceed2e01..76f237cb 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -546,6 +546,14 @@ static struct cmd_t command_defs[] = "The default is 'off'.", NULL } } }, + { "/alias", + cmd_alias, parse_args, 1, 3, &cons_alias_setting, + { "/alias add|remove|list [name value]", "Add your own command aliases.", + { "/alias add|remove|list [name value]", + "-----------------------------------", + "Add, remove or show command aliases.", + NULL } } }, + { "/chlog", cmd_chlog, parse_args, 1, 1, &cons_chlog_setting, { "/chlog on|off", "Chat logging to file.", @@ -861,6 +869,7 @@ static Autocomplete otr_log_ac; static Autocomplete connect_property_ac; static Autocomplete statuses_ac; static Autocomplete statuses_cons_chat_ac; +static Autocomplete alias_ac; /* * Initialise command autocompleter and history @@ -1044,6 +1053,11 @@ cmd_init(void) autocomplete_add(statuses_cons_chat_ac, "online"); autocomplete_add(statuses_cons_chat_ac, "none"); + alias_ac = autocomplete_new(); + autocomplete_add(alias_ac, "add"); + autocomplete_add(alias_ac, "remove"); + autocomplete_add(alias_ac, "list"); + cmd_history_init(); } @@ -1079,6 +1093,7 @@ cmd_uninit(void) autocomplete_free(connect_property_ac); autocomplete_free(statuses_ac); autocomplete_free(statuses_cons_chat_ac); + autocomplete_free(alias_ac); } // Command autocompletion functions @@ -1157,6 +1172,7 @@ cmd_reset_autocomplete() autocomplete_reset(connect_property_ac); autocomplete_reset(statuses_ac); autocomplete_reset(statuses_cons_chat_ac); + autocomplete_reset(alias_ac); bookmark_autocomplete_reset(); } @@ -1378,8 +1394,8 @@ _cmd_complete_parameters(char *input, int *size) return; } - gchar *cmds[] = { "/help", "/prefs", "/log", "/disco", "/close", "/wins" }; - Autocomplete completers[] = { help_ac, prefs_ac, log_ac, disco_ac, close_ac, wins_ac }; + gchar *cmds[] = { "/help", "/prefs", "/log", "/disco", "/close", "/wins", "/alias" }; + Autocomplete completers[] = { help_ac, prefs_ac, log_ac, disco_ac, close_ac, wins_ac, alias_ac }; for (i = 0; i < ARRAY_SIZE(cmds); i++) { result = autocomplete_param_with_ac(input, size, cmds[i], completers[i]); diff --git a/src/command/commands.c b/src/command/commands.c index 7943bfad..712d39d8 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1818,6 +1818,13 @@ cmd_nick(gchar **args, struct cmd_help_t help) return TRUE; } +gboolean +cmd_alias(gchar **args, struct cmd_help_t help) +{ + cons_show("Alias command TODO"); + return TRUE; +} + gboolean cmd_tiny(gchar **args, struct cmd_help_t help) { diff --git a/src/command/commands.h b/src/command/commands.h index 741ab638..4572da52 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -109,5 +109,6 @@ gboolean cmd_who(gchar **args, struct cmd_help_t help); gboolean cmd_win(gchar **args, struct cmd_help_t help); gboolean cmd_wins(gchar **args, struct cmd_help_t help); gboolean cmd_xa(gchar **args, struct cmd_help_t help); +gboolean cmd_alias(gchar **args, struct cmd_help_t help); #endif diff --git a/src/ui/console.c b/src/ui/console.c index e6ab7eab..a79f438e 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -902,6 +902,12 @@ _cons_show_account(ProfAccount *account) cons_alert(); } +static void +_cons_alias_setting(void) +{ + cons_show("Alias setting TODO"); +} + static void _cons_theme_setting(void) { @@ -1607,6 +1613,7 @@ console_init_module(void) cons_mouse_setting = _cons_mouse_setting; cons_statuses_setting = _cons_statuses_setting; cons_titlebar_setting = _cons_titlebar_setting; + cons_alias_setting = _cons_alias_setting; cons_show_ui_prefs = _cons_show_ui_prefs; cons_notify_setting = _cons_notify_setting; cons_show_desktop_prefs = _cons_show_desktop_prefs; diff --git a/src/ui/ui.h b/src/ui/ui.h index df59e477..00d284f3 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -202,6 +202,7 @@ void (*cons_show_received_subs)(void); void (*cons_show_sent_subs)(void); void (*cons_alert)(void); void (*cons_theme_setting)(void); +void (*cons_alias_setting)(void); void (*cons_beep_setting)(void); void (*cons_flash_setting)(void); void (*cons_splash_setting)(void);