diff options
Diffstat (limited to 'userspace/xterm')
| -rw-r--r-- | userspace/xterm/terminal.c | 17 | ||||
| -rw-r--r-- | userspace/xterm/vesa.c | 6 | ||||
| -rw-r--r-- | userspace/xterm/xterm.c | 53 |
3 files changed, 45 insertions, 31 deletions
diff --git a/userspace/xterm/terminal.c b/userspace/xterm/terminal.c index 15fbd36..07c21cf 100644 --- a/userspace/xterm/terminal.c +++ b/userspace/xterm/terminal.c @@ -86,6 +86,7 @@ typedef struct term_out_struct void (*update_cursor)(uint32_t col,uint32_t row); }term_out; +// NOT USED (TODO?) typedef struct term_in_struct { void (*put_char)(uint8_t c); @@ -398,13 +399,6 @@ terminal_tty terminal_init(term_out *screen,term_in *input) term_out tout; 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 void terminal_put(terminal_tty *tty, uint8_t c) @@ -655,3 +649,12 @@ void terminal_put(terminal_tty *tty, uint8_t c) tty->screen->update_cursor(tty->x,tty->y); return; } + +// initialize terminal for vesa +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; +} diff --git a/userspace/xterm/vesa.c b/userspace/xterm/vesa.c index b6cec2f..6d61498 100644 --- a/userspace/xterm/vesa.c +++ b/userspace/xterm/vesa.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <malloc.h> #include "vesa.h" +#include "../newcalls.h" void PutFont(char c, int x,int y, int color_fg,int color_bg); @@ -62,7 +63,6 @@ void vesa_update_cursor(uint32_t col,uint32_t row) 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); } @@ -194,6 +194,10 @@ void PutFont(char c, int x,int y, int color_fg,int color_bg) else PutPixel(posx,posy,color_bg); } } + + // invalidate area + _gui_inval((x<<16)|(y),(font_width+1<<16)|(font_height+1)); + /* for(int y=0;y<vesaYres;y++) { diff --git a/userspace/xterm/xterm.c b/userspace/xterm/xterm.c index b333794..5540ac9 100644 --- a/userspace/xterm/xterm.c +++ b/userspace/xterm/xterm.c @@ -8,49 +8,56 @@ char *argv1[]={"xterm","/bin/fsh",0}; int main(int argc, char **argv) { + // we need a window _gui_win(); + // basically loads font and sets a few constants vesa_init(NULL); + + // init tty and set vesa output funcs void *tty=terminal_init_vesa(); //int xterm_in[2]; int xterm_out[2]; //_pipe(xterm_in); - _pipe(xterm_out); + pipe(xterm_out); - int pid=_fork(); + int pid=fork(); - if(!pid) + if(!pid) // child { int tty_fd=_open("/dev/tty"); //_close(xterm_in[1]); - _close(xterm_out[0]); + close(xterm_out[0]); - _dup2(tty_fd,0);// stdin - _dup2(xterm_out[1],1);// stdout - _dup2(xterm_out[1],2);// stderr + dup2(tty_fd,0);// stdin + dup2(xterm_out[1],1);// stdout + dup2(xterm_out[1],2);// stderr // replace process with our foolshell or whatever if(argc==1)_execve(argv1[1],argv1,environ); - _execve(argv[1],argv,environ); + execve(argv[1],argv,environ); - while(1); + printf("unable to execve %s",argv[1]); // never reached } - - //_close(xterm_in[0]); - _close(xterm_out[1]); - - //_dup2(xterm_in[1],0); // compositor writes here. - //_close(xterm_in[1]); - - while(1) - { - char buf[1]; - - _read(xterm_out[0],buf,1); // show what foolshell writes to its stdout/stderr - terminal_put(tty,buf[0]); - _gui_rect(); + else{ + + //_close(xterm_in[0]); + close(xterm_out[1]); + + //_dup2(xterm_in[1],0); // compositor writes here. + //_close(xterm_in[1]); + + // TODO quit if execve fails or child exits... + while(1) + { + char buf[1]; + + read(xterm_out[0],buf,1); // show what foolshell writes to its stdout/stderr + terminal_put(tty,buf[0]); + } } + } |
