Added last activity time format option

This commit is contained in:
James Booth
2015-09-29 23:30:23 +01:00
parent ac1164a3fa
commit 99fc70bd92
9 changed files with 81 additions and 28 deletions

View File

@@ -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;

View File

@@ -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;