From 0adbc2a776c36b736bb5acb7184ba559d9428bc4 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Fri, 26 Jul 2019 22:13:33 +0100 Subject: towards dynamic screen management --- Makefile | 5 +++-- TODO | 3 +-- gramscii.c | 67 +++++++++++++++++++++++++++++++++++++++++--------------------- 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index a59ead3..55959ce 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,9 @@ options: @echo "-+-+-+-+-+-+-+-+-+-+-" -gramscii: ${INC} - +gramscii: ${SRC} ${INC} + $(CC) $(CFLAGS) -o gramscii ${SRC} + clean: @echo cleaning @rm -f $(SRC:.c=) diff --git a/TODO b/TODO index f6087c7..7b324b8 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,5 @@ + optimize redraws (redraw only the modified rectangle) -- change screen management (i.e., dynamic array of lines) ++ change screen management (i.e., dynamic array of lines) - add screen geometry option (-g 25x80?) - read file at point - read output of command (!) @@ -48,4 +48,3 @@ * set different line styles (done for hl, vl, corner) * add status bar * implement box - diff --git a/gramscii.c b/gramscii.c index 3bed08b..8a89fc9 100644 --- a/gramscii.c +++ b/gramscii.c @@ -33,6 +33,13 @@ #include "arg.h" +typedef struct{ + int sz; + int lst; + char *s; +} line_t; + + #define MOVE 0x00 #define BOX 0x01 #define ARROW 0x02 @@ -71,9 +78,10 @@ #define MIN(x,y) (x) < (y) ? (x) : (y) #define MAX(x,y) (x) > (y) ? (x) : (y) -/** #define DEBUG 1 **/ +#define DEBUG 1 -char **screen; +line_t *screen; +int num_lines; int WIDTH, HEIGHT; int state; @@ -113,7 +121,7 @@ struct termios t1, t2, t3; void dump_lines(){ int i; for (i=0; i