From 680da211339de72cabe6f4dbaf8d4626b70d8ee3 Mon Sep 17 00:00:00 2001 From: girst Date: Tue, 19 Feb 2019 20:17:55 +0100 Subject: [PATCH] remove freecell backspace --- README.md | 4 +++- sol.c | 15 +++++---------- sol.h | 11 ++++++----- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index b623d37..e0fb5eb 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ licensing details, see `LICENSE`. * TODO FREECELL: autodetect possible moves (card selector choice dialog) ### P2 + * TODO FREECELL: join() + * TODO: klondike/freecell: auto-move to foundation (optional) * TODO: suggest moves (`h` => hint) * TODO: cleanup: in `x2y()` functions there is a lot of replication and noise when calculating legal moves, top cards, etc. @@ -43,7 +45,6 @@ licensing details, see `LICENSE`. ### P4 * TODO: ellipsis overlap: if more than three cards in a row overlap, replace middle ones with an ellipsis - * TODO: differentiate foundation placeholder from cells ph. (freecell) * TODO: mouse mode improvements: - spider/freecell: detect how many cards to move to empty pile (must find exact position despite `extreme_overlap`) @@ -110,6 +111,7 @@ licensing details, see `LICENSE`. * DONE FREECELL: t2t() multi card move and accompanying pop_undo() * DONE: - mouse (term2pile() cell encoding, set_mouse(), wait_mouse_up()) * DONE FREECELL: don't allow selecting more cards than movable (`DO_HI, TOP_HI, cursor_{up,down}`) + * DONE: differentiate foundation placeholder from cells ph. (freecell) ## Notes diff --git a/sol.c b/sol.c index 82f64c6..41045c7 100644 --- a/sol.c +++ b/sol.c @@ -125,6 +125,11 @@ restart: switch (get_cmd(&from, &to, &opt)) { case CMD_MOVE: ret = action[from][to](from,to,opt); +#ifdef FREECELL + if (ret == ERR && is_tableu(from) && to == from) /*i.e. failed foundation move*/ + ret = t2c(from, STOCK, 0); + else +#endif if (ret == ERR && is_tableu(from) && is_tableu(to)) /* try again with from/to swapped: */ ret = action[to][from](to,from,opt); @@ -943,16 +948,6 @@ from_l: print_table(&active, &inactive); #endif inactive = active; break; -#ifdef FREECELL - //TODO: instead of backspace, use doublespace (first try x2t, then x2c) - case 0x7f: case '\b': /* backspace key sends DEL on most terminals */ - if (active.pile == STOCK) return CMD_INVAL; - *from = active.pile; - *opt = active.opt; /* when FOUNDATION */ - *to = STOCK; - return CMD_MOVE; - case '\n': return CMD_INVAL;//TODO: move card to foundation? -#endif /* mouse addressing: */ case MOUSE_MIDDLE: return CMD_NONE; case MOUSE_RIGHT: diff --git a/sol.h b/sol.h index 8269dd0..5ceeed5 100644 --- a/sol.h +++ b/sol.h @@ -205,9 +205,9 @@ struct undo undo_sentinel; #elif defined FREECELL #define LONGHELP_SPECIFIC "" #define DIRECT_ADDR_KEYHELP \ + " or to a free cell\n" \ " 1 .. 8: directly address tableu\n" \ - " 9, 0 : directly address cells and foundation\n" \ - " backsp: move card under cursor to a free cell\n" + " 9, 0 : directly address cells and foundation\n" #endif #define LONGHELP \ "OPTIONS:\n" \ @@ -225,13 +225,14 @@ struct undo undo_sentinel; " H,M,L : move cursor to first/centre/last tableu pile (or home/ins/end)\n" \ " J : join to here (or right mouse click)\n" \ /*" K : show hint\n" */\ - " space : select at cursor (or left mouse click)\n" \ " return: draw from stock\n" \ + " space : select at cursor (or left mouse click)\n" \ + " double press to move to foundation\n" \ + DIRECT_ADDR_KEYHELP \ " :n : new game\n" \ " :r : restart game\n" \ " :h : show keyboard help\n" \ - " :q : quit\n" \ - DIRECT_ADDR_KEYHELP + " :q : quit\n" //}}} int sol(void); -- 2.39.3