summaryrefslogtreecommitdiff
path: root/gramscii.c
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2019-07-21 00:11:03 +0100
committerKatolaZ <katolaz@freaknet.org>2019-07-21 00:11:03 +0100
commit4cb5948229fea24c9a2eb3413d6dbe53613bada7 (patch)
tree58f2525b70e1f92916c245bca824c199064e2282 /gramscii.c
parent2e1d9e58798f35b1861862d5dcff8088aab4edea (diff)
style change in box and arrow modes + fix manpage
Diffstat (limited to 'gramscii.c')
-rw-r--r--gramscii.c145
1 files changed, 82 insertions, 63 deletions
diff --git a/gramscii.c b/gramscii.c
index 2913fca..1a21350 100644
--- a/gramscii.c
+++ b/gramscii.c
@@ -362,6 +362,33 @@ void toggle_end_mark(){
mark_end = end_marks[cur_end];
}
+int change_style(char c){
+ switch(c){
+ case '-':
+ toggle_hline();
+ break;
+ case '|':
+ toggle_vline();
+ break;
+ case '+':
+ toggle_corner();
+ break;
+ case '<':
+ toggle_st_mark();
+ break;
+ case '>':
+ toggle_end_mark();
+ break;
+ case '.':
+ reset_styles();
+ break;
+ default:
+ return 0;
+ }
+ return c;
+}
+
+
/***** text, box, arrows *****/
@@ -430,10 +457,14 @@ void get_box(){
step = 1;
draw_box(x,y,NOFIX);
while((c=getchar())!=EOF && c != 27 && c!= 'b'){
- if (!move_around(c)) continue;
+ if (change_style(c))
+ goto update_box;
+ if (!move_around(c))
+ continue;
check_bound();
redraw();
step = 1;
+update_box:
draw_box(orig_x, orig_y, NOFIX);
status_bar();
show_cursor();
@@ -504,7 +535,10 @@ void get_arrow(){
step = 1;
draw_arrow(x,y, arrow, 0, NOFIX);
while((c=getchar())!=EOF && c != 27 && c!= 'a'){
- if (!move_around(c)) continue;
+ if (change_style(c))
+ goto update_arrow;
+ if (!move_around(c))
+ continue;
check_bound();
/* FIXME: if we are out of bound, do nothing? */
if (arrow_len == arrow_sz){
@@ -515,6 +549,7 @@ void get_arrow(){
arrow[arrow_len++] = step;
redraw();
step = 1;
+update_arrow:
draw_arrow(orig_x, orig_y, arrow, arrow_len, NOFIX);
status_bar();
show_cursor();
@@ -701,67 +736,51 @@ void commands(){
char c;
while((c=getchar())!=EOF){
- if (!move_around(c)) switch(c){
- case 'i':
- state = TEXT;
- get_text();
- break;
- case 'R':
- redraw();
- break;
- case 'b':
- state = BOX;
- get_box();
- break;
- case 'a':
- state = ARROW;
- get_arrow();
- break;
- case 'W':
- force_new = 1;/** FALLTHROUGH **/
- case 'w':
- write_file();
- break;
- case 'e':
- check_modified();/** FALLTHROUGH **/
- case 'E':
- load_file();
- break;
- case 'N':
- new_file();
- break;
- case 'x':
- state = DEL;
- delete();
- break;
- case 'v':
- state = VIS;
- visual_box();
- break;
- case '-':
- toggle_hline();
- break;
- case '|':
- toggle_vline();
- break;
- case '+':
- toggle_corner();
- break;
- case '<':
- toggle_st_mark();
- break;
- case '>':
- toggle_end_mark();
- break;
- case '.':
- reset_styles();
- break;
- case 'q':
- check_modified();/** FALLTHROUGH **/
- case 'Q':
- cleanup(0);
- exit(0);
- break;
+ if (!change_style(c) && !move_around(c)){
+ switch(c){
+ case 'i':
+ state = TEXT;
+ get_text();
+ break;
+ case 'R':
+ redraw();
+ break;
+ case 'b':
+ state = BOX;
+ get_box();
+ break;
+ case 'a':
+ state = ARROW;
+ get_arrow();
+ break;
+ case 'W':
+ force_new = 1;/** FALLTHROUGH **/
+ case 'w':
+ write_file();
+ break;
+ case 'e':
+ check_modified();/** FALLTHROUGH **/
+ case 'E':
+ load_file();
+ break;
+ case 'N':
+ new_file();
+ break;
+ case 'x':
+ state = DEL;
+ delete();
+ break;
+ case 'v':
+ state = VIS;
+ visual_box();
+ break;
+ case 'q':
+ check_modified();/** FALLTHROUGH **/
+ case 'Q':
+ cleanup(0);
+ exit(0);
+ break;
+ }
}
check_bound();
status_bar();