Implementing 8 bit mode for meta.

This commit is contained in:
Christoph Lohmann 2013-04-23 15:22:14 +02:00
parent b596d6ba3c
commit 2bd6afd1c9
2 changed files with 22 additions and 4 deletions

21
st.c
View File

@ -114,6 +114,7 @@ enum term_mode {
MODE_ECHO = 1024, MODE_ECHO = 1024,
MODE_APPCURSOR = 2048, MODE_APPCURSOR = 2048,
MODE_MOUSESGR = 4096, MODE_MOUSESGR = 4096,
MODE_8BIT = 8192,
}; };
enum escape_state { enum escape_state {
@ -1650,6 +1651,9 @@ tsetmode(bool priv, bool set, int *args, int narg) {
case 1006: case 1006:
MODBIT(term.mode, set, MODE_MOUSESGR); MODBIT(term.mode, set, MODE_MOUSESGR);
break; break;
case 1034:
MODBIT(term.mode, set, MODE_8BIT);
break;
case 1049: /* = 1047 and 1048 */ case 1049: /* = 1047 and 1048 */
case 47: case 47:
case 1047: case 1047:
@ -3228,7 +3232,8 @@ kpress(XEvent *ev) {
XKeyEvent *e = &ev->xkey; XKeyEvent *e = &ev->xkey;
KeySym ksym; KeySym ksym;
char xstr[31], buf[32], *customkey, *cp = buf; char xstr[31], buf[32], *customkey, *cp = buf;
int len; int len, ret;
long c;
Status status; Status status;
Shortcut *bp; Shortcut *bp;
@ -3249,13 +3254,23 @@ kpress(XEvent *ev) {
if((customkey = kmap(ksym, e->state))) { if((customkey = kmap(ksym, e->state))) {
len = strlen(customkey); len = strlen(customkey);
memcpy(buf, customkey, len); memcpy(buf, customkey, len);
/* 2. hardcoded (overrides X lookup) */ /* 3. hardcoded (overrides X lookup) */
} else { } else {
if(len == 0) if(len == 0)
return; return;
if(len == 1 && e->state & Mod1Mask) if(len == 1 && e->state & Mod1Mask) {
if(IS_SET(MODE_8BIT)) {
if(*xstr < 0177) {
c = *xstr | B7;
ret = utf8encode(&c, cp);
cp += ret;
len = 0;
}
} else {
*cp++ = '\033'; *cp++ = '\033';
}
}
memcpy(cp, xstr, len); memcpy(cp, xstr, len);
len = cp - buf + len; len = cp - buf + len;

View File

@ -147,6 +147,7 @@ st| simpleterm,
kich1=\E[2~, kich1=\E[2~,
knp=\E[6~, knp=\E[6~,
kmous=\E[M, kmous=\E[M,
km,
kpp=\E[5~, kpp=\E[5~,
lines#24, lines#24,
mir, mir,
@ -162,6 +163,7 @@ st| simpleterm,
rmcup=\E[?1049l, rmcup=\E[?1049l,
rmir=\E[4l, rmir=\E[4l,
rmkx=\E[?1l\E>, rmkx=\E[?1l\E>,
rmm=\E[?1034l,
rmso=\E[27m, rmso=\E[27m,
rmul=\E[m, rmul=\E[m,
rs1=\Ec, rs1=\Ec,
@ -178,6 +180,7 @@ st| simpleterm,
smcup=\E[?1049h, smcup=\E[?1049h,
smir=\E[4h, smir=\E[4h,
smkx=\E[?1h\E=, smkx=\E[?1h\E=,
smm=\E[?1034h,
smso=\E[7m, smso=\E[7m,
smul=\E[4m, smul=\E[4m,
tbc=\E[3g, tbc=\E[3g,