1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-16 04:13:02 +01:00

add setting option to disable timestamps

This commit is contained in:
Jfreegman 2014-06-28 20:33:46 -04:00
parent a2e6a25fc8
commit 97536d2a72
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
5 changed files with 33 additions and 3 deletions

View File

@ -13,7 +13,7 @@ client.
Lines starting with "#" are comments and will be ignored. Lines starting with "#" are comments and will be ignored.
.PP .PP
Keys: Keys:
.RS .PP
.B time .B time
.RS .RS
Select between 24 and 12 hour time. Select between 24 and 12 hour time.
@ -21,6 +21,13 @@ Select between 24 and 12 hour time.
Values: 24, 12 Values: 24, 12
.RE .RE
.PP .PP
.B timestamps
.RS
Enable or disable timestamps.
.br
Values: 1 to enable, 0 to disable
.RE
.PP
.B autolog .B autolog
.RS .RS
Enable or disable autologging. Enable or disable autologging.

View File

@ -1,6 +1,9 @@
# 24 or 12 hour time # 24 or 12 hour time
time:24; time:24;
# 1 to enable timestamps, 0 to disable
timestamps:1;
# 1 to enable autologging, 0 to disable # 1 to enable autologging, 0 to disable
autolog:0; autolog:0;

View File

@ -58,6 +58,11 @@ struct tm *get_time(void)
/*Puts the current time in buf in the format of [HH:mm:ss] */ /*Puts the current time in buf in the format of [HH:mm:ss] */
void get_time_str(uint8_t *buf, int bufsize) void get_time_str(uint8_t *buf, int bufsize)
{ {
if (user_settings->timestamps == TIMESTAMPS_OFF) {
buf[0] = '\0';
return;
}
const char *t = user_settings->time == TIME_12 ? "[%-I:%M:%S] " : "[%H:%M:%S] "; const char *t = user_settings->time == TIME_12 ? "[%-I:%M:%S] " : "[%H:%M:%S] ";
strftime(buf, bufsize, t, get_time()); strftime(buf, bufsize, t, get_time());
} }

View File

@ -36,6 +36,7 @@
static void uset_autolog(struct user_settings *s, const char *val); static void uset_autolog(struct user_settings *s, const char *val);
static void uset_time(struct user_settings *s, const char *val); static void uset_time(struct user_settings *s, const char *val);
static void uset_timestamps(struct user_settings *s, const char *val);
static void uset_alerts(struct user_settings *s, const char *val); static void uset_alerts(struct user_settings *s, const char *val);
static void uset_colours(struct user_settings *s, const char *val); static void uset_colours(struct user_settings *s, const char *val);
static void uset_hst_size(struct user_settings *s, const char *val); static void uset_hst_size(struct user_settings *s, const char *val);
@ -52,6 +53,7 @@ struct {
} user_settings_list[] = { } user_settings_list[] = {
{ "autolog", uset_autolog }, { "autolog", uset_autolog },
{ "time", uset_time }, { "time", uset_time },
{ "timestamps", uset_timestamps },
{ "disable_alerts", uset_alerts }, { "disable_alerts", uset_alerts },
{ "colour_theme", uset_colours }, { "colour_theme", uset_colours },
{ "history_size", uset_hst_size }, { "history_size", uset_hst_size },
@ -79,6 +81,14 @@ static void uset_time(struct user_settings *s, const char *val)
s->time = n == TIME_12 ? TIME_12 : TIME_24; s->time = n == TIME_12 ? TIME_12 : TIME_24;
} }
static void uset_timestamps(struct user_settings *s, const char *val)
{
int n = atoi(val);
/* default on if invalid value */
s->timestamps = n == TIMESTAMPS_OFF ? TIMESTAMPS_OFF : TIMESTAMPS_ON;
}
static void uset_alerts(struct user_settings *s, const char *val) static void uset_alerts(struct user_settings *s, const char *val)
{ {
int n = atoi(val); int n = atoi(val);
@ -155,6 +165,7 @@ static void set_default_settings(struct user_settings *s)
/* see settings_values enum in settings.h for defaults */ /* see settings_values enum in settings.h for defaults */
uset_autolog(s, "0"); uset_autolog(s, "0");
uset_time(s, "24"); uset_time(s, "24");
uset_timestamps(s, "1");
uset_alerts(s, "0"); uset_alerts(s, "0");
uset_colours(s, "0"); uset_colours(s, "0");
uset_hst_size(s, "700"); uset_hst_size(s, "700");

View File

@ -26,9 +26,9 @@
#include "toxic.h" #include "toxic.h"
#ifdef _SUPPORT_AUDIO #ifdef _SUPPORT_AUDIO
#define NUM_SETTINGS 8 #define NUM_SETTINGS 9
#else #else
#define NUM_SETTINGS 6 #define NUM_SETTINGS 7
#endif /* _SUPPORT_AUDIO */ #endif /* _SUPPORT_AUDIO */
/* holds user setting values */ /* holds user setting values */
@ -36,6 +36,7 @@ struct user_settings {
int autolog; /* boolean */ int autolog; /* boolean */
int alerts; /* boolean */ int alerts; /* boolean */
int time; /* 12 or 24 */ int time; /* 12 or 24 */
int timestamps; /* boolean */
int colour_theme; /* boolean (0 for default toxic colours) */ int colour_theme; /* boolean (0 for default toxic colours) */
int history_size; /* int between MIN_HISTORY and MAX_HISTORY */ int history_size; /* int between MIN_HISTORY and MAX_HISTORY */
char download_path[MAX_STR_SIZE]; char download_path[MAX_STR_SIZE];
@ -53,6 +54,9 @@ enum {
TIME_24 = 24, TIME_24 = 24,
TIME_12 = 12, TIME_12 = 12,
TIMESTAMPS_OFF = 0,
TIMESTAMPS_ON = 1,
ALERTS_DISABLED = 1, ALERTS_DISABLED = 1,
ALERTS_ENABLED = 0, ALERTS_ENABLED = 0,