Add termTitle

weechat-hashes
Curtis McEnroe 2018-08-13 22:54:02 -04:00
parent 1ca6974b64
commit 11d445b672
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
2 changed files with 16 additions and 0 deletions

2
chat.h
View File

@ -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);

14
term.c
View File

@ -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);