diff options
author | James Booth <boothj5@gmail.com> | 2015-09-29 23:30:23 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-09-29 23:30:23 +0100 |
commit | 99fc70bd9283280bdb6056634c759196f549a4c6 (patch) | |
tree | cf08ac6c09eed76ff1350efa3c739268667de73e /src/command | |
parent | ac1164a3fa6f4c388399af06612e16eade16e46b (diff) | |
download | profani-tty-99fc70bd9283280bdb6056634c759196f549a4c6.tar.gz |
Added last activity time format option
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 21 | ||||
-rw-r--r-- | src/command/commands.c | 19 |
2 files changed, 33 insertions, 7 deletions
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 <format>", "/time main off", "/time statusbar set <format>", - "/time statusbar off") + "/time statusbar off", + "/time lastactivity set <format>") 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 <format>", "Change time format in main window." }, - { "main off", "Do not show time in main window." }, - { "statusbar set <format>", "Change time format in statusbar." }, - { "statusbar off", "Change time format in status bar." }) + { "main set <format>", "Change time format in main window." }, + { "main off", "Do not show time in main window." }, + { "statusbar set <format>", "Change time format in statusbar." }, + { "statusbar off", "Do not show time in status bar." }, + { "lastactivity set <format>", "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; |