From: hackbard Date: Wed, 19 May 2004 17:25:08 +0000 (+0000) Subject: display api improvements - to be continued X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb2eedc347c7457678118762799806db07d5d200;p=my-code%2Fivac.git display api improvements - to be continued --- diff --git a/src/display.c b/src/display.c index 914ab63..89c6472 100644 --- a/src/display.c +++ b/src/display.c @@ -11,12 +11,17 @@ int display_init(t_display *display) { puts("[display] initializing display ..."); /* init stuff next .. */ + display->max_x=atoi(getenv("COLUMNS")); + display->max_y=atoi(getenv("LINES")); return D_SUCCESS; } int display_refresh(t_display *display) { + display->max_x=atoi(getenv("COLUMNS")); + display->max_y=atoi(getenv("LINES")); + return D_SUCCESS; } @@ -26,3 +31,21 @@ int display_shutdown(t_display *display) { return D_SUCCESS; } + +int display_term_line(t_display *display,char sym) { + + int i; + + for(i=0;imax_x;i++) printf("%c",sym); + printf("\n"); + + return D_SUCCESS; +} + +int display_term_string(t_display *display,char *string) { + + /* to be continued ... */ + + return D_SUCCESS; +} + diff --git a/src/display.h b/src/display.h index 113e892..a12f380 100644 --- a/src/display.h +++ b/src/display.h @@ -2,11 +2,18 @@ /* includes */ #include +#include /* defines */ #define D_SUCCESS 1 #define D_ERROR -1 +#define MAX_TERM_STRING 64 + +#define CENTERED (1<<0) +#define LEFT (1<<1) +#define RIGHT (1<<2) + /* display specific variables */ typedef struct s_display { int max_x; @@ -19,3 +26,5 @@ typedef struct s_display { int display_init(t_display *display); int display_refresh(t_display *display); int display_shutdown(t_display *display); +int display_term_line(t_display *display,char sym); +int display_term_string(t_display *display,char *string); diff --git a/src/ivac.c b/src/ivac.c index 44e831c..60338ee 100644 --- a/src/ivac.c +++ b/src/ivac.c @@ -130,7 +130,13 @@ int main(int argc,char **argv) { audio_setup(&(ivac.audio)); /* display */ - ivac_display(&(ivac.display)); +#ifdef XXX_GUI + /* "constant" graphics */ + ivac_display_head(&ivac); + ivac_display_box(&ivac); + ivac_display_console(&ivac); +#endif + ivac_display(&ivac); /* start event system - callbacks used: ivac_event_cb + ivac_regular_cb */ event_start(&(ivac.event),(void *)&ivac,ivac_event_cb,ivac_regular_cb); @@ -273,7 +279,7 @@ int ivac_event_cb(t_event *event,void *ptr) { event_math(ivac->net.connection[channel].fd,event,READ,ADD); ivac_send_info(channel,ivac); } - ivac_display_content(ivac); + ivac_display(ivac); } /* wait for user info */ @@ -287,7 +293,7 @@ int ivac_event_cb(t_event *event,void *ptr) { sprintf(c_str,"channel %02d: broken pipe - disconnected",channel); ivac_add_to_monitor(ivac,c_str); } - ivac_display_content(ivac); + ivac_display(ivac); } } } @@ -320,7 +326,7 @@ int ivac_parse_command(t_input *input,void *ptr) { data=input->content; valid=0; - /* refresh prompt content only! */ + /* refresh prompt content only */ ivac_display_prompt_content(ivac); /* parse command routines */ @@ -453,7 +459,7 @@ int ivac_parse_command(t_input *input,void *ptr) { ivac_add_to_monitor(ivac,c_str); /* refresh whole display content */ - ivac_display_content(ivac); + ivac_display(ivac); /* delete content buffer + reset counter */ memset(input->content,0,input->c_count-1); @@ -464,16 +470,26 @@ int ivac_parse_command(t_input *input,void *ptr) { return SUCCESS; } -int ivac_display_head(t_display *display) { +int ivac_display_head(t_ivac *ivac) { - puts("#########################################################"); +#ifndef XXX_GUI + display_term_line(&(ivac->display),'#'); puts("##### ivac - - Copyright (C) 2004 Frank Zirkelbach #####"); puts("#########################################################"); +#endif return SUCCESS; } -int ivac_display_box(t_display *display) { +int ivac_display_box(t_ivac *ivac) { + +#ifndef XXX_GUI + puts("---------------------------------------------------------------------"); + printf("username: %s, capabilities: %02x|%04x\n",ivac->username,ivac->g_cap, + ivac->av_cap); + puts("---------------------------------------------------------------------"); + puts("connections:"); +#endif return SUCCESS; } @@ -487,10 +503,26 @@ int ivac_display_box_content(t_ivac *ivac) { if(ivac->challenger[channel].name[0]==0) strcpy(ivac->challenger[channel].name,""); +#ifndef XXX_GUI + for(channel=0;channelnet.connection[channel].status&C_INFO_A) + printf("channel %02d: %s:%d, status: %02x, name: %s\n",channel, + ivac->net.connection[channel].ip, + ivac->net.connection[channel].port, + ivac->net.connection[channel].status, + ivac->challenger[channel].name); + } +#endif + return SUCCESS; } -int ivac_display_console(t_display *display) { +int ivac_display_console(t_ivac *ivac) { + +#ifndef XXX_GUI + puts("---------------------------------------------------------------------"); + puts("console messages:"); +#endif return SUCCESS; } @@ -499,54 +531,58 @@ int ivac_display_console_content(t_ivac *ivac) { int i; +#ifndef XXX_GUI for(i=0;iconsole[i]); + printf("| %s\n",ivac->console[i]); +#endif return SUCCESS; } -int ivac_display_prompt(t_display *display) { +int ivac_display_prompt(t_ivac *ivac) { + +#ifndef XXX_GUI + puts("---------------------------------------------------------------------"); + printf("prompt: "); +#endif return SUCCESS; } int ivac_display_prompt_content(t_ivac *ivac) { +#ifndef XXX_GUI printf("%c",ivac->input.content[ivac->input.c_count-1]); fflush(NULL); +#endif return SUCCESS; } -int ivac_display(t_display *display) { +int ivac_display(t_ivac *ivac) { int x,y; +#ifndef XXX_GUI /* display head */ - ivac_display_head(display); + ivac_display_head(ivac); /* display box */ - ivac_display_box(display); - - /* display console */ - ivac_display_console(display); - - /* display command prompt */ - ivac_display_prompt(display); - - return SUCCESS; -} - -int ivac_display_content(t_ivac *ivac) { - - /* display box content */ + ivac_display_box(ivac); +#endif ivac_display_box_content(ivac); - /* display console content */ +#ifndef XXX_GUI + /* display console */ + ivac_display_console(ivac); +#endif ivac_display_console_content(ivac); - /* display prompt content */ - ivac_display_prompt_content(ivac); +#ifndef XXX_GUI + /* display command prompt */ + ivac_display_prompt(ivac); +#endif + fflush(NULL); return SUCCESS; } diff --git a/src/ivac.h b/src/ivac.h index 2bd69c5..af2932b 100644 --- a/src/ivac.h +++ b/src/ivac.h @@ -73,15 +73,14 @@ int ivac_receive_info(int channel,t_ivac *ivac); int ivac_event_cb(t_event *event,void *ptr); int ivac_regular_cb(t_event *event,void *ptr); int ivac_parse_command(t_input *input,void *ptr); -int ivac_display_head(t_display *display); -int ivac_display_box(t_display *display); +int ivac_display_head(t_ivac *ivac); +int ivac_display_box(t_ivac *ivac); int ivac_display_box_content(t_ivac *ivac); -int ivac_display_console(t_display *display); +int ivac_display_console(t_ivac *ivac); int ivac_display_console_content(t_ivac *ivac); -int ivac_display_prompt(t_display *display); +int ivac_display_prompt(t_ivac *ivac); int ivac_display_prompt_content(t_ivac *ivac); -int ivac_display(t_display *display); -int ivac_display_content(t_ivac *ivac); +int ivac_display(t_ivac *ivac); int ivac_add_to_monitor(t_ivac *ivac,char *msg); #endif