/* Screen.c by Nathan Hellweg */ #include #include #include #include #include #include"screen.h" #define min(a,b) ((a)<(b)?(a):(b)) int Scrn_state=0; char *tparm(); char *getenv(); int **Scrn_Buffer; int **Scrn_Image; int Rows; int Cols; int cur_y; int cur_x; int cur_state; struct termios termios_old; void move_cur(int y, int x) { char *s; if(!cursor_address) { fprintf(debug,"Cursor motion string not set"); exit(1); } s=tparm(cursor_address,y,x); putp(s); } void cls() { if(clear_screen == NULL){ fprintf(debug,"Clear Scrn not set"); exit(1); } putp(clear_screen); } int terminit() { char *term; int outc(); int status; int i,j; char *s; /*Get term type */ if((term=getenv("TERM"))==NULL) { fprintf(stderr,"TERM is not set"); exit(1); } setupterm(term,1,&status); if(status!=1){ fprintf(stderr,"Error in setupterm"); exit(1); } /* clear Scrn */ cls(); Cols=columns; Rows=lines; return(1); } int Buff_Init() { int i,j; Scrn_Buffer=(int **)malloc(sizeof(int *)*Rows); Scrn_Image=(int **)malloc(sizeof(int *)*Rows); for(i=0;i=Rows||x<0||x>=Cols) return; Scrn_Buffer[y][x]=c; } void Scrn_Redraw() { int i,j; for(i=0;i=Rows||x>=Cols) return; if(y!=cur_y||x!=cur_x) Scrn_Move(y,x); if(state(c)!=state(cur_state)){ /* fprintf(debug,"Changed states from %d to %d\n",state(cur_state),state(c)); */ Scrn_State(state(c)); } putchar(c); cur_x++; if(cur_x>=Cols) Scrn_Move(cur_y+1,0); }