From c52d6bc5edfdddb18e380c51c1d993fb8d28c06e Mon Sep 17 00:00:00 2001 From: girst Date: Sun, 20 Jan 2019 19:00:02 +0100 Subject: [PATCH] implement 'M' keybinding moves active cursor to the centre pile --- README.md | 1 + sol.c | 6 ++++-- sol.h | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1fc33ba..fd15188 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ play klondike and spider solitaire in your unicode terminal. * TODO: suggest moves (`h` => hint) * TODO: 'join to here' command (should take longest chain available) * TODO: escape sequences (for real cursor keys) + * TODO: inverted moves (if A->B doesn't work, try B->A) * TODO: cleanup: in `x2y()` functions there is a lot of replication and noise when calculating legal moves, top cards, etc. ### P3 diff --git a/sol.c b/sol.c index 180fca8..4b5bcf8 100644 --- a/sol.c +++ b/sol.c @@ -498,6 +498,7 @@ from_l: print_table(&active, &inactive); case 'l': cursor_right(&active); goto from_l; case 'H': cursor_to(&active,TAB_1); goto from_l; /* leftmost tableu */ case 'L': cursor_to(&active,TAB_MAX);goto from_l; /* rigthmost tableu */ + case 'M': cursor_to(&active,TAB_MAX/2); goto from_l; /* center tableu */ //TODO: real cursor keys, home/end case ' ': /* continue with second cursor */ *from = active.pile; @@ -542,8 +543,9 @@ to_l: print_table(&active, &inactive); case 'j': cursor_down (&active); goto to_l; case 'k': cursor_up (&active); goto to_l; case 'l': cursor_right(&active); goto to_l; - case 'H': cursor_to(&active,TAB_1); goto to_l; - case 'L': cursor_to(&active,TAB_MAX);goto to_l; + case 'H': cursor_to(&active,TAB_1); goto to_l; + case 'L': cursor_to(&active,TAB_MAX); goto to_l; + case 'M': cursor_to(&active,TAB_MAX/2); goto to_l; case 'J': /* fallthrough; key makes no sense on destination */ case ' ': *to = active.pile; diff --git a/sol.h b/sol.h index 9457a71..1e2a800 100644 --- a/sol.h +++ b/sol.h @@ -177,11 +177,12 @@ struct undo undo_sentinel; #define KEYHELP \ "Keybindings:\n" \ " hjkl : move cursor\n" \ - " H, L : move cursor to first/last tableu pile\n" \ - " J, K : join to here, show hint\n" \ - " n, q : new game, quit\n" \ + " H,M,L : move cursor to first/centre/last tableu pile\n" \ + /*" J, K : join to here, show hint\n" */\ " space : select at cursor\n" \ " return: draw from stock\n" \ + " :n : new game\n" \ + " :q : quit\n" \ DIRECT_ADDR_KEYHELP //}}} -- 2.39.3