about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-27 14:18:20 -0500
committerJune McEnroe <june@causal.agency>2021-01-27 14:18:20 -0500
commitd6ff9e53cf724460b6f827edf40d698d35ffa2f7 (patch)
treef54e194740a4600a3ac6ea3966e58a76adf1f0fb
parentAdd toggleable display of timestamps (diff)
downloadcatgirl-d6ff9e53cf724460b6f827edf40d698d35ffa2f7.tar.gz
catgirl-d6ff9e53cf724460b6f827edf40d698d35ffa2f7.zip
Change default timestamp format to %X
This respects the user's locale settings.
Diffstat (limited to '')
-rw-r--r--catgirl.12
-rw-r--r--chat.c15
-rw-r--r--ui.c14
3 files changed, 14 insertions, 17 deletions
diff --git a/catgirl.1 b/catgirl.1
index d40b377..d572a8b 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -188,7 +188,7 @@ in the specified
 .Xr strftime 3
 .Ar format .
 The default format is
-.Qq \&%T .
+.Qq \&%X .
 .
 .It Fl a Ar user : Ns Ar pass , Cm sasl-plain = Ar user : Ns Ar pass
 Authenticate as
diff --git a/chat.c b/chat.c
index 7de427c..7335520 100644
--- a/chat.c
+++ b/chat.c
@@ -125,16 +125,6 @@ static void parseHash(char *str) {
 	if (*str) hashBound = strtoul(&str[1], NULL, 0);
 }
 
-static void parseTimestamp(const char *format) {
-	uiTime.enable = true;
-	if (!format) return;
-	char buf[TimeCap];
-	uiTime.format = format;
-	struct tm *time = localtime(&(time_t) { -22100400 });
-	uiTime.width = strftime(buf, sizeof(buf), format, time);
-	if (!uiTime.width) errx(EX_USAGE, "invalid timestamp format: %s", format);
-}
-
 #ifdef __OpenBSD__
 
 static void unveilConfig(const char *name) {
@@ -246,7 +236,10 @@ int main(int argc, char *argv[]) {
 			break; case 'O': utilPush(&urlOpenUtil, optarg);
 			break; case 'R': self.restricted = true;
 			break; case 'S': bind = optarg;
-			break; case 'T': parseTimestamp(optarg);
+			break; case 'T': {
+				uiTime.enable = true;
+				if (optarg) uiTime.format = optarg;
+			}
 			break; case 'a': sasl = true; self.plain = optarg;
 			break; case 'c': cert = optarg;
 			break; case 'e': sasl = true;
diff --git a/ui.c b/ui.c
index 5997571..da40dc0 100644
--- a/ui.c
+++ b/ui.c
@@ -69,11 +69,6 @@ enum {
 #define RIGHT (COLS - 1)
 #define MAIN_LINES (LINES - StatusLines - InputLines)
 
-struct Time uiTime = {
-	.format = "%T",
-	.width = 8,
-};
-
 static WINDOW *status;
 static WINDOW *main;
 static WINDOW *input;
@@ -232,6 +227,8 @@ static const char *ExitFocusMode  = "\33[?1004l";
 static const char *EnterPasteMode = "\33[?2004h";
 static const char *ExitPasteMode  = "\33[?2004l";
 
+struct Time uiTime = { .format = "%X" };
+
 static void errExit(void) {
 	putp(ExitFocusMode);
 	putp(ExitPasteMode);
@@ -239,6 +236,13 @@ static void errExit(void) {
 }
 
 void uiInitEarly(void) {
+	char buf[TimeCap];
+	struct tm *time = localtime(&(time_t) { -22100400 });
+	uiTime.width = strftime(buf, sizeof(buf), uiTime.format, time);
+	if (!uiTime.width) {
+		errx(EX_CONFIG, "invalid timestamp format: %s", uiTime.format);
+	}
+
 	initscr();
 	cbreak();
 	noecho();
an>Show indicator in status when window has pending inputJune McEnroe 2022-02-20Use separate edit buffers for each IDJune McEnroe 2022-02-20Make sure new cap is actually larger than new lengthJune McEnroe 2022-02-20Remove unused mbs.len field from struct EditJune McEnroe 2022-02-19Remove unneeded includes in ui.cJune McEnroe 2022-02-19Reimplement tab completeJune McEnroe 2022-02-19Handle errors from editFn, etc.June McEnroe 2022-02-19Reimplement text macrosJune McEnroe 2022-02-19Factor out input handling to input.cJune McEnroe 2022-02-19Factor out window management to window.cJune McEnroe 2022-02-19Enable -Wmissing-prototypesJune McEnroe In other words, warn when a function is missing static. I don't see why this isn't in -Wextra. 2022-02-19Fix edit.[ch] license notice additional permissionsJune McEnroe 2022-02-19Run line editing testsJune McEnroe I know, it feels wrong. 2022-02-18Implement new line editing "library"June McEnroe Losing tab complete and text macros, for now. This new implementation works on an instance of a struct and does not interact with the rest of catgirl, making it possible to copy into another project. Unlike existing line editing libraries, this one is entirely abstract and can be rendered externally. My goal with this library is to be able to implement vi mode. Since it operates on struct instances rather than globals, it might also be possible to give catgirl separate line editing buffers for each window, which would be a nice UX improvement. 2022-02-18Simplify cursor positioning in inputJune McEnroe Do some extra work by adding the portion before the cursor to the input window twice, but simplify the interaction with the split point. This fixes the awkward behaviour when moving the cursor across colour codes where the code would be partially interpreted up to the cursor. 2022-02-18Fix M-f orderingJune McEnroe 2022-02-12Move sandman build to scripts/MakefileJune McEnroe 2022-02-12Use compat_readpassphrase.c on LinuxJune McEnroe 2022-02-12Copy RPP defines from oconfigureJune McEnroe