From 8dd92909a95ae0bb9159576a8d9e90acf0c6ddb7 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Sat, 20 Jul 2019 14:55:01 +0100 Subject: add comment in fallthrough cases --- gramscii.c | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'gramscii.c') diff --git a/gramscii.c b/gramscii.c index 6676545..a832010 100644 --- a/gramscii.c +++ b/gramscii.c @@ -193,7 +193,6 @@ void erase_line(char *s){ } void erase_box(int x1, int y1, char c){ - int x_incr, y_incr, i; x_incr = x1 < x? +1: -1; @@ -269,22 +268,22 @@ void go_to(int where){ int move_around(char c){ switch(c){ - case 'H': step = 5; + case 'H': step = 5;/** FALLTHROUGH **/ case 'h': dir = DIR_L; x -= step; break; - case 'J': step = 5; + case 'J': step = 5;/** FALLTHROUGH **/ case 'j': dir = DIR_D; y += step; break; - case 'K': step = 5; + case 'K': step = 5;/** FALLTHROUGH **/ case 'k': dir = DIR_U; y -= step; break; - case 'L': step = 5; + case 'L': step = 5;/** FALLTHROUGH **/ case 'l': dir = DIR_R; x += step; @@ -304,7 +303,7 @@ int move_around(char c){ default: return 0; } - return 1; + return c; } int progr_x(int dir){ @@ -357,26 +356,6 @@ void toggle_end_mark(){ -void init(){ - - signal(SIGHUP, cleanup); - signal(SIGINT, cleanup); - signal(SIGTERM, cleanup); - signal(SIGQUIT, cleanup); - - tcgetattr(0, &t1); - t2 = t1; - t2.c_lflag &= ~(ICANON | ECHO); - tcsetattr(0, TCSANOW, &t2); - - init_screen(); - x = WIDTH/2; - y = HEIGHT/2; - modified = 0; - fname[0] = '\0'; - redraw(); -} - /***** text, box, arrows *****/ @@ -663,7 +642,7 @@ void visual_box(){ while((c=getchar())!=EOF && c != 27 && c!= 'v'){ if (!move_around(c)) switch(c){ case 'f':/* fill */ - f = get_key("fill char: "); + f = get_key("fill char: "); /** FALLTHROUGH **/ case 'x':/* erase */ erase_box(orig_x, orig_y, f); modified = 1; @@ -686,6 +665,27 @@ vis_exit: state = MOVE; } +/*** Initialisation ***/ + +void init(){ + + signal(SIGHUP, cleanup); + signal(SIGINT, cleanup); + signal(SIGTERM, cleanup); + signal(SIGQUIT, cleanup); + + tcgetattr(0, &t1); + t2 = t1; + t2.c_lflag &= ~(ICANON | ECHO); + tcsetattr(0, TCSANOW, &t2); + + init_screen(); + x = WIDTH/2; + y = HEIGHT/2; + modified = 0; + fname[0] = '\0'; + redraw(); +} /*** Commands ***/ @@ -711,12 +711,12 @@ void commands(){ get_arrow(); break; case 'W': - force_new = 1; + force_new = 1;/** FALLTHROUGH **/ case 'w': write_file(); break; case 'e': - check_modified(); + check_modified();/** FALLTHROUGH **/ case 'E': load_file(); break; @@ -747,7 +747,7 @@ void commands(){ toggle_end_mark(); break; case 'q': - check_modified(); + check_modified();/** FALLTHROUGH **/ case 'Q': cleanup(0); exit(0); -- cgit v1.2.3