From: Alan Cox Date: Wed, 10 Jun 2015 22:22:35 +0000 (+0100) Subject: vt: add bits for attribute setting/reporting X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f57a87ec8089e7803206af2b159b4eef35cae26b;p=FUZIX.git vt: add bits for attribute setting/reporting Done with a single escape code to make the parsing tiny. It's then up to the platform what if anything to offer, but if nothing is supported then the platform needs the vtattr_cap byte defining. --- diff --git a/Kernel/include/tty.h b/Kernel/include/tty.h index 2218fe8b..1ca66620 100644 --- a/Kernel/include/tty.h +++ b/Kernel/include/tty.h @@ -143,6 +143,7 @@ struct termios { #define KBMAPGET 0x21 #define VTSIZE 0x22 #define KBSETTRANS 0x23 +#define VTATTRS 0x24 /* Character Input Queue size */ #define TTYSIZ 132 diff --git a/Kernel/include/vt.h b/Kernel/include/vt.h index ed87d166..9509a735 100644 --- a/Kernel/include/vt.h +++ b/Kernel/include/vt.h @@ -19,6 +19,15 @@ struct vt_switch { uint8_t vtmode; + uint8_t vtattr; +#define VTA_INVERSE 1 +#define VTA_UNDERLINE 2 +#define VTA_ITALIC 4 +#define VTA_FLASH 8 +#define VTA_BOLD 16 +#define VTA_OVERSTRIKE 32 + /* 64 is set to ensure a valid normal character */ +#define VTA_NOCURSOR 128 signed char cursorx; signed char cursory; signed char ncursory; @@ -41,5 +50,6 @@ void plot_char(int8_t y, int8_t x, uint16_t c); void do_beep(void); int vt_ioctl(uint8_t minor, uarg_t op, char *ptr); int vt_inproc(uint8_t minor, unsigned char c); +extern uint8_t vtattr_cap; -#endif \ No newline at end of file +#endif diff --git a/Kernel/vt.c b/Kernel/vt.c index 1329df0f..2c6eb0b2 100644 --- a/Kernel/vt.c +++ b/Kernel/vt.c @@ -39,11 +39,24 @@ * This code can be banked on its own. If you touch it on Z80 make * very sure you inspect the asm output for calls to compiler helpers * and don't add any. - * + * + * Possible VT extensions to look at + * - Esc-L Insert blank line, move lines below down + * - ESC-M Delete cursor line, move up blank bottom + * - Colour setting (Atari ST uses esc b/c) but we need + * more flexibility and border + * - ESC-d erase start to cursor inclusive + * - ESC-j save cursor y/x + * - ESC-k restore cursor + * - ESC-l erase line, cursor to left + * - ESC-o erase from start of line to cursor (inclusive) + * + * Would tty be a better graphics interface than direct ? Probably not ? */ static uint8_t vtmode; +uint8_t vtattr; static signed char cursorx; static signed char cursory = VT_INITIAL_LINE; static signed char ncursory; @@ -153,7 +166,8 @@ static int escout(unsigned char c) } if (c == 'Y') return 2; - + if (c == 'a') + return 4; return 0; } @@ -176,13 +190,17 @@ void vtoutput(unsigned char *p, unsigned int len) ncursory = c - ' '; vtmode++; continue; - } else { + } else if (vtmode == 3) { int ncursorx = c - ' '; if (ncursory >= 0 && ncursorx <= VT_BOTTOM) cursory = ncursory; if (ncursorx >= 0 && ncursorx <= VT_RIGHT) cursorx = ncursorx; vtmode = 0; + } else { + vtattr = c; + vtmode = 0; + continue; } } cursor_on(cursory, cursorx); @@ -210,6 +228,8 @@ int vt_ioctl(uint8_t minor, uarg_t request, char *data) #endif case VTSIZE: return VT_HEIGHT << 8 | VT_WIDTH; + case VTATTRS: + return vtattr_cap; } } return tty_ioctl(minor, request, data); @@ -259,6 +279,7 @@ void vtinit(void) void vt_save(struct vt_switch *vt) { vt->vtmode = vtmode; + vt->vtattr = vtattr; vt->cursorx = cursorx; vt->cursory = cursory; vt->ncursory = ncursory; @@ -267,6 +288,7 @@ void vt_save(struct vt_switch *vt) void vt_load(struct vt_switch *vt) { vtmode = vt->vtmode; + vtattr = vt->vtattr; cursorx = vt->cursorx; cursory = vt->cursory; ncursory = vt->ncursory;