diff options
author | KatolaZ <katolaz@freaknet.org> | 2019-07-20 10:49:14 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2019-07-20 10:49:14 +0100 |
commit | ad0b403caa61c3f1c07698ffe6952588861d98c2 (patch) | |
tree | 978351cb42a2fe9d64f5480c1baef8db5f02d8aa | |
parent | 2f5d0a4be8c029c5a4d1279be8823604db2c0fc2 (diff) |
small changes to status bar + remove trailing blanks
-rw-r--r-- | gramscii.c | 53 |
1 files changed, 28 insertions, 25 deletions
@@ -106,18 +106,21 @@ char* state_str(){ default: return "ERR"; } - return "ERR"; + return "ERR"; } void status_bar(){ - + printf("\033[%d;1f\033[7m", HEIGHT+1); printf("%100s", " "); printf("\033[%d;1f\033[7m", HEIGHT+1); - printf(" x: %3d y: %3d -- mode: %4s hl: %c vl: %c cn: %c <: %c >: %c %10s", + printf(" x:%3d y:%3d -- MODE:%4s HL:%c VL:%c CN:%c SM:%c EM:%c %10s", x, y, state_str(), line_h, line_v, corner, mark_st, mark_end, ""); - printf(" [%s]", fname ); + if (!modified) + printf(" [%s]", fname ); + else + printf(" *%s*", fname ); printf("\033[0m"); } @@ -169,7 +172,7 @@ void set_xy(int x, int y, char c){ void draw_xy(int x, int y, char c){ /* FIXME: check if x and y are valid!!!! */ printf("\033[%d;%df",y+1,x+1); - putchar(c); + putchar(c); } void update_current(){ @@ -194,7 +197,7 @@ void check_bound(){ if (x<0) x=0; else if (x>=WIDTH) x = WIDTH-1; if (y<0) y=0; - else if (y>=HEIGHT) y = HEIGHT -1; + else if (y>=HEIGHT) y = HEIGHT -1; } void init_screen(){ @@ -215,7 +218,7 @@ void init_screen(){ void redraw(){ int i; - + printf("\033[2J\033[1;1H"); for (i=0;i<HEIGHT;i++){ fprintf(stdout,"%s\n",screen[i]); @@ -228,10 +231,10 @@ int move_around(char c){ switch(c){ case 'H': step = 5; - case 'h': + case 'h': dir = DIR_L; x -= step; - break; + break; case 'J': step = 5; case 'j': dir = DIR_D; @@ -286,11 +289,11 @@ void toggle_hline(){ cur_hl = (cur_hl + 1) % hlines_sz; line_h = hlines[cur_hl]; - + } void toggle_corner(){ - + cur_corn = (cur_corn + 1 ) % corners_sz; corner = corners[cur_corn]; @@ -304,13 +307,13 @@ void toggle_vline(){ } void toggle_st_mark(){ - + cur_start = (cur_start + 1 ) % stmarks_sz; mark_st = st_marks[cur_start]; } void toggle_end_mark(){ - + cur_end = (cur_end+ 1 ) % endmarks_sz; mark_end = end_marks[cur_end]; } @@ -323,12 +326,12 @@ void init(){ 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; @@ -343,7 +346,7 @@ void init(){ void get_text(){ char c; int orig_x = x; - + redraw(); while((c=getchar())!=EOF && c != 27){ if(c=='\n'){ @@ -377,7 +380,7 @@ void draw_box(int x1, int y1, int fix){ f = set_xy; else f = draw_xy; - + xmin = MIN(x, x1); xmax = MAX(x, x1); ymin = MIN(y, y1); @@ -429,7 +432,7 @@ void draw_arrow(int x, int y, char *a, int a_len, int fix){ char line; void (*f)(int, int, char); - + if (fix == FIX) f = set_xy; else @@ -454,7 +457,7 @@ void draw_arrow(int x, int y, char *a, int a_len, int fix){ line = (a[i] & DIR_L) || (a[i] & DIR_R) ? line_h : line_v; x += progr_x(a[i]); y += progr_y(a[i]); - f(x, y, line); + f(x, y, line); } /* f(x,y,mark_end);*/ cur_dir = a[i]; @@ -476,7 +479,7 @@ void get_arrow(){ } arrow_len = 0; dir = DIR_N; - + redraw(); step = 1; draw_arrow(x,y, arrow, 0, NOFIX); @@ -549,7 +552,7 @@ void delete(){ void write_file(){ FILE *f; int i; - + if (!fname[0] || force_new){ get_string("Write to: ", fname, 255); if (f=fopen(fname, "r")){ @@ -612,6 +615,8 @@ void new_file(){ modified=0; } +/*** Commands ***/ + void commands(){ char c; @@ -664,10 +669,10 @@ void commands(){ case '|': toggle_vline(); break; - case '+': + case '+': toggle_corner(); break; - case '<': + case '<': toggle_st_mark(); break; case '>': @@ -690,8 +695,6 @@ void commands(){ } - - int main(int argc, char *argv[]){ init(); |