add global movements (g, G. m) - gramscii - A simple editor for ASCII box-and-arrow charts
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit c8512825e3baf1525af7117affa13d00ac6b0d1d
(DIR) parent ad0b403caa61c3f1c07698ffe6952588861d98c2
(HTM) Author: KatolaZ <katolaz@freaknet.org>
Date: Sat, 20 Jul 2019 11:03:55 +0100
add global movements (g, G. m)
Diffstat:
M gramscii.c | 64 ++++++++++++++++---------------
1 file changed, 33 insertions(+), 31 deletions(-)
---
(DIR) diff --git a/gramscii.c b/gramscii.c
@@ -79,6 +79,8 @@ char mark_end;
char modified;
char fname[256];
+char visual;
+
struct termios t1, t2, t3;
@@ -227,6 +229,24 @@ void redraw(){
show_cursor();
}
+void go_to(int where){
+ switch(where){
+ case HOME:
+ x = y = 0;
+ break;
+ case END:
+ x = WIDTH-1;
+ y = HEIGHT-1;
+ break;
+ case MIDDLE:
+ x = WIDTH/2;
+ y = HEIGHT/2;
+ break;
+ }
+ check_bound();
+ show_cursor();
+}
+
int move_around(char c){
switch(c){
@@ -250,28 +270,22 @@ int move_around(char c){
dir = DIR_R;
x += step;
break;
- default:
- return 0;
- }
- return 1;
-}
-
-void go_to(int where){
- switch(where){
- case HOME:
- x = y = 0;
+ case 'g':
+ dir = DIR_N;
+ go_to(HOME);
break;
- case END:
- x = WIDTH-1;
- y = HEIGHT-1;
+ case 'G':
+ dir = DIR_N;
+ go_to(END);
break;
- case MIDDLE:
- x = WIDTH/2;
- y = HEIGHT/2;
+ case 'm':
+ dir = DIR_N;
+ go_to(MIDDLE);
break;
+ default:
+ return 0;
}
- check_bound();
- show_cursor();
+ return 1;
}
int progr_x(int dir){
@@ -369,7 +383,6 @@ void get_text(){
state=MOVE;
}
-
void draw_box(int x1, int y1, int fix){
int xmin, ymin, xmax, ymax;
@@ -401,8 +414,6 @@ void draw_box(int x1, int y1, int fix){
show_cursor();
}
-
-
void get_box(){
char c;
int orig_x=x, orig_y=y;
@@ -535,8 +546,8 @@ void delete(){
while((c=getchar())!=EOF && c!=27 && c!= 'x'){
if (!move_around(c)) continue;
check_bound();
- step = 1;
do_delete(orig_x, orig_y);
+ step = 1;
modified = 1;
orig_x = x;
orig_y = y;
@@ -650,15 +661,6 @@ void commands(){
case 'N':
new_file();
break;
- case 'g':
- go_to(HOME);
- break;
- case 'G':
- go_to(END);
- break;
- case 'm':
- go_to(MIDDLE);
- break;
case 'x':
state = DEL;
delete();