From ebc531d48a9d7369f63631781dd7f96281b6012d Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 31 Mar 2018 17:57:37 +0200 Subject: [PATCH] finish schemes cleanup, fix %.*s format --- mines_2017.c | 4 +-- schemes.h | 75 ++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/mines_2017.c b/mines_2017.c index 3167dc6..61b8689 100644 --- a/mines_2017.c +++ b/mines_2017.c @@ -697,9 +697,9 @@ void show_minefield (int mode) { op.scheme->border_status_l, f.m - f.f, modechar[f.s], - half_spaces-7-(f.m-f.f>999), spaces, + MAX(0,half_spaces-7-(f.m-f.f>999)), spaces, mode==SHOWMINES?everything_opened()?EMOT(WON):EMOT(DEAD):EMOT(SMILE), - half_spaces-6-(dtime>999), spaces, + MAX(0,half_spaces-6-(dtime>999)), spaces, dtime, op.scheme->border_status_r); /* third line */ diff --git a/schemes.h b/schemes.h index b5bbf65..67880dd 100644 --- a/schemes.h +++ b/schemes.h @@ -4,7 +4,19 @@ contains color/monchrome schemes for tty-mines. #ifndef __SCHEMES_H__ #define __SCHEMES_H__ -#define C(color, string) "\033[" #color "m" #string "\033[0m" +#define SGR(color, string) "\033[" color "m" string "\033[0m" +#define BOLD "1" +#define BLINK "5" +#define REV "7" +#define RED "31" +#define GREEN "32" +#define YELLOW "33" +#define BLUE "34" +#define CYAN "36" +#define GREY "37" +#define BRED "91" +#define BBLUE "94" +#define WHITE "97" enum e_emoticons { EMOT_SMILE, @@ -55,8 +67,8 @@ struct minescheme { struct minescheme symbols_mono = { .number = {" ", "1", "2", "3", "4", "5", "6", "7", "8"}, .field_closed = "░░", - .field_flagged = "\033[7m!\033[0m", - .field_question = "\033[7m?\033[0m", + .field_flagged = SGR(REV,"!"), + .field_question = SGR(REV,"?"), .mouse_highlight = "▓▓", .mine_normal = "*", .mine_death = "#", @@ -88,13 +100,21 @@ struct minescheme symbols_mono = { }; struct minescheme symbols_col1 = { - .number = {" ", C(94,1), C(32,2), C(31,3), C(34,4), C(33,5), C(36,6), C(30,7), C(97,8)}, + .number = {" ", + SGR(BBLUE, "1"), + SGR(GREEN, "2"), + SGR(RED, "3"), + SGR(BLUE, "4"), + SGR(YELLOW,"5"), + SGR(CYAN, "6"), + SGR(GREY, "7"), + SGR(WHITE, "8")}, .field_closed = "░░", - .field_flagged = "\033[37m▕\033[91m▀\033[m", + .field_flagged = CGR(GREY,"▕")CGR(xxx,BRED,"▀"), .field_question = "?", .mouse_highlight = "▓▓", .mine_normal = "*", - .mine_death = C(31,*), + .mine_death = SGR(RED,"*"), .mine_wrongf = "/", .mine_wrongq = "\", @@ -124,15 +144,23 @@ struct minescheme symbols_col1 = { struct minescheme symbols_doublewidth = { /* vt220 multilingual character set, see http://vt100.net/docs/vt220-rm/table2-4.html */ - .number = {" ", C(1,1), C(1,2), C(1,3), C(1,4), C(1,5), C(1,6), C(1,7), C(1,8)}, + .number = {" ", + SGR(BOLD,"1"), + SGR(BOLD,"2"), + SGR(BOLD,"3"), + SGR(BOLD,"4"), + SGR(BOLD,"5"), + SGR(BOLD,"6"), + SGR(BOLD,"7"), + SGR(BOLD,"8")}, .field_closed = "\x61", - .field_flagged = C(1,!), - .field_question = C(1,?), - .mouse_highlight = C(5,@), - .mine_normal = C(1,*), - .mine_death = C(1,#), - .mine_wrongf = C(1,/), - .mine_wrongq = C(1,\\), + .field_flagged = SGR(BOLD,"!"), + .field_question = SGR(BOLD,"?"), + .mouse_highlight = SGR(BLINK,"@"), + .mine_normal = SGR(BOLD,"*"), + .mine_death = SGR(BOLD,"#"), + .mine_wrongf = SGR(BOLD,"/"), + .mine_wrongq = SGR(BOLD,"\\"), .emoticons = {":)", ":(", ":D", ":o"}, @@ -155,9 +183,22 @@ struct minescheme symbols_doublewidth = { .border_bottom_r = "\x6a", .cell_width = 1, - .init_seq = "\033(0", /* enable DEC Special Graphics Character Set */ - .reset_seq = "\033(B", /* enable DEC Multinational Character Set (TODO: check) */ + .init_seq = "\033(0" /* enable DEC Special Graphics Character Set */ + "\033[?3l", /* switch to 80 column mode */ + .reset_seq = "\033(B" /* enable DEC Multinational Character Set (TODO: check) */ + "\033[?3h", /* switch to 132 column mode */ }; -#undef C +#undef SGR +#undef BOLD +#undef BLINK +#undef RED +#undef GREEN +#undef YELLOW +#undef BLUE +#undef CYAN +#undef GREY +#undef BRED +#undef BBLUE +#undef WHITE #endif -- 2.39.3