summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2019-07-22 13:54:48 +0100
committerKatolaZ <katolaz@freaknet.org>2019-07-22 13:54:48 +0100
commit557124afa12af33f8453f04beab1ebfbe1e7a593 (patch)
treeca39d73f22e29100ace697c5f492a485f3db7ca7
parentf73faa7a82282660413e4056486e452af61832c0 (diff)
change global movement commands -- g+[gGmhjkl]
-rw-r--r--TODO25
-rw-r--r--gramscii.c49
2 files changed, 54 insertions, 20 deletions
diff --git a/TODO b/TODO
index eb18bd3..4e8bd96 100644
--- a/TODO
+++ b/TODO
@@ -1,27 +1,32 @@
+ optimize redraws (i.e., avoid to redraw if possible)
- move configs in config.h
- add Makefile
-- auto-arrow 'A' (automatic end-char)
-- change screen management (i.e., use an array of lines)
+- change screen management (i.e., dynamic array of lines)
+- get screen geometry
+- add action multiplier (e.g., "7h" moves left by 7 cols)
+- use [ENTER] to confirm arrow, boxes, and text (useful for scripting)
+- add scripting mode option ("-s"?)
+- add screen geometry option (-g 25x80?)
- read file at point
- parse control characters
- parse arrows (text-mode will allow movements as well)
-- implement CTRL+G as abort (aside ESC)
-- change "g" command:
- - g-g (goto top-left)
- - g-G (goto bottom-right)
- - g-m (goto middle)
- - g-[hjkl] (goto leftmost, bottom, top, rightmost)
+- (?) implement CTRL+G as abort (aside ESC)
+- add crop command (c)
+ visual selection
- - crop
+ - crop-to
- yank/put
* fill
* delete
- undo (by storing lines changed across insert/remove operations)
- manage special chars (DEL/CANC) during text insert
(also do not print unmanaged chars!)
-- get screen geometry
- allow scrolling (both vertical and horizontal)
+- auto-arrow 'A' (automatic end-char)
+* change "g" command:
+ - g-g (goto top-left)
+ - g-G (goto bottom-right)
+ - g-m (goto middle)
+ - g-[hjkl] (goto leftmost, bottom, top, rightmost)
* move style commands in a separate function
(and allow style change in all the modes...)
* add "vis" (for visual) in mode strings
diff --git a/gramscii.c b/gramscii.c
index 1a21350..0ca2291 100644
--- a/gramscii.c
+++ b/gramscii.c
@@ -273,6 +273,44 @@ void go_to(int where){
show_cursor();
}
+void handle_goto(){
+ char c;
+ c=getchar();
+ switch(c){
+ case 'h':
+ dir = DIR_L;
+ x = 0;
+ break;
+ case 'l':
+ dir = DIR_R;
+ x = WIDTH - 1;
+ break;
+ case 'j':
+ dir = DIR_D;
+ y = HEIGHT - 1;
+ break;
+ case 'k':
+ dir = DIR_U;
+ y = 0;
+ break;
+ case 'g':
+ dir = DIR_N;
+ go_to(HOME);
+ break;
+ case 'G':
+ dir = DIR_N;
+ go_to(END);
+ break;
+ case 'm':
+ dir = DIR_N;
+ go_to(MIDDLE);
+ break;
+ }
+ check_bound();
+ show_cursor();
+}
+
+
int move_around(char c){
switch(c){
@@ -297,16 +335,7 @@ int move_around(char c){
x += step;
break;
case 'g':
- dir = DIR_N;
- go_to(HOME);
- break;
- case 'G':
- dir = DIR_N;
- go_to(END);
- break;
- case 'm':
- dir = DIR_N;
- go_to(MIDDLE);
+ handle_goto();
break;
default:
return 0;