From c9a6b0faecb76984eb51754f6d188a87be025e8f Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Mon, 22 Jul 2019 17:05:57 +0100 Subject: initial commit of dynamic screen size --- gramscii.c | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'gramscii.c') diff --git a/gramscii.c b/gramscii.c index 5e5a9b1..1223a76 100644 --- a/gramscii.c +++ b/gramscii.c @@ -10,6 +10,7 @@ #include #include #include +#include #define MOVE 0x00 #define BOX 0x01 @@ -27,8 +28,6 @@ #define DIR_HOR (DIR_R | DIR_L) #define DIR_VER (DIR_D | DIR_U) -#define WIDTH 100 -#define HEIGHT 25 #define NOFIX 0x0 #define FIX 0x1 @@ -52,7 +51,8 @@ #define MIN(x,y) (x) < (y) ? (x) : (y) #define MAX(x,y) (x) > (y) ? (x) : (y) -char screen[HEIGHT][WIDTH+1]; +char **screen; +int WIDTH, HEIGHT; int state; int dir; @@ -121,7 +121,7 @@ char* state_str(){ void status_bar(){ printf("\033[%d;1f\033[7m", HEIGHT+1); - printf("%100s", " "); + printf("%*s", WIDTH-1, ""); printf("\033[%d;1f\033[7m", HEIGHT+1); printf(" x:%3d y:%3d -- MODE:%4s HL:%c VL:%c CN:%c SP:%c EP:%c %10s", x, y, state_str(), line_h, line_v, corner, mark_st, mark_end, ""); @@ -132,12 +132,12 @@ void status_bar(){ printf("\033[0m"); } -char get_key(char *s){ +char get_key(char *msg){ printf("\033[%d;1f\033[7m", HEIGHT+1); - printf("%100s", " "); + printf("%*s", WIDTH, ""); printf("\033[%d;1f\033[7m", HEIGHT+1); - printf("%s ", s); + printf("%s", msg); printf("\033[0m"); return getchar(); } @@ -145,7 +145,7 @@ char get_key(char *s){ void get_string(char *msg, char *s, int sz){ printf("\033[%d;1f\033[7m", HEIGHT+1); - printf("%100s", " "); + printf("%*s", WIDTH, ""); printf("\033[%d;1f\033[7m", HEIGHT+1); /* We must activate echo now */ t3 = t2; @@ -235,14 +235,6 @@ void reset_styles(){ } -void init_screen(){ - int i; - for(i=0; i