summary refs log tree commit diff
path: root/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'term.c')
-rw-r--r--term.c14
1 files changed, 14 insertions, 0 deletions
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);
follow=1'>Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe For some reason I haven't been able to figure out, trying to poll /dev/tty returns POLLNVAL (and this was using 100% CPU looping), but using stderr instead works fine. 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe