summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-13 22:54:02 -0400
committerJune McEnroe <june@causal.agency>2018-08-13 22:54:02 -0400
commit11d445b6720d78d4fe847affb1d26ee0a552ea0f (patch)
tree2cdf54a05e04473953eed9c5a7714531d1ebbab3
parentDon't ping self (diff)
downloadcatgirl-11d445b6720d78d4fe847affb1d26ee0a552ea0f.tar.gz
catgirl-11d445b6720d78d4fe847affb1d26ee0a552ea0f.zip
Add termTitle
-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);
src/commit/bin/order.y?id=cdf925f29e53eba20bc47af161fb6aec3b7c465d&follow=1'>Add orderJune McEnroe 2019-05-12Add T suffix in bitJune McEnroe 2019-05-10Highlight yacc and lex files as CJune McEnroe Their %-prefixed directives should probably be highlighted Macro. 2019-05-10Use val instead of suboptargJune McEnroe suboptarg doesn't exist in GNU. Hopefully BSD getsubopt also sets val on failure? 2019-05-09Add Parable of the SowerJune McEnroe 2019-05-07Add bit without buildJune McEnroe Need to do some stuff in the Makefile for lex and yacc and generating HTML pages for it. 2019-05-04Fix MANDIR typoJune McEnroe 2019-05-04Move relay to binJune McEnroe