From 6896545dba02089b5778d3cb96a15ec3e68fe3c2 Mon Sep 17 00:00:00 2001 From: girst Date: Fri, 4 Jan 2019 20:08:22 +0100 Subject: [PATCH] change unicode_large_color, implement extreme overlap heuristic colorscheme was unusable on white-bg terminals; extreme overlap must be enabled with -oconsv (conserve vertical space), cutoff was chosen arbitrarily --- Makefile | 2 ++ README.md | 4 ++++ schemes.h | 4 +++- sol.c | 15 +++++++++++---- sol.h | 4 +++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e2b0813..2e2122a 100644 --- a/Makefile +++ b/Makefile @@ -21,3 +21,5 @@ getfuns: sol.c test: grep -n --color=always 'TODO\|XXX\|\/xxx-slashes-xxx\/[^:]' * +longtest: test + sed 's/\t/ /g' sol.c|grep -n --color=always '^.\{81\}'|awk '{print "\033[35msol.c\033[36m:" $$0}' diff --git a/README.md b/README.md index af75da8..4dfecfb 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,10 @@ play klondike and spider solitaire in your unicode terminal. * DONE: make piles 0-indexed in klondike as well * HOLD: duplicate card ♠A found in tableu: added check at start to monitor this Cannot reproduce, removed check + * HOLD: bugs in spider's t2t() + * once segfaulted on large column + * sometimes doesn't work (ERR when it should be OK) + Cannot reproduce * DONE: some input functions are in `x2y()` -- move them to `get_cmd()` (req. for mouse, hjkl modes) * DONE: sigint, sigcont handler! atexit() to avoid inconsistent term state diff --git a/schemes.h b/schemes.h index fbb34bd..a9664c2 100644 --- a/schemes.h +++ b/schemes.h @@ -24,7 +24,9 @@ struct scheme { #define RULCARD(s, r) \ ULCARD("\033[91m" s "\033[39m", r) #define BULCARD(s, r) \ - ULCARD("\033[37m" s "\033[39m", r) + ULCARD("\033[2m" s "\033[22m", r) //WARN: using faint breaks bold +// ULCARD("\033[90m" s "\033[39m", r) //WARN: low contrast on black backgr. +// ULCARD("\033[37m" s "\033[39m", r) //WARN: unusable on white background #define USCARD(c) (char*[]){c} const struct scheme unicode_large_mono = { diff --git a/sol.c b/sol.c index 12006e3..132f140 100644 --- a/sol.c +++ b/sol.c @@ -54,6 +54,7 @@ struct opts { #ifdef SPIDER int m; /* difficulty mode */ #endif + int v; /* conserve vertical space */ const struct scheme* s; } op; @@ -95,10 +96,11 @@ int main(int argc, char** argv) { #ifdef SPIDER op.m = MEDIUM; #endif + op.v = 0; int optget; opterr = 0; /* don't print message on unrecognized option */ - while ((optget = getopt (argc, argv, "+:hd:s:")) != -1) { + while ((optget = getopt (argc, argv, "+:hd:o:s:")) != -1) { switch (optget) { #ifdef SPIDER case 'd': /* difficulty */ @@ -107,6 +109,9 @@ int main(int argc, char** argv) { if(!strcmp(optarg, "hard")) op.m = NORMAL; break; #endif + case 'o': /* misc. options */ + if(!strcmp(optarg, "consv")) op.v = 1; + break; case 's': /* scheme */ if(!strcmp(optarg,"color")) op.s = &unicode_large_color; if(!strcmp(optarg, "mono")) op.s = &unicode_large_mono; @@ -156,6 +161,7 @@ int sol(void) { case CMD_JOIN: //TODO: join any pile to here case CMD_INVAL: visbell(); break; case CMD_NEW: return GAME_NEW; + case CMD_AGAIN: //TODO: restart with same seed case CMD_QUIT: return GAME_QUIT; } print_table(NO_HI, NO_HI); @@ -519,8 +525,9 @@ from_l: print_table(&active, &inactive); inactive = active; break; /* misc keys: */ - case 'q': return CMD_QUIT; - case 'r': return CMD_NEW; + case 'q': return CMD_QUIT; //TODO: should be : command + case 'n': return CMD_NEW; //TODO: should be : command + case 'r': return CMD_AGAIN; //TODO: should be : command case 'J': return CMD_JOIN; case 'K': return CMD_HINT; case '?': return CMD_HELP; @@ -753,7 +760,7 @@ void print_table(const struct cursor* active, const struct cursor* inactive) { / :op.s->card[card] )[line[pile]]); - int extreme_overlap = 0; //TODO: activate iff space constrained (per pile) + int extreme_overlap = op.v && find_top(f.t[pile])>10; /* normal overlap: */ if (++line[pile] >= (next?op.s->overlap:op.s->height) /* extreme overlap on closed cards: */ diff --git a/sol.h b/sol.h index 31e3820..0f7d47d 100644 --- a/sol.h +++ b/sol.h @@ -16,6 +16,7 @@ #define LONGHELP \ "OPTIONS:\n" \ LONGHELP_SPECIFIC \ + " -o(ption) (consv=conserve vertical space)\n" \ " -s(cheme) (color|mono|small)\n" \ " -h(elp)\n" \ "\n" @@ -24,7 +25,7 @@ " hjkl : move cursor\n" \ " H, L : move cursor to first/last tableu pile\n" \ " J, K : join to here, show hint\n" \ - " r, q : new game, quit\n" \ + " n, q : new game, quit\n" \ " space : select at cursor\n" \ " return: draw from stock\n" \ DIRECT_ADDR_KEYHELP @@ -116,6 +117,7 @@ enum special_cmds { CMD_NONE, CMD_QUIT, CMD_NEW, + CMD_AGAIN, CMD_HINT, CMD_HELP, CMD_JOIN, -- 2.39.3