Use tsl/fsl capabilities for title if available

Also manually fill them if TERM=xterm* because they really should be
there.
weechat-hashes
C. McEnroe 2020-02-02 18:39:08 -05:00
parent a507ff4073
commit 8ec17d4f8c
3 changed files with 9 additions and 18 deletions

2
chat.h
View File

@ -129,9 +129,7 @@ enum TermEvent {
TermPasteStart, TermPasteStart,
TermPasteEnd, TermPasteEnd,
}; };
void termInit(void);
void termNoFlow(void); void termNoFlow(void);
void termTitle(const char *title);
void termMode(enum TermMode mode, bool set); void termMode(enum TermMode mode, bool set);
enum TermEvent termEvent(char ch); enum TermEvent termEvent(char ch);

14
term.c
View File

@ -17,19 +17,11 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include "chat.h" #include "chat.h"
static bool xterm;
void termInit(void) {
const char *term = getenv("TERM");
xterm = (term && !strncmp(term, "xterm", 5));
}
void termNoFlow(void) { void termNoFlow(void) {
struct termios attr; struct termios attr;
int error = tcgetattr(STDIN_FILENO, &attr); int error = tcgetattr(STDIN_FILENO, &attr);
@ -39,12 +31,6 @@ void termNoFlow(void) {
tcsetattr(STDIN_FILENO, TCSANOW, &attr); 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) { static void privateMode(const char *mode, bool set) {
printf("\33[?%s%c", mode, (set ? 'h' : 'l')); printf("\33[?%s%c", mode, (set ? 'h' : 'l'));
fflush(stdout); fflush(stdout);

11
ui.c
View File

@ -24,6 +24,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sysexits.h> #include <sysexits.h>
#include <term.h>
#include <time.h> #include <time.h>
#include <wchar.h> #include <wchar.h>
#include <wctype.h> #include <wctype.h>
@ -133,11 +134,15 @@ void uiInit(void) {
initscr(); initscr();
cbreak(); cbreak();
noecho(); noecho();
termInit();
termNoFlow(); termNoFlow();
def_prog_mode(); def_prog_mode();
err_set_exit(errExit); err_set_exit(errExit);
colorInit(); colorInit();
if (!to_status_line && !strncmp(termname(), "xterm", 5)) {
to_status_line = "\33]2;";
from_status_line = "\7";
}
status = newwin(1, COLS, 0, 0); status = newwin(1, COLS, 0, 0);
input = newpad(1, InputCols); input = newpad(1, InputCols);
keypad(input, true); keypad(input, true);
@ -305,7 +310,9 @@ static void statusUpdate(void) {
&unread, windows.active->unread &unread, windows.active->unread
); );
if (!windows.active->unread) buf[unread] = '\0'; if (!windows.active->unread) buf[unread] = '\0';
termTitle(buf); putp(to_status_line);
putp(buf);
putp(from_status_line);
} }
void uiShowID(size_t id) { void uiShowID(size_t id) {