From 932b1fafec6e0e3641e3b79b0396fe3bd9fc8374 Mon Sep 17 00:00:00 2001 From: girst Date: Mon, 7 Jan 2019 18:12:55 +0100 Subject: [PATCH] awful hack that un-breaks faint+bold printing bold and faint can bet set individually, but only reset both at once. this causes the bold attribute (useful for determining with cards are movable) to be reset when faint was. we are splitting the string at a known-whitespace position only if we are at the faint printed lines (str[n]==033). --- README.md | 2 +- schemes.h | 6 ++---- sol.c | 13 +++++++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2631107..c9aece3 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ play klondike and spider solitaire in your unicode terminal. - insert append_undo() in x2y() functions - to encode stack position we need to overload `f.u.n` as index. (similar for foundation: overload `f.u.n` as foundation id) - - w2f(): have to encode both stock index and foundation id <-XXX + - w2f(): have to encode both stock index and foundation id don't want to add a struct field for this one case; for the time being (i.e. forever) I'm ORing waste index and (foundation id<<16). ugly but works :/ diff --git a/schemes.h b/schemes.h index a774168..8bf2d98 100644 --- a/schemes.h +++ b/schemes.h @@ -24,9 +24,7 @@ struct scheme { #define RULCARD(s, r) \ ULCARD("\033[91m" s "\033[39m", r) #define BULCARD(s, 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 + ULCARD("\033[2m" s "\033[22m", r) //WARN: requires hack in print_hi() #define USCARD(c) (char*[]){c} const struct scheme unicode_large_mono = { @@ -134,7 +132,7 @@ const struct scheme unicode_large_color = { "│\033[94m▚\033[39m", "╰─" }, - .halfcard = (int[]){6, 16, 4, 6}, //TODO: these values must be changed to fit the BULCARD macro! + .halfcard = (int[]){6, 15, 4, 6}, .halfwidth = {2, 3, 999}, }; const struct scheme unicode_small_mono = { diff --git a/sol.c b/sol.c index ac10e6b..49da24c 100644 --- a/sol.c +++ b/sol.c @@ -116,8 +116,8 @@ int sol(void) { case WON: return GAME_WON; } break; - case CMD_HINT: //TODO: show a possible (and sensible) move - case CMD_JOIN: //TODO: join any pile to here (longest if possible) + case CMD_HINT: break;//TODO: show a possible (and sensible) move + case CMD_JOIN: break;//TODO: join any pile to here (longest if possible) case CMD_UNDO: undo_pop(f.u); break; case CMD_INVAL: visbell(); break; case CMD_NEW: return GAME_NEW; @@ -673,6 +673,15 @@ void deal(void) { // screen drawing routines {{{ void print_hi(int invert, int grey_bg, int bold, char* str) { + if (op.s == &unicode_large_color){//ARGH! awful hack for bold with faint + int offset = str[3]==033?16:str[4]==033?17:0; + if ((unsigned char)str[10] == 0x9a) offset = 0; //facedown card + printf ("%s%s%s""%.*s%s%s""%s%s%s", + bold?"\033[1m":"", invert?"\033[7m":"", grey_bg?"\033[100m":"", + offset, str, bold?"\033[1m":"", str+offset, + grey_bg?"\033[49m":"", invert?"\033[27m":"",bold?"\033[22m":""); + return; + } printf ("%s%s%s%s%s%s%s", bold?"\033[1m":"", invert?"\033[7m":"", grey_bg?"\033[100m":"", str, -- 2.39.3