summaryrefslogtreecommitdiff
path: root/userspace/xterm
diff options
context:
space:
mode:
Diffstat (limited to 'userspace/xterm')
-rw-r--r--userspace/xterm/Makefile3
-rw-r--r--userspace/xterm/terminal.c43
-rw-r--r--userspace/xterm/vesa.c20
3 files changed, 48 insertions, 18 deletions
diff --git a/userspace/xterm/Makefile b/userspace/xterm/Makefile
index b6bac6e..fdec016 100644
--- a/userspace/xterm/Makefile
+++ b/userspace/xterm/Makefile
@@ -1,6 +1,7 @@
CC=i686-foolos-gcc
-AS=i686-foolos-as
+
+CFLAGS = -ggdb -O0 # best gdb debugging experience
xterm: vesa.o terminal.o
clean:
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;
diff --git a/userspace/xterm/vesa.c b/userspace/xterm/vesa.c
index 7f22a5f..745e7fb 100644
--- a/userspace/xterm/vesa.c
+++ b/userspace/xterm/vesa.c
@@ -29,6 +29,10 @@ static int console_y;
static int console_lines;
static int console_cols;
+static uint8_t termdata[80*24];
+static uint8_t termdata_bg[80*24];
+static uint8_t termdata_fg[80*24];
+
// same colors as in screen.h
static uint32_t cols[] = {
0x0, // black
@@ -52,14 +56,26 @@ static uint32_t cols[] = {
/** update cursor position */
void vesa_update_cursor(uint32_t col,uint32_t row)
{
+ int oldx=console_x;
+ int oldy=console_y;
+
console_x=col;
console_y=row;
+
+
+ vesa_console_put_char(termdata[oldy*80+oldx],termdata_bg[oldy*80+oldx],termdata_fg[oldy*80+oldx],oldx,oldy);
+ vesa_console_put_char(termdata[row*80+col],termdata_bg[row*80+col],termdata_fg[row*80+col],col,row);
}
/** put char */
void vesa_console_put_char(uint8_t c,uint8_t color_bg, uint8_t color_fg, uint32_t x, uint32_t y)
{
- PutFont(c, x,y, cols[color_bg],cols[color_fg]);
+ termdata[y*80+x]=c;
+ termdata_bg[y*80+x]=color_bg;
+ termdata_fg[y*80+x]=color_fg;
+
+ if(x==console_x&&y==console_y)PutFont(c, x,y, cols[color_fg],cols[color_bg]);
+ else PutFont(c, x,y, cols[color_bg],cols[color_fg]);
}
//
@@ -88,7 +104,7 @@ uint32_t vesa_init(char *fontname)
FILE *f;
//if(fontname==NULL)f=fopen("/doc/fonts/binfont.bin","r");
//if(fontname==NULL)f=fopen("/doc/fonts/tinyfont.bin","r");
- if(fontname==NULL)f=fopen("/doc/fonts/binfont_v2.bin","r");
+ if(fontname==NULL)f=fopen("/doc/fonts/envypn7x13.bin","r");
fread(&font_width,1,1,f);
fread(&font_height,1,1,f);