summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--chat.h2
-rw-r--r--term.c14
-rw-r--r--ui.c11
3 files changed, 9 insertions, 18 deletions
diff --git a/chat.h b/chat.h
index f9de779..8a806f1 100644
--- a/chat.h
+++ b/chat.h
@@ -129,9 +129,7 @@ enum TermEvent {
 	TermPasteStart,
 	TermPasteEnd,
 };
-void termInit(void);
 void termNoFlow(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 bf4a933..427cac6 100644
--- a/term.c
+++ b/term.c
@@ -17,19 +17,11 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <termios.h>
 #include <unistd.h>
 
 #include "chat.h"
 
-static bool xterm;
-
-void termInit(void) {
-	const char *term = getenv("TERM");
-	xterm = (term && !strncmp(term, "xterm", 5));
-}
-
 void termNoFlow(void) {
 	struct termios attr;
 	int error = tcgetattr(STDIN_FILENO, &attr);
@@ -39,12 +31,6 @@ void termNoFlow(void) {
 	tcsetattr(STDIN_FILENO, TCSANOW, &attr);
 }
 
-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);
diff --git a/ui.c b/ui.c
index 2d5e454..f434289 100644
--- a/ui.c
+++ b/ui.c
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sysexits.h>
+#include <term.h>
 #include <time.h>
 #include <wchar.h>
 #include <wctype.h>
@@ -133,11 +134,15 @@ void uiInit(void) {
 	initscr();
 	cbreak();
 	noecho();
-	termInit();
 	termNoFlow();
 	def_prog_mode();
 	err_set_exit(errExit);
 	colorInit();
+	if (!to_status_line && !strncmp(termname(), "xterm", 5)) {
+		to_status_line = "\33]2;";
+		from_status_line = "\7";
+	}
+
 	status = newwin(1, COLS, 0, 0);
 	input = newpad(1, InputCols);
 	keypad(input, true);
@@ -305,7 +310,9 @@ static void statusUpdate(void) {
 		&unread, windows.active->unread
 	);
 	if (!windows.active->unread) buf[unread] = '\0';
-	termTitle(buf);
+	putp(to_status_line);
+	putp(buf);
+	putp(from_status_line);
 }
 
 void uiShowID(size_t id) {
2019-12-20Respect mailmap in gl pretty formatJune McEnroe 2019-12-20Set LANG in cgit filtersJune McEnroe ttpre needs to know about UTF-8 too so it can bold/italic non-ASCII chars. 2019-12-20Source .editrc before applying -v or -eJune McEnroe Otherwise a bind -v in .editrc will take precedence and overwrite the ^I binding for sh-complete. 2019-12-20Disable signing commitsJune McEnroe Why did I ever turn this on? This gets me nothing but inconvenience. RIP to all the wasted bytes in my git repos. 2019-12-19Ignore about-filterJune McEnroe 2019-12-19Fix matching make tags with no sourcesJune McEnroe 2019-12-19Avoid matching := assignments as tagsJune McEnroe 2019-12-18Hide line numbers when rendering mdocJune McEnroe Hack: output an extra <td> after rendering mdoc so that line numbers can be hidden based on there being three. This required splitting source-filter and about-filter since on about pages there is no table. 2019-12-18Customize cgit CSSJune McEnroe 2019-12-18Use :target rather than :focus pseudo-classJune McEnroe :target persists after you click on something else. 2019-12-18Copy cgit auxiliary binaries properlyJune McEnroe 2019-12-18Add git.causal.agency cgit configJune McEnroe 2019-12-18Bail from hi if input is binaryJune McEnroe NULs in the input cause an infinite loop in htmlEscape, not to mention regexes obviously not working, etc. 2019-12-16Post "cgit setup"June McEnroe