From a2bf8545d73621de7cfa3a06663d1b94fdc668c4 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Fri, 19 Jul 2019 15:38:14 +0100 Subject: fix arrow pointer -- toggle start and end markers --- gramscii.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 12 deletions(-) (limited to 'gramscii.c') diff --git a/gramscii.c b/gramscii.c index 2cc7213..1d75b34 100644 --- a/gramscii.c +++ b/gramscii.c @@ -23,6 +23,8 @@ #define DIR_D 0x04 #define DIR_L 0x08 +#define DIR_HOR (DIR_R | DIR_L) +#define DIR_VER (DIR_D | DIR_U) #define WIDTH 100 #define HEIGHT 25 @@ -54,12 +56,20 @@ char corner; char hlines[] = {"-~=#@._ "}; char vlines[] = {"|H#@:;i "}; char corners[] = {"+'H#@.\""}; +char st_marks[] = {"+o-|<>^v"}; +char end_marks[] = {">+o-|<^v"}; + int hlines_sz= sizeof(hlines) -1; int vlines_sz= sizeof(vlines) -1; int corners_sz = sizeof(corners) -1; -int cur_hl, cur_vl, cur_corn; +int stmarks_sz = sizeof(st_marks) - 1; +int endmarks_sz = sizeof(st_marks) - 1; + +int cur_hl, cur_vl, cur_corn, cur_start, cur_end; char line_h; char line_v; +char mark_st; +char mark_end; struct termios t1, t2; @@ -99,8 +109,11 @@ void init_screen(){ cur_corn = 0; corner = corners[0]; cur_hl = cur_vl = 0; + cur_start = cur_end = 0; line_h = hlines[cur_hl]; line_v = vlines[cur_vl]; + mark_st = st_marks[cur_start]; + mark_end = end_marks[cur_end]; } char* state_str(){ @@ -123,8 +136,8 @@ char* state_str(){ void status_bar(){ printf("\033[%d;1f\033[7m", HEIGHT+1); - printf(" x: %3d y: %3d -- mode: %4s hl: %c vl: %c cn: %c %10s", - x, y, state_str(), line_h, line_v, corner, ""); + printf(" x: %3d y: %3d -- mode: %4s hl: %c vl: %c cn: %c <: %c >: %c %10s", + x, y, state_str(), line_h, line_v, corner, mark_st, mark_end, ""); printf("\033[0m"); } @@ -297,12 +310,9 @@ int progr_y(int dir){ } -/* FIXME: fix pointer position */ -/* FIXME: set initial and final markers */ -/* FIXME: draw "corner" as first char after change of dir */ void draw_arrow(int x, int y, char *a, int a_len, int fix){ - int i, j; + int i, j, cur_dir; char line; void (*f)(int, int, char); @@ -312,20 +322,31 @@ void draw_arrow(int x, int y, char *a, int a_len, int fix){ else f = draw_xy; + f(x,y,mark_st); if (!a_len){ - f(x,y,corner); + show_cursor(); return; } - line = (a[0] & DIR_L) || (a[0] & DIR_R) ? line_h : line_v; - f(x,y,line); + cur_dir=DIR_N; for (i=0; i0) { + /* If we are switching between horizontal and vertical, put a "corner" */ + if (((cur_dir & DIR_HOR) && (a[i] & DIR_VER)) || + ((cur_dir & DIR_VER) && (a[i] & DIR_HOR))){ + f(x,y,corner); + show_cursor(); + } + } for(j=0; j': + toggle_end_mark(); + break; case 'Q': case 'q': cleanup(0); -- cgit v1.2.3