summaryrefslogtreecommitdiff
path: root/screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/screen.c b/screen.c
index 587abd7..3c69541 100644
--- a/screen.c
+++ b/screen.c
@@ -252,39 +252,53 @@ void go_to(int where){
show_cursor();
}
-void handle_goto(){
+void handle_goto(char global){
char c;
c=getchar();
switch(c){
case 'h':
dir = DIR_L;
+ step = x;
x = 0;
break;
case 'l':
dir = DIR_R;
+ step = WIDTH - x -1;
x = WIDTH - 1;
break;
case 'j':
dir = DIR_D;
+ step = HEIGHT - y-1;
y = HEIGHT - 1;
break;
case 'k':
dir = DIR_U;
+ step = y;
y = 0;
break;
case 'g':
- dir = DIR_N;
- go_to(HOME);
+ if (global){
+ dir = DIR_N;
+ go_to(HOME);
+ } else step = 0;
break;
case 'G':
- dir = DIR_N;
- go_to(END);
+ if (global){
+ dir = DIR_N;
+ go_to(END);
+ } else step = 0;
break;
case 'm':
- dir = DIR_N;
- go_to(MIDDLE);
+ if (global){
+ dir = DIR_N;
+ go_to(MIDDLE);
+ } else step = 0;
break;
}
+
+#ifdef DEBUG
+ fprintf(stderr, "global move: dir: %d x: %d y: %d\n", dir, x, y);
+#endif
check_bound(&x, &y);
show_cursor();
}
@@ -324,7 +338,7 @@ int get_escape(FILE *fc){
}
-int move_around(char c, FILE *fc){
+int move_around(char c, FILE *fc, char global){
if (isdigit(c)){
if (mult)
@@ -365,7 +379,13 @@ int move_around(char c, FILE *fc){
x += step;
break;
case 'g':
- handle_goto();
+#ifdef DEBUG
+ fprintf(stderr, "before global: step: %d x: %d y: %d\n", step, x, y);
+#endif
+ handle_goto(global);
+#ifdef DEBUG
+ fprintf(stderr, "after global: step: %d x: %d y: %d\n", step, x, y);
+#endif
break;
default:
return 0;