summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--chat.h2
-rw-r--r--term.c14
2 files changed, 16 insertions, 0 deletions
diff --git a/chat.h b/chat.h
index 7e9f220..d6dfdf7 100644
--- a/chat.h
+++ b/chat.h
@@ -109,6 +109,8 @@ enum TermEvent {
 	TERM_PASTE_START,
 	TERM_PASTE_END,
 };
+void termInit(void);
+void termTitle(const char *title);
 void termMode(enum TermMode mode, bool set);
 enum TermEvent termEvent(char ch);
 
diff --git a/term.c b/term.c
index c603d32..1266328 100644
--- a/term.c
+++ b/term.c
@@ -17,11 +17,25 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "chat.h"
 
 #define PAIR(a, b) (((short)(a) << 8) | ((short)(b) & 0xFF))
 
+static bool xterm;
+
+void termInit(void) {
+	char *term = getenv("TERM");
+	xterm = term && !strncmp(term, "xterm", 5);
+}
+
+void termTitle(const char *title) {
+	if (!xterm) return;
+	printf("\33]0;%s\33\\", title);
+	fflush(stdout);
+}
+
 static void privateMode(const char *mode, bool set) {
 	printf("\33[?%s%c", mode, (set ? 'h' : 'l'));
 	fflush(stdout);
0094d3bf8e7e&follow=1'>Automatically select the last used lens for a bodyJune McEnroe 2024-09-19Add photos from September 5June McEnroe 2024-09-15Add some more film stocks to the listJune McEnroe 2024-09-13Add photos from September 2June McEnroe 2024-09-13Add Fomapan 200 to films listJune McEnroe 2024-09-10Add August 29 picnic photosJune McEnroe 2024-09-08Apply some bold to trips renderingJune McEnroe 2024-09-08Render trips hopefully more efficientlyJune McEnroe 2024-09-08Allow removing bodies and lensesJune McEnroe 2024-09-08Limit body width so it looks less silly on desktopJune McEnroe 2024-09-07Handle no film being loadedJune McEnroe 2024-09-07Fancy up the text a littleJune McEnroe