📄 vt.c
字号:
/* * h - set various options. */ case 'h': if(noperand == 1){ switch(operand[0]){ default: break; case 20: /* set newline mode */ ttystate[cs->raw].nlcr = 0; break; case 30: /* screen visible (? not supported through VT220) */ break; } }else while(--noperand > 0){ switch(operand[noperand]){ default: break; case 1: /* set cursor keys to send application function: ESC O A..D */ break; case 2: /* set ANSI */ break; case 3: /* set 132 columns */ setdim(-1, 132); break; case 4: /* set smooth scrolling */ break; case 5: /* set screen to reverse video (not implemented) */ break; case 6: /* set origin to relative */ originrelative = 1; x = 0; y = yscrmin; break; case 7: /* set auto-wrap mode */ wraparound = 1; break; case 8: /* set auto-repeat mode */ break; case 9: /* set interlacing mode */ break; case 25: /* text cursor on (VT220) */ cursoron = 1; break; } } break; /* * m - change character attrs. */ case 'm': setattr(noperand, operand); break; /* * n - request various reports */ case 'n': switch(operand[0]){ case 5: /* status */ sendnchars2(4, "\033[0n"); /* terminal ok */ break; case 6: /* cursor position */ sendnchars2(sprint(buf, "\033[%d;%dR", originrelative ? y+1 - yscrmin : y+1, x+1), buf); break; } break; /* * q - turn on list of LEDs; turn off others. */ case 'q': break; /* * r - change scrolling region. operand[0] is * min scrolling region and operand[1] is max * scrolling region. */ case 'r': yscrmin = 0; yscrmax = ymax; switch(noperand){ case 2: yscrmax = operand[1]-1; if(yscrmax > ymax) yscrmax = ymax; case 1: yscrmin = operand[0]-1; if(yscrmin < 0) yscrmin = 0; } x = 0; y = yscrmin; break; /* * x - report terminal parameters */ case 'x': sendnchars2(20, "\033[3;1;1;120;120;1;0x"); break; /* * y - invoke confidence test */ case 'y': break; /* * A - cursor up. */ case 'e': case 'A': fixops(operand); y -= operand[0]; if(y < yscrmin) y = yscrmin; olines -= operand[0]; if(olines < 0) olines = 0; break; /* * B - cursor down */ case 'B': fixops(operand); y += operand[0]; if(y > yscrmax) y=yscrmax; break; /* * C - cursor right */ case 'a': case 'C': fixops(operand); x += operand[0]; /* * VT-100-UG says not to go past the * right margin. */ if(x > xmax) x = xmax; break; /* * D - cursor left */ case 'D': fixops(operand); x -= operand[0]; if(x < 0) x = 0; break; /* * G - cursor to column */ case '\'': case 'G': fixops(operand); x = operand[0] - 1; if(x > xmax) x = xmax; break; /* * H and f - cursor motion. operand[0] is row and * operand[1] is column, origin 1. */ case 'H': case 'f': fixops(operand+1); x = operand[1] - 1; if(x > xmax) x = xmax; /* fallthrough */ /* * d - cursor to line n (xterm) */ case 'd': fixops(operand); y = operand[0] - 1; if(originrelative){ y += yscrmin; if(y > yscrmax) y = yscrmax; }else{ if(y > ymax) y = ymax; } break; /* * J - clear some or all of the display. */ case 'J': switch (operand[0]) { /* * operand 2: whole screen. */ case 2: clear(Rpt(pt(0, 0), pt(xmax+1, ymax+1))); break; /* * operand 1: start of screen to active position, inclusive. */ case 1: clear(Rpt(pt(0, 0), pt(xmax+1, y))); clear(Rpt(pt(0, y), pt(x+1, y+1))); break; /* * Default: active position to end of screen, inclusive. */ default: clear(Rpt(pt(x, y), pt(xmax+1, y+1))); clear(Rpt(pt(0, y+1), pt(xmax+1, ymax+1))); break; } break; /* * K - clear some or all of the line. */ case 'K': switch (operand[0]) { /* * operand 2: whole line. */ case 2: clear(Rpt(pt(0, y), pt(xmax+1, y+1))); break; /* * operand 1: start of line to active position, inclusive. */ case 1: clear(Rpt(pt(0, y), pt(x+1, y+1))); break; /* * Default: active position to end of line, inclusive. */ default: clear(Rpt(pt(x, y), pt(xmax+1, y+1))); break; } break; /* * P - delete character(s) from right of cursor (xterm) */ case 'P': fixops(operand); i = x + operand[0]; draw(screen, Rpt(pt(x, y), pt(xmax+1, y+1)), screen, nil, pt(i, y)); clear(Rpt(pt(xmax-operand[0], y), pt(xmax+1, y+1))); break; /* * @ - insert blank(s) to right of cursor (xterm) */ case '@': fixops(operand); i = x + operand[0]; draw(screen, Rpt(pt(i, y), pt(xmax+1, y+1)), screen, nil, pt(x, y)); clear(Rpt(pt(x, y), pt(i, y+1))); break; /* * X - erase character(s) at cursor and to the right (xterm) */ case 'X': fixops(operand); i = x + operand[0]; clear(Rpt(pt(x, y), pt(i, y+1))); break; /* * L - insert a line at cursor position (VT102 and later) */ case 'L': fixops(operand); for(i = 0; i < operand[0]; ++i) scroll(y, yscrmax, y+1, y); break; /* * M - delete a line at cursor position (VT102 and later) */ case 'M': fixops(operand); for(i = 0; i < operand[0]; ++i) scroll(y+1, yscrmax+1, y, yscrmax); break; /* * S,T - scroll up/down (xterm) */ case 'T': fixops(operand); for(i = 0; i < operand[0]; ++i) scroll(yscrmin, yscrmax, yscrmin+1, yscrmin); break; case 'S': fixops(operand); for(i = 0; i < operand[0]; ++i) scroll(yscrmin+1, yscrmax+1, yscrmin, yscrmin); break; case '=': /* ? not supported through VT220 */ number(buf, nil); switch(buf[0]) { case 'h': case 'l': break; } break; /* * Anything else we ignore for now... */ default:print("unknown escape2 '%c' (0x%x)\n", dch, dch); break; } break; /* * Collapse multiple '\033' to one. */ case '\033': peekc = '\033'; break; /* set title */ case ']': /* it's actually <esc> ] num ; title <bel> */ { int ch, fd; number(buf, nil); i = 0; while((ch = get_next_char()) != '\a') if(i < sizeof buf) buf[i++] = ch; fd = open("/dev/label", OWRITE); write(fd, buf, i); close(fd); } break; /* * Ignore other commands. */ default:print("unknown command '%c' (0x%x)\n", dch, dch); break; } break; default: /* ordinary char */Default: if(isgraphics && gmap[(uchar) buf[0]]) buf[0] = gmap[(uchar) buf[0]]; /* line wrap */ if (x > xmax){ if(wraparound){ x = 0; newline(); }else{ continue; } } n = 1; c = 0; while (!cs->raw && host_avail() && x+n<=xmax && n<BUFS && (c = get_next_char())>=' ' && c<'\177') { buf[n++] = c; c = 0; } buf[n] = 0;// clear(Rpt(pt(x,y), pt(x+n, y+1))); drawstring(pt(x, y), buf, attr); x += n; peekc = c; break; } }}static voidsetattr(int argc, int *argv){ int i; for(i=0; i<argc; i++) { switch(argv[i]) { case 0: attr = defattr; fgcolor = fgdefault; bgcolor = bgdefault; break; case 1: attr |= THighIntensity; break; case 4: attr |= TUnderline; break; case 5: attr |= TBlink; break; case 7: attr |= TReverse; break; case 8: attr |= TInvisible; break; case 22: attr &= ~THighIntensity; break; case 24: attr &= ~TUnderline; break; case 25: attr &= ~TBlink; break; case 27: attr &= ~TReverse; break; case 28: attr &= ~TInvisible; break; case 30: /* black */ case 31: /* red */ case 32: /* green */ case 33: /* brown */ case 34: /* blue */ case 35: /* purple */ case 36: /* cyan */ case 37: /* white */ fgcolor = colors[argv[i]-30]; break; case 39: fgcolor = fgdefault; break; case 40: /* black */ case 41: /* red */ case 42: /* green */ case 43: /* brown */ case 44: /* blue */ case 45: /* purple */ case 46: /* cyan */ case 47: /* white */ bgcolor = colors[argv[i]-40]; break; case 49: bgcolor = bgdefault; break; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -