summaryrefslogtreecommitdiff
path: root/draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c88
1 files changed, 65 insertions, 23 deletions
diff --git a/draw.c b/draw.c
index 1c74a94..e1ee63b 100644
--- a/draw.c
+++ b/draw.c
@@ -161,7 +161,7 @@ void draw_parallelogram(int x1, int y1, char st, char fix){
}
else
f = draw_xy;
- if (st & BOX_PARR){
+ if (st == BOX_PARR){
minoff = dy;
maxoff = 0;
lean = '/';
@@ -195,47 +195,89 @@ void draw_parallelogram(int x1, int y1, char st, char fix){
}
-char flip_lean(char st){
- if (st & BOX_PARR)
+char flip_par_lean(char st){
+ if (st == BOX_PARR)
return BOX_PARL;
- else if (st & BOX_PARL)
+ else if (st == BOX_PARL)
return BOX_PARR;
return st;
}
+void draw_trapezium(int x1, int y1, char st, char fix){
+
+}
+
+/*
+ * draw the current box, being it an actual box, a parallelogram, or a
+ * trapezium
+ */
+void update_box(int x1, int y1, char st, char fix){
+
+ if (st == BOX_RECT)
+ draw_box(x1, y1, fix);
+ else if (st & BOX_PAR)
+ draw_parallelogram(x1, y1, st, fix);
+ else if (st & BOX_TRAP)
+ draw_trapezium(x1, y1, st, fix);
+ status_bar();
+ show_cursor();
+}
+
+char toggle_trap_type(char st){
+ return st;
+}
+
+int box_end(char c, char st){
+ if (c == '\n' ||
+ c == 27 ||
+ ((st == BOX_RECT) && c == 'b') ||
+ ((st & BOX_PAR) && c == 'z') ||
+ ((st & BOX_TRAP) && c == 't'))
+ return 1;
+ return 0;
+}
+
+/* draw boxes, parallelograms, and trapezia */
void get_box(FILE *fc, char st){
char c;
int orig_x=x, orig_y=y;
redraw();
step = 1;
+#ifdef DEBUG
+ fprintf(stderr, "box style: %d\n", st);
+#endif
draw_box(x,y,NOFIX);
- while((c=fgetc(fc))!=EOF && c != 27 && c!= 'b' && c != '\n'){
- if (c == 'Z'){
- st = flip_lean(st);
+ while((c=fgetc(fc))!=EOF && !box_end(c, st)){
+ if (c == 'Z' && (st & BOX_PAR)){
+ st = flip_par_lean(st);
redraw();
- goto update_box;
+#ifdef DEBUG
+ fprintf(stderr, "new parallelogram style: %d\n", st);
+#endif
+ update_box(orig_x, orig_y, st, NOFIX);
+ continue;
+ }
+ else if (c == 'T' && (st & BOX_TRAP)){
+ st = toggle_trap_type(st);
+ redraw();
+ update_box(orig_x, orig_y, st, NOFIX);
+ continue;
+ }
+ if (change_style(c)){
+ update_box(orig_x, orig_y, st, NOFIX);
+ continue;
}
- if (change_style(c))
- goto update_box;
if (!move_around(c, fc, 1))
continue;
check_bound(&x, &y);
redraw();
step = 1;
-update_box:
- if (st == BOX_RECT)
- draw_box(orig_x, orig_y, NOFIX);
- else
- draw_parallelogram(orig_x, orig_y, st, NOFIX);
- status_bar();
- show_cursor();
- }
- if (st == BOX_RECT && (c == 'b' || c == '\n')){
- draw_box(orig_x, orig_y, FIX);
- modified = 1;
+ update_box(orig_x, orig_y, st, NOFIX);
}
- else if ((st & (BOX_PARR | BOX_PARL)) && (c == 'z' || c == '\n')){
- draw_parallelogram(orig_x, orig_y, st, FIX);
+ if (((st == BOX_RECT ) && (c == 'b' || c == '\n')) ||
+ ( (st & BOX_PAR ) && (c == 'z' || c == '\n')) ||
+ ( (st & BOX_TRAP ) && (c == 't' || c == '\n'))){
+ update_box(orig_x, orig_y, st, FIX);
modified = 1;
}
redraw();