vt: fix xterm cursor keys

This commit is contained in:
cinap_lenrek 2017-04-22 18:01:49 +02:00
parent c5b2927250
commit 5d7a77cf57
3 changed files with 22 additions and 9 deletions

View file

@ -54,6 +54,7 @@ extern void newline(void);
extern int get_next_char(void);
extern void ringbell(void);
extern int number(Rune *, int *);
extern void shift(int,int,int,int);
extern void scroll(int,int,int,int);
extern void backup(int);
extern void sendnchars(int, char *);

View file

@ -214,7 +214,7 @@ initialize(int argc, char **argv)
fontname = nil;
term = "vt100";
fk = vt100fk;
blkbg = nocolor = 0;
blkbg = 0;
rflag = 0;
attr = defattr;
ARGBEGIN{
@ -315,8 +315,9 @@ drawscreen(void)
uchar c, *ap, *cp;
Rune *rp;
/* draw background */
draw(screen, screen->r, bgcolor, nil, ZP);
/* draw background */
for(y = 0; y <= ymax; y++){
for(x = 0; x <= xmax; x += n){
cp = onscreenc(x, y);
@ -982,6 +983,18 @@ pos(Point pt)
return pt;
}
void
shift(int x1, int y, int x2, int w)
{
if(x1+w > xmax+1)
w = xmax+1 - x1;
if(x2+w > xmax+1)
w = xmax+1 - x2;
memmove(onscreenr(x1, y), onscreenr(x2, y), w*sizeof(Rune));
memmove(onscreena(x1, y), onscreena(x2, y), w);
memmove(onscreenc(x1, y), onscreenc(x2, y), w);
}
void
scroll(int sy, int ly, int dy, int cy) /* source, limit, dest, which line to clear */
{

View file

@ -68,10 +68,10 @@ struct funckey vt220fk[NKEYS] = {
struct funckey xtermfk[NKEYS] = {
{ "page up", "\033[5~", },
{ "page down", "\033[6~", },
{ "up key", "\033[A", },
{ "down key", "\033[B", },
{ "left key", "\033[D", },
{ "right key", "\033[C", },
{ "up key", "\033OA", },
{ "down key", "\033OB", },
{ "left key", "\033OD", },
{ "right key", "\033OC", },
{ "F1", "\033OP", },
{ "F2", "\033OQ", },
{ "F3", "\033OR", },
@ -326,7 +326,6 @@ emulate(void)
case 'Z':
Ident:
sendnchars(7, "\033[?1;2c"); /* VT100 with AVO option */
// sendnchars(5, "\033[?6c"); /* VT102 (insert/delete-char, etc.) */
break;
/*
@ -734,7 +733,7 @@ emulate(void)
case 'P':
fixops(operand);
i = x + operand[0];
draw(screen, Rpt(pt(x, y), pt(xmax+1, y+1)), screen, nil, pt(i, y));
shift(x, y, i, xmax+1 - i);
clear(xmax-operand[0], y, xmax+1, y+1);
break;
@ -744,7 +743,7 @@ emulate(void)
case '@':
fixops(operand);
i = x + operand[0];
draw(screen, Rpt(pt(i, y), pt(xmax+1, y+1)), screen, nil, pt(x, y));
shift(i, y, x, xmax+1 - i);
clear(x, y, i, y+1);
break;