From 99fc70bd9283280bdb6056634c759196f549a4c6 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 29 Sep 2015 23:30:23 +0100 Subject: Added last activity time format option --- src/command/command.c | 21 +++++++++++++++------ src/command/commands.c | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 7 deletions(-) (limited to 'src/command') diff --git a/src/command/command.c b/src/command/command.c index 603b0f12..2203b398 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -950,7 +950,8 @@ static struct cmd_t command_defs[] = "/time main set ", "/time main off", "/time statusbar set ", - "/time statusbar off") + "/time statusbar off", + "/time lastactivity set ") CMD_DESC( "Configure time display preferences. " "Time formats are strings supported by g_date_time_format. " @@ -958,14 +959,16 @@ static struct cmd_t command_defs[] = "Setting the format to an unsupported string, will display the string. " "If the format contains spaces, it must be surrounded with double quotes.") CMD_ARGS( - { "main set ", "Change time format in main window." }, - { "main off", "Do not show time in main window." }, - { "statusbar set ", "Change time format in statusbar." }, - { "statusbar off", "Change time format in status bar." }) + { "main set ", "Change time format in main window." }, + { "main off", "Do not show time in main window." }, + { "statusbar set ", "Change time format in statusbar." }, + { "statusbar off", "Do not show time in status bar." }, + { "lastactivity set ", "Change time format for last activity." }) CMD_EXAMPLES( "/time main set \"%d-%m-%y %H:%M\"", "/time main off", - "/time statusbar set %H:%M") + "/time statusbar set %H:%M", + "/time lastactivity set \"%d-%m-%y %H:%M\"") }, { "/inpblock", @@ -2098,6 +2101,7 @@ cmd_init(void) time_ac = autocomplete_new(); autocomplete_add(time_ac, "main"); autocomplete_add(time_ac, "statusbar"); + autocomplete_add(time_ac, "lastactivity"); time_format_ac = autocomplete_new(); autocomplete_add(time_format_ac, "set"); @@ -3367,6 +3371,11 @@ _time_autocomplete(ProfWin *window, const char * const input) return found; } + found = autocomplete_param_with_ac(input, "/time lastactivity", time_format_ac, TRUE); + if (found) { + return found; + } + found = autocomplete_param_with_ac(input, "/time main", time_format_ac, TRUE); if (found) { return found; diff --git a/src/command/commands.c b/src/command/commands.c index 6b301057..2e4332b2 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -3569,7 +3569,24 @@ cmd_wrap(ProfWin *window, const char * const command, gchar **args) gboolean cmd_time(ProfWin *window, const char * const command, gchar **args) { - if (g_strcmp0(args[0], "statusbar") == 0) { + if (g_strcmp0(args[0], "lastactivity") == 0) { + if (args[1] == NULL) { + cons_show("Current last activity time format is '%s'.", prefs_get_string(PREF_TIME_LASTACTIVITY)); + return TRUE; + } else if (g_strcmp0(args[1], "set") == 0 && args[2] != NULL) { + prefs_set_string(PREF_TIME_LASTACTIVITY, args[2]); + cons_show("Last activity time format set to '%s'.", args[2]); + ui_redraw(); + return TRUE; + } else if (g_strcmp0(args[1], "off") == 0) { + cons_show("Last activity time cannot be disabled."); + ui_redraw(); + return TRUE; + } else { + cons_bad_cmd_usage(command); + return TRUE; + } + } else if (g_strcmp0(args[0], "statusbar") == 0) { if (args[1] == NULL) { cons_show("Current status bar time format is '%s'.", prefs_get_string(PREF_TIME_STATUSBAR)); return TRUE; -- cgit 1.4.1-2-gfad0