1 /* display.c -- display management stuff
3 * hackbard@hackdaworld.dyndns.org
11 int display_init(t_display *display,int outfd) {
16 if(ioctl(1,TIOCGWINSZ,&ws)==-1) {
17 perror("[display] ioctl call");
20 display->max_x=ws.ws_col;
21 display->max_y=ws.ws_row;
25 dprintf(display->outfd,"[display] initializing display, w: %02d / h: %02d\n",
28 /* allocating 'screen' buffer */
29 if((display->screen=(char *)malloc(display->max_x*display->max_y))
31 perror("[display] malloc call");
34 /* space as display pixel default */
35 memset(display->screen,0x20,display->max_x*display->max_y);
48 int display_draw(t_display *display) {
55 mvprintw(0,0,"%s",display->screen);
56 //for(y=0;y<display->max_y;y++)
57 // for(x=0;x<display->max_x;x++)
58 // mvaddch(y,x,*(display->screen+y*display->max_x+x));
61 for(y=0;y<display->max_y;y++) {
62 for(x=0;x<display->max_x;x++)
63 fprintf(stderr,"%c",*(display->screen+y*display->max_x+x));
71 int display_draw_until_line(t_display *display,int line) {
77 for(x=0;x<display->max_x;x++)
78 mvaddch(y,x,*(display->screen+y*display->max_x+x));
83 for(x=0;x<display->max_x;x++)
84 fprintf(stderr,"%c",*(display->screen+y*display->max_x+x));
92 int display_set_cursor(t_display *display,int x,int y) {
102 int display_clear_screen(t_display *display) {
104 memset(display->screen,0x20,display->max_x*display->max_y);
109 int display_shutdown(t_display *display) {
115 free(display->screen);
117 dprintf(display->outfd,"[display] shutdown\n");
122 int display_line(t_display *display,int X,int Y,int X_,int Y_,char sym) {
131 *(display->screen+y*display->max_x+x)=sym;
137 int display_string(t_display *display,int x,int y,char *string,int len) {
139 if(len>display->max_x-x) return D_INV_STRING_LEN;
141 memcpy(display->screen+y*display->max_x+x,string,len);
146 int display_string_vert(t_display *display,int x,int y,char *string,int len) {
150 if(len>display->max_y-y) return D_INV_STRING_LEN;
151 for(i=y*display->max_x+x;i<(y+len)*display->max_x+x;i+=display->max_x)
152 *(display->screen+i)=*(string++);