From 4a72033ad4cb604365f00e2fb3108d162aa628e9 Mon Sep 17 00:00:00 2001 From: girst Date: Tue, 19 Feb 2019 19:51:48 +0100 Subject: [PATCH] differentiate foundation from placeholder MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit alternative designs: ╭╌╌╌╮╭╌╌╌╮╭╌╌╌╮ ╎ ╳ ╎╎▕▔▏╎╎▛▀▜╎ ╎╱‾╲╎╎▕▔▏╎╎▛▀▜╎ ╰╌╌╌╯╰╌╌╌╯╰╌╌╌╯ --- README.md | 4 +--- schemes.h | 21 +++++++++++++++++++-- sol.c | 5 ++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1881cbc..b623d37 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,12 @@ licensing details, see `LICENSE`. * TODO: visbell changes: instead of screen, flash active {cursor,card} {red,twice}? * TODO: differential drawing mode (at least for highlighting cards) * TODO: `.` command (repeat last action) - * TODO: FreeCell (/u/CFWhitman) - req' algorithm for moving multiple cards around - for first multicardmove impl.: allow moving (n+1) cards where n is empty spaces ### 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: detect how many cards to move to empty pile + - spider/freecell: detect how many cards to move to empty pile (must find exact position despite `extreme_overlap`) * TODO: scores, variants: draw 3, max. n overturns * TODO: vt220 mode (problems: charset, slow baudrate and no differential drawing mode) diff --git a/schemes.h b/schemes.h index 8aedec5..6d26c3c 100644 --- a/schemes.h +++ b/schemes.h @@ -10,12 +10,14 @@ struct scheme { char** card[_NUM_CARDS_internal]; char** facedown; char** placeholder; + char** foundation; char** halfstack; /* left half of stack (for spider) */ int* halfcard; /* byte offset of right half of cards (for spider) */ int halfwidth[3]; /* printed width of halfstack([0]) and halfcard([1]), byte width of halfcard([2]) */ }; +#define p "\017" /*padding, [RB]?CARD must have same length; alternative: \177*/ #define ULCARD(s, r) (char*[]) \ {"╭───╮",\ "│"s" "r"│",\ @@ -24,10 +26,10 @@ struct scheme { #define RULCARD(s, r) \ ULCARD("\033[91m" s "\033[39m", r) #define BULCARD(s, r) \ - ULCARD("\017\033[2m" s "\033[22m", r)//WARN: requires hack in print_hi() + ULCARD(p "\033[2m" s "\033[22m", r)//WARN: requires hack in print_hi() #define USCARD(c) (char*[]){c} #define RUSCARD(c) (char*[]){"\033[91m" c "\033[39m "} -#define BUSCARD(c) (char*[]){"\017\017\017\017\017" c "\017\017\017\017\017 "} +#define BUSCARD(c) (char*[]){c p p p p p p p p p p " "} const struct scheme unicode_large_mono = { .width = 5, @@ -79,6 +81,12 @@ const struct scheme unicode_large_mono = { "╎ ╎", "╰╌╌╌╯" }, + .foundation = (char*[]){ + "╭╌╌╌╮", + "╎╭─╮╎", + "╎├─┤╎", + "╰╌╌╌╯" + }, .halfstack = (char*[]) { "╭─", "│▚", @@ -138,6 +146,12 @@ const struct scheme unicode_large_color = { "╎ ╎", "╰╌╌╌╯" }, + .foundation = (char*[]){ + "╭╌╌╌╮", + "╎\033[2m╭─╮\033[22m╎", + "╎\033[2m├─┤\033[22m╎", + "╰╌╌╌╯" + }, .halfstack = (char*[]) { "╭─", "│\033[94m▚\033[39m", @@ -182,6 +196,7 @@ const struct scheme unicode_small_mono = { }, .facedown = (char*[]){"🂠 "}, .placeholder = (char*[]){"❲❳"}, + .foundation = (char*[]){"⟨⟩"}, .halfstack = (char*[]){"🂠"}, .halfcard = (int[]){0}, .halfwidth = {1, 1, 4}, @@ -221,8 +236,10 @@ const struct scheme unicode_small_color = { }, .facedown = (char*[]){"🂠 "}, .placeholder = (char*[]){"❲❳"}, + .foundation = (char*[]){"⟨⟩"}, .halfstack = (char*[]){"🂠"}, .halfcard = (int[]){0}, .halfwidth = {1, 1, 14}, }; +#undef p #endif diff --git a/sol.c b/sol.c index dfba035..82f64c6 100644 --- a/sol.c +++ b/sol.c @@ -1407,7 +1407,7 @@ void print_table(const struct cursor* active, const struct cursor* inactive) { /* cursor addr. || direct addr. */ inactive->opt==pile || inactive->opt < 0 ), 1, - (card < 0)?op.s->placeholder[line] + (card < 0)?op.s->foundation[line] :op.s->card[f.f[pile][card]][line]); } printf("\n"); @@ -1440,7 +1440,6 @@ void print_table(const struct cursor* active, const struct cursor* inactive) { #elif defined FREECELL /* print open cells, foundation: */ for (int line = 0; line < op.s->height; line++) { - //FREECELL TODO: cells and foundation look the same! (different placeholder?) for (int pile = 0; pile < NUM_CELLS; pile++) print_hi (active->pile==STOCK && active->opt==pile, inactive->pile==STOCK && ( @@ -1456,7 +1455,7 @@ void print_table(const struct cursor* active, const struct cursor* inactive) { /* cursor addr. || direct addr. */ inactive->opt==pile || inactive->opt < 0 ), 1, - (card < 0)?op.s->placeholder[line] + (card < 0)?op.s->foundation[line] :op.s->card[f.f[pile][card]][line]); } printf("\n"); -- 2.39.3