summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2019-08-13 16:20:49 +0100
committerKatolaZ <katolaz@freaknet.org>2019-08-13 16:20:49 +0100
commit257ec5d56fbe0ac65b04ae10bf36dd14e86c95a5 (patch)
tree9656caf5b6adeb5dd62bd78bc96498dcb7f39e7c
parent39ec615b54c0cc2734ac29ba4caac574c21503a4 (diff)
towards parallelograms
-rw-r--r--draw.c59
1 files changed, 56 insertions, 3 deletions
diff --git a/draw.c b/draw.c
index 7e93e39..0cb50a1 100644
--- a/draw.c
+++ b/draw.c
@@ -141,7 +141,48 @@ void draw_box(int x1, int y1, int fix){
show_cursor();
}
-void get_box(FILE *fc){
+void draw_parallelogram(int x1, int y1, char st, char fix){
+ int xmin, ymin, xmax, ymax;
+ int dy;
+ int i;
+ void (*f)(int, int, char);
+
+
+ xmin = MIN(x, x1);
+ xmax = MAX(x, x1);
+ ymin = MIN(y, y1);
+ ymax = MAX(y, y1);
+ dy = ymax - ymin;
+
+ if (fix == FIX){
+ f = set_xy;
+ copy_lines_to_ring(ymin, ymax, PRV_STATE);
+ }
+ 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);
+ }
+ for(i=ymin+1; i<=ymax; i++){
+ f(xmin, i, line_v);
+ f(xmax, i, line_v);
+ }
+ f(xmin, ymin, corner);
+ f(xmin, ymax, corner);
+ f(xmax, ymin, corner);
+ f(xmax, ymax, corner);
+ if (fix == FIX)
+ copy_lines_to_ring(ymin, ymax, NEW_STATE);
+ show_cursor();
+
+
+
+}
+
+
+void get_box(FILE *fc, char st){
char c;
int orig_x=x, orig_y=y;
redraw();
@@ -156,14 +197,21 @@ void get_box(FILE *fc){
redraw();
step = 1;
update_box:
- draw_box(orig_x, orig_y, NOFIX);
+ 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 (c == 'b' || c == '\n'){
+ if (st == BOX_RECT && (c == 'b' || c == '\n')){
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);
+ modified = 1;
+ }
redraw();
mode = MOVE;
}
@@ -331,6 +379,9 @@ void erase(FILE *fc){
}
+
+
+
/*** Visual ***/
@@ -385,6 +436,8 @@ vis_exit:
mode = MOVE;
}
+/*** yank/paste/undo ***/
+
void paste(){
int y2;