mirror of git://git.suckless.org/st
Add SRM sequence
This sequence enable/disable the local echo. --- st.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 20 deletions(-)
This commit is contained in:
parent
ace789a79f
commit
73177ba366
72
st.c
72
st.c
|
@ -120,7 +120,8 @@ enum term_mode {
|
||||||
MODE_MOUSE = 32|64,
|
MODE_MOUSE = 32|64,
|
||||||
MODE_REVERSE = 128,
|
MODE_REVERSE = 128,
|
||||||
MODE_KBDLOCK = 256,
|
MODE_KBDLOCK = 256,
|
||||||
MODE_HIDE = 512
|
MODE_HIDE = 512,
|
||||||
|
MODE_ECHO = 1024
|
||||||
};
|
};
|
||||||
|
|
||||||
enum escape_state {
|
enum escape_state {
|
||||||
|
@ -320,6 +321,7 @@ static void tswapscreen(void);
|
||||||
static void tsetdirt(int, int);
|
static void tsetdirt(int, int);
|
||||||
static void tsetmode(bool, bool, int *, int);
|
static void tsetmode(bool, bool, int *, int);
|
||||||
static void tfulldirt(void);
|
static void tfulldirt(void);
|
||||||
|
static void techo(char *, int);
|
||||||
|
|
||||||
static void ttynew(void);
|
static void ttynew(void);
|
||||||
static void ttyread(void);
|
static void ttyread(void);
|
||||||
|
@ -1534,7 +1536,8 @@ tsetmode(bool priv, bool set, int *args, int narg) {
|
||||||
case 4: /* IRM -- Insertion-replacement */
|
case 4: /* IRM -- Insertion-replacement */
|
||||||
MODBIT(term.mode, set, MODE_INSERT);
|
MODBIT(term.mode, set, MODE_INSERT);
|
||||||
break;
|
break;
|
||||||
case 12: /* XXX: SRM -- Send/Receive */
|
case 12: /* SRM -- Send/Receive */
|
||||||
|
MODBIT(term.mode, !set, MODE_ECHO);
|
||||||
break;
|
break;
|
||||||
case 20: /* LNM -- Linefeed/new line */
|
case 20: /* LNM -- Linefeed/new line */
|
||||||
MODBIT(term.mode, set, MODE_CRLF);
|
MODBIT(term.mode, set, MODE_CRLF);
|
||||||
|
@ -1848,6 +1851,28 @@ tputtab(bool forward) {
|
||||||
tmoveto(x, term.c.y);
|
tmoveto(x, term.c.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
techo(char *buf, int len) {
|
||||||
|
for(; len > 0; buf++, len--) {
|
||||||
|
char c = *buf;
|
||||||
|
|
||||||
|
if(c == '\033') { /* escape */
|
||||||
|
tputc("^", 1);
|
||||||
|
tputc("[", 1);
|
||||||
|
} else if (c < '\x20') { /* control code */
|
||||||
|
if(c != '\n' && c != '\r' && c != '\t') {
|
||||||
|
c |= '\x40';
|
||||||
|
tputc("^", 1);
|
||||||
|
}
|
||||||
|
tputc(&c, 1);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (len)
|
||||||
|
tputc(buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tputc(char *c, int len) {
|
tputc(char *c, int len) {
|
||||||
uchar ascii = *c;
|
uchar ascii = *c;
|
||||||
|
@ -2679,7 +2704,7 @@ void
|
||||||
kpress(XEvent *ev) {
|
kpress(XEvent *ev) {
|
||||||
XKeyEvent *e = &ev->xkey;
|
XKeyEvent *e = &ev->xkey;
|
||||||
KeySym ksym;
|
KeySym ksym;
|
||||||
char buf[32], *customkey;
|
char xstr[31], buf[32], *customkey, *cp = buf;
|
||||||
int len, meta, shift, i;
|
int len, meta, shift, i;
|
||||||
Status status;
|
Status status;
|
||||||
|
|
||||||
|
@ -2688,7 +2713,7 @@ kpress(XEvent *ev) {
|
||||||
|
|
||||||
meta = e->state & Mod1Mask;
|
meta = e->state & Mod1Mask;
|
||||||
shift = e->state & ShiftMask;
|
shift = e->state & ShiftMask;
|
||||||
len = XmbLookupString(xw.xic, e, buf, sizeof(buf), &ksym, &status);
|
len = XmbLookupString(xw.xic, e, xstr, sizeof(xstr), &ksym, &status);
|
||||||
|
|
||||||
/* 1. shortcuts */
|
/* 1. shortcuts */
|
||||||
for(i = 0; i < LEN(shortcuts); i++) {
|
for(i = 0; i < LEN(shortcuts); i++) {
|
||||||
|
@ -2702,7 +2727,8 @@ kpress(XEvent *ev) {
|
||||||
|
|
||||||
/* 2. custom keys from config.h */
|
/* 2. custom keys from config.h */
|
||||||
if((customkey = kmap(ksym, e->state))) {
|
if((customkey = kmap(ksym, e->state))) {
|
||||||
ttywrite(customkey, strlen(customkey));
|
len = strlen(customkey);
|
||||||
|
memcpy(buf, customkey, len);
|
||||||
/* 2. hardcoded (overrides X lookup) */
|
/* 2. hardcoded (overrides X lookup) */
|
||||||
} else {
|
} else {
|
||||||
switch(ksym) {
|
switch(ksym) {
|
||||||
|
@ -2714,34 +2740,44 @@ kpress(XEvent *ev) {
|
||||||
sprintf(buf, "\033%c%c",
|
sprintf(buf, "\033%c%c",
|
||||||
IS_SET(MODE_APPKEYPAD) ? 'O' : '[',
|
IS_SET(MODE_APPKEYPAD) ? 'O' : '[',
|
||||||
(shift ? "dacb":"DACB")[ksym - XK_Left]);
|
(shift ? "dacb":"DACB")[ksym - XK_Left]);
|
||||||
ttywrite(buf, 3);
|
len = 3;
|
||||||
break;
|
break;
|
||||||
case XK_Insert:
|
case XK_Insert:
|
||||||
if(shift)
|
if(shift) {
|
||||||
selpaste();
|
selpaste();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memcpy(buf, xstr, len);
|
||||||
break;
|
break;
|
||||||
case XK_Return:
|
case XK_Return:
|
||||||
|
len = 0;
|
||||||
if(meta)
|
if(meta)
|
||||||
ttywrite("\033", 1);
|
*cp++ = '\033', len++;
|
||||||
|
|
||||||
if(IS_SET(MODE_CRLF)) {
|
*cp++ = '\r', len++;
|
||||||
ttywrite("\r\n", 2);
|
|
||||||
} else {
|
if(IS_SET(MODE_CRLF))
|
||||||
ttywrite("\r", 1);
|
*cp = '\n', len++;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
/* 3. X lookup */
|
/* 3. X lookup */
|
||||||
default:
|
default:
|
||||||
if(len > 0) {
|
if(len == 0)
|
||||||
if(meta && len == 1)
|
return;
|
||||||
ttywrite("\033", 1);
|
|
||||||
ttywrite(buf, len);
|
if (len == 1 && meta)
|
||||||
}
|
*cp++ = '\033';
|
||||||
|
|
||||||
|
memcpy(cp, xstr, len);
|
||||||
|
len = cp - buf + len;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ttywrite(buf, len);
|
||||||
|
if(IS_SET(MODE_ECHO))
|
||||||
|
techo(buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cmessage(XEvent *e) {
|
cmessage(XEvent *e) {
|
||||||
/* See xembed specs
|
/* See xembed specs
|
||||||
|
|
Loading…
Reference in New Issue