diff options
| -rw-r--r-- | TODO | 5 | ||||
| -rw-r--r-- | draw.c | 58 | ||||
| -rw-r--r-- | gramscii.c | 6 | ||||
| -rw-r--r-- | gramscii.h | 12 | ||||
| -rw-r--r-- | screen.c | 2 | 
5 files changed, 63 insertions, 20 deletions
@@ -1,10 +1,10 @@  + optimize redraws (redraw only the modified rectangle) +- implement comment (#: ignore everything until the end of the line)  - add screen geometry option (-g 25x80?) -- maybe move "text" mode to "t" +- (?)maybe move "text" mode to "t"  - implement ellipse  - (?) filled box (B)  - (?) manage filled box character (as for other styles) -- implement comment (#: ignore until the end of the line)  + parse control characters     + parse arrows (text-mode will allow movements as well)  - (?) implement CTRL+G as abort (aside ESC) @@ -14,6 +14,7 @@  - allow scrolling (both vertical and horizontal)  - catch SIGWINCH and react appropriately (after scrolling is     enabled) +* implement parallelogram mode (z/Z)  * fix bug in reading commands from files  * fix bug in visual crop  * read file at point @@ -143,8 +143,9 @@ void draw_box(int x1, int y1, int fix){  void draw_parallelogram(int x1, int y1, char st, char fix){  	int xmin, ymin, xmax, ymax; -	int dy; +	int dy, minoff, maxoff, xoff, xincr;  	int i; +	char lean;  	void (*f)(int, int, char); @@ -160,27 +161,47 @@ void draw_parallelogram(int x1, int y1, char st, char fix){  	}  	else  		f = draw_xy; -	/*FIXME: INCOMPLETE -- CONTINUE HERE */ -	for(i=xmin+1; i<=xmax; i++){ -		f(i, ymin, line_h); -		f(i, ymax, line_h); +	if (st & BOX_PARR){ +		minoff = dy; +		maxoff = 0; +		lean = '/'; +		xincr = -1;  	} -	for(i=ymin+1; i<=ymax; i++){ -		f(xmin, i, line_v); -		f(xmax, i, line_v); +	else { +		minoff = 0; +		maxoff = dy; +		lean = '\\'; +		xincr = +1;  	} -	f(xmin, ymin, corner); -	f(xmin, ymax, corner); -	f(xmax, ymin, corner); -	f(xmax, ymax, corner); +	for(i=xmin+1; i<=xmax-dy; i++){ +		f(i+minoff, ymin, line_h); +		f(i+maxoff, ymax, line_h); +	} +	 +	for(i=ymin+1, xoff=minoff; i<=ymax; i++, xoff += xincr){ +		f(xmin+(xoff+xincr), i, lean); +		if (minoff) +			f(xmax - (minoff - xoff - xincr), i, lean); +		else  +			f(xmax - (maxoff - xoff - xincr), i, lean); +	} +	f(xmin+minoff, ymin, corner); +	f(xmin+maxoff, ymax, corner); +	f(xmax-maxoff, ymin, corner); +	f(xmax-minoff, ymax, corner);  	if (fix == FIX)  		copy_lines_to_ring(ymin, ymax, NEW_STATE);  	show_cursor(); - -  } +char flip_lean(char st){ +	if (st & BOX_PARR) +		return BOX_PARL; +	else if (st & BOX_PARL) +		return BOX_PARR; +	return st; +}  void get_box(FILE *fc, char st){  	char c; @@ -189,6 +210,11 @@ void get_box(FILE *fc, char st){  	step = 1;  	draw_box(x,y,NOFIX);  	while((c=fgetc(fc))!=EOF && c != 27 && c!= 'b' && c != '\n'){ +		if (c == 'Z'){ +			st = flip_lean(st); +			redraw(); +			goto update_box; +		}  		if (change_style(c))  			goto update_box;  		if (!move_around(c, fc, 1))  @@ -208,8 +234,8 @@ update_box:  		draw_box(orig_x, orig_y, FIX);  		modified = 1;  	} -	else if ((st & (BOX_PAR1 | BOX_PAR2)) &&  (c == 'z' || c == 'Z' || c == '\n')){ -		draw_parallelogram(orig_x, orig_y, FIX); +	else if ((st & (BOX_PARR | BOX_PARL)) &&  (c == 'z' || c == '\n')){ +		draw_parallelogram(orig_x, orig_y, st, FIX);  		modified = 1;  	}  	redraw(); @@ -90,7 +90,7 @@ void commands(FILE *fc){  					break;  				case 'b':  					mode = BOX; -					get_box(fc); +					get_box(fc, BOX_RECT);  					break;  				case 'A': autoend=1;  				case 'a': @@ -134,6 +134,10 @@ void commands(FILE *fc){  				case 'r':  					read_file_at(fc, x, y);  					break; +				case 'z': +					mode = PAR; +					get_box(fc, BOX_PARR); +					break;  				case 'q':  					check_modified(fc);/** FALLTHROUGH **/  				case 'Q': @@ -18,6 +18,7 @@  #define TEXT   0x04  #define DEL    0x08  #define VIS    0x10 +#define PAR    0x20  /**/  /* directions */ @@ -31,6 +32,15 @@  #define DIR_VER (DIR_D | DIR_U)  /**/ +/** box style **/ +/* rectangular box */ +#define BOX_RECT 0x00 +/* parallelogram (leaning right) */ +#define BOX_PARR 0x01 +/* parallelogram (leaning left) */ +#define BOX_PARL 0x02 +/**/ +  #define NOFIX 0x0  #define FIX   0x1 @@ -169,7 +179,7 @@ int _isblank(int c);  /** drawing-related functions **/  int change_style(char c);  void get_text(FILE *fc); -void get_box(FILE *fc); +void get_box(FILE *fc, char st);  void get_arrow(FILE *fc);  void erase(FILE *fc);  void visual_box(FILE *fc); @@ -35,6 +35,8 @@ char* mode_str(){  			return "del";  		case VIS:  			return "vis"; +		case PAR: +			return "par";  		default:  			return "ERR";  	}  | 
