diff options
Diffstat (limited to 'userspace/xterm/terminal.c')
| -rw-r--r-- | userspace/xterm/terminal.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/userspace/xterm/terminal.c b/userspace/xterm/terminal.c index 60cd8b0..15fbd36 100644 --- a/userspace/xterm/terminal.c +++ b/userspace/xterm/terminal.c @@ -1,7 +1,11 @@ // https://en.wikipedia.org/wiki/ANSI_escape_code // http://en.wikipedia.org/wiki/VT52 // http://vt100.net/docs/vt520-rm/ +// https://invisible-island.net/xterm/terminfo.html // man 4 console_codes +// + +// AIMING TO BE A vt52? #include <stdint.h> #include <stdbool.h> @@ -49,6 +53,7 @@ typedef enum{ ecma48_blinkoff, ecma48_reverse_video_off, + // fg codes are 3x ecma48_fg_black =30, ecma48_fg_red, ecma48_fg_green, @@ -56,10 +61,12 @@ typedef enum{ ecma48_fg_blue, ecma48_fg_magenta, ecma48_fg_cyan, - ecma48_fg_white, + ecma48_fg_white, // 37 + ecma48_underscore_on, // set def color ecma48_underscore_off, // set def color + // bg codes are 4x ecma48_bg_black, //40 ecma48_bg_red, ecma48_bg_green, @@ -210,6 +217,7 @@ static void process_graphic_npar(terminal_tty *tty, terminal_settings s) case ecma48_fg_white: tty->fg=SCR_WHITE; break; + // bg case ecma48_bg_black: @@ -303,6 +311,7 @@ static void process_cup(terminal_tty *tty) } tty->npar=0; + tty->escaping=0; } static void process_graphic_npars(terminal_tty *tty) @@ -331,10 +340,8 @@ static void process_graphic_npars(terminal_tty *tty) } -static void reset(terminal_tty *tty) +static void clear(terminal_tty *tty) { - tty->bg=SCR_BLACK; - tty->fg=SCR_WHITE; for(int x=0;x<tty->width;x++) for(int y=0;y<tty->height;y++) @@ -360,7 +367,7 @@ terminal_tty terminal_init(term_out *screen,term_in *input) tty.set_lfnl=true; // tty.set_lfnl=false; - + // termios! tty.set_echo=true; tty.set_echo=false; @@ -375,12 +382,15 @@ terminal_tty terminal_init(term_out *screen,term_in *input) tty.x=0; tty.y=0; + tty.bg=SCR_BLACK; + tty.fg=SCR_WHITE; + tty.width=TERM_WIDTH; tty.height=TERM_HEIGHT; tty.reverse_video=false; - reset(&tty); + clear(&tty); return tty; } @@ -390,13 +400,10 @@ terminal_tty tty; terminal_tty* terminal_init_vesa() { - tout.put_char=vesa_console_put_char; tout.update_cursor=vesa_update_cursor; tty=(terminal_init(&tout,NULL)); return &tty; - - } // send one ASCII character to the terminal @@ -438,7 +445,7 @@ void terminal_put(terminal_tty *tty, uint8_t c) } } - else if(c==0x0D) // CR + else if(c==0x0D) // CR \r { tty->x=0; return; @@ -448,7 +455,7 @@ void terminal_put(terminal_tty *tty, uint8_t c) { for(uint32_t x=tty->x;x<tty->width;x++) { - set_char(tty,x,tty->y,' ',tty->fg,tty->bg); + // set_char(tty,x,tty->y,' ',tty->fg,tty->bg); } tty->y++; if(tty->set_lfnl)tty->x=0; @@ -468,7 +475,7 @@ void terminal_put(terminal_tty *tty, uint8_t c) { for(uint32_t x=tty->x;x<tty->width;x++) { - set_char(tty, x, tty->y, ' ', tty->fg, tty->bg); + set_char(tty, x, tty->y, ' ', tty->fg,tty->bg); } } // FOOL-TERM: clear to end of screen @@ -478,6 +485,7 @@ void terminal_put(terminal_tty *tty, uint8_t c) { set_char(tty, x, tty->y, ' ', tty->fg, tty->bg); } + for(uint32_t y=tty->y+1;y<tty->height;y++) { for(uint32_t x=0;x<tty->width;x++) @@ -520,9 +528,13 @@ void terminal_put(terminal_tty *tty, uint8_t c) /// - if(c=='c'){reset(tty);} // RESET + if(c=='c'){clear(tty);} // RESET - if(c=='D'){tty->y++;} // LINEFEED + if(c=='D'){tty->y++; + + tty->fg=SCR_WHITE; + tty->bg=SCR_BLACK; + } // LINEFEED if(c=='E'){tty->y++;tty->x=0;} //NEWLINE //if(c=='H'){} // SET TABSTOP: TODO @@ -534,7 +546,8 @@ void terminal_put(terminal_tty *tty, uint8_t c) { for(uint32_t x=0;x<tty->width;x++) { - uint32_t c=' '|tty->fg<<8|tty->bg<<16; + //uint32_t c=' '|tty->fg<<8|tty->bg<<16; + uint32_t c=' '|tty->fg<<8|SCR_BLACK<<16; if(y!=0) c=tty->data[index(tty,x,y-1)]; tty->data[index(tty,x,y)] = c; |
