Add termTitle
parent
1ca6974b64
commit
11d445b672
2
chat.h
2
chat.h
|
@ -109,6 +109,8 @@ enum TermEvent {
|
||||||
TERM_PASTE_START,
|
TERM_PASTE_START,
|
||||||
TERM_PASTE_END,
|
TERM_PASTE_END,
|
||||||
};
|
};
|
||||||
|
void termInit(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
14
term.c
|
@ -17,11 +17,25 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "chat.h"
|
#include "chat.h"
|
||||||
|
|
||||||
#define PAIR(a, b) (((short)(a) << 8) | ((short)(b) & 0xFF))
|
#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) {
|
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);
|
||||||
|
|
Loading…
Reference in New Issue