diff options
Diffstat (limited to 'gramscii.c')
-rw-r--r-- | gramscii.c | 66 |
1 files changed, 66 insertions, 0 deletions
@@ -16,6 +16,7 @@ #define ARROW 0x02 #define TEXT 0x04 #define DEL 0x08 +#define VIS 0x10 #define DIR_N 0x00 #define DIR_R 0x01 @@ -45,6 +46,9 @@ #define END 0x02 #define MIDDLE 0x04 +#define VIDEO_NRM 0 +#define VIDEO_REV 7 + #define MIN(x,y) (x) < (y) ? (x) : (y) #define MAX(x,y) (x) > (y) ? (x) : (y) @@ -188,6 +192,21 @@ 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; + y_incr = y1 < y? +1: -1; + do{ + i = y1; + do{ + set_xy(x1, i, c); + } while(i != y && (1 | (i += y_incr))); + } while(x1 != x && (1 | (x1 += x_incr))); + +} + void erase_screen(){ int i; for(i=0;i<HEIGHT; i++) @@ -297,6 +316,10 @@ int progr_y(int dir){ return dir == DIR_U ? -1 : dir == DIR_D ? 1: 0; } +void set_video(int v){ + printf("\033[%dm", v); +} + /*** Lines and markers ***/ void toggle_hline(){ @@ -626,6 +649,45 @@ void new_file(){ modified=0; } +/*** Visual ***/ + + +void visual_box(){ + int orig_x =x, orig_y = y; + char c, f = BG; + + redraw(); + step = 1; + set_video(VIDEO_REV); + draw_box(x,y,NOFIX); + while((c=getchar())!=EOF && c != 27 && c!= 'v'){ + if (!move_around(c)) switch(c){ + case 'f':/* fill */ + f = get_key("fill char: "); + case 'x':/* erase */ + erase_box(orig_x, orig_y, f); + modified = 1; + goto vis_exit; + break; + } + check_bound(); + set_video(VIDEO_NRM); + redraw(); + step = 1; + f = BG; + set_video(VIDEO_REV); + draw_box(orig_x, orig_y, NOFIX); + status_bar(); + show_cursor(); + } +vis_exit: + set_video(VIDEO_NRM); + redraw(); + state = MOVE; +} + + + /*** Commands ***/ void commands(){ @@ -665,6 +727,10 @@ void commands(){ state = DEL; delete(); break; + case 'v': + state = VIS; + visual_box(); + break; case '-': toggle_hline(); break; |