From 83c275f2b7fef888af10bf82252e9e33b43cada8 Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 31 Mar 2018 23:31:23 +0200 Subject: [PATCH] implement 'z' key, improved scheme (is new version) --- mines_2017.c | 19 +++++++++---------- schemes.h | 8 ++++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/mines_2017.c b/mines_2017.c index ff8028c..9e3dd7e 100644 --- a/mines_2017.c +++ b/mines_2017.c @@ -1,5 +1,5 @@ /******************************************************************************* - minesviiper 0.3.1459 + minesviiper 0.3.14592 By Tobias Girstmair, 2015 - 2018 ./minesviiper 16x16x40 @@ -8,9 +8,9 @@ MOUSE MODE: - left click to open and choord - right click to flag/unflag VI MODE: - hjkl to move cursor left/down/up/right - - bduw to jump left/down/up/right by 5 cells - - o to open and choord + - o/space to open and choord - i to flag/unflag + - (see `./minesviiper -h' for all keybindings) GNU GPL v3, see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt *******************************************************************************/ @@ -227,6 +227,7 @@ int main (int argc, char** argv) { " hjkl: move left/down/up/right\n" " bduw: move to next boundary\n" " ^Gg$: move to the left/bottom/top/right\n" + " z: center cursor on minefield\n" " o: open/choord\n" " i: flag/unflag\n" " space:modeful cursor (either open or flag)\n" @@ -389,6 +390,7 @@ newgame: case '$': cursor_move (f.p[0], f.w-1 ); break; case 'g': cursor_move (0, f.p[1] ); break; case 'G': cursor_move (f.h-1, f.p[1] ); break; + case 'z': cursor_move (f.h/2, f.w/2); break; case 'm': action = tolower(getch(mouse)); if (action < 'a' || action > 'z') break;/*out of bound*/ @@ -693,21 +695,19 @@ char* get_emoticon(void) { #define print_border(which, width) \ print_line(which) printm (width, BORDER(which,MIDDLE)) void show_minefield (int mode) { - int dtime; + int dtime = difftime (time(NULL), f.t)*!!f.t; int half_spaces = f.w*op.scheme->cell_width/2; - int left_spaces = MAX(0,half_spaces-7-(f.m-f.f>999)+2); + int left_spaces = MAX(0,half_spaces-7-(f.m-f.f>999)); int right_spaces = MAX(0,half_spaces-6-(dtime>999)); static char modechar[] = {'*', '!', '?'}; move (0,0); - dtime = (f.t == 0)?0: difftime (time(NULL), f.t); - print_border(TOP, f.w); print_line(STATUS) { - printf("[%03d%c]%*s%*s[%03d]", + printf("[%03d%c]%*s%s%*s[%03d]", /* [ */ f.m - f.f, modechar[f.s], /* ] */ - left_spaces, get_emoticon(), right_spaces,"", + left_spaces,"", get_emoticon(), right_spaces,"", /* [ */ dtime /* ] */); } print_border(DIVIDER, f.w); @@ -776,7 +776,6 @@ int field2screen_c (int c) { return (CW*c+COL_OFFSET - (CW%2)); } int clicked_emoticon (unsigned char* mouse) { -move(30,0);printf("%d-%d", mouse[2], mouse[1]); /* :D clicked: TODO: won't work in single-width mode! */ return (mouse[2] == LINE_OFFSET-1 && ( mouse[1] == (f.w*CW/2)+COL_OFFSET || diff --git a/schemes.h b/schemes.h index 08c7fef..7660a7b 100644 --- a/schemes.h +++ b/schemes.h @@ -113,7 +113,6 @@ struct minescheme symbols_col1 = { .cell_width = 2, }; -//TODO: numbers aren't BOLD after {partial_,}show_minefield() struct minescheme symbols_doublewidth = { /* vt220 multilingual character set, see http://vt100.net/docs/vt220-rm/table2-4.html */ @@ -127,7 +126,7 @@ struct minescheme symbols_doublewidth = { SGR(BOLD,"7"), SGR(BOLD,"8")}, .field_closed = "\x61", - .field_flagged = SGR(BOLD,"!"), + .field_flagged = SGR(REV,SGR(BOLD,"!")), .field_question = SGR(BOLD,"?"), .mouse_highlight = SGR(BLINK,"@"), .mine_normal = SGR(BOLD,"*"), @@ -144,10 +143,11 @@ struct minescheme symbols_doublewidth = { {"\033#6\x6d","\x71","\x6a"}}, .cell_width = 1, + .flag_offset = 4, .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 */ + .reset_seq = "\033(B" /* reset to DEC Multinational Character Set */ + "\033[?3h", /* switch back to 132 column mode (TODO: shouldn't be hardcoded) */ }; #undef SGR -- 2.39.3