From 1ef0443d0dd8be2cd8505e7993d230326b72168c Mon Sep 17 00:00:00 2001 From: girst Date: Wed, 13 Feb 2019 17:42:24 +0100 Subject: [PATCH] allow disabling visual bell (might change) thanks to github user mikezila for the idea. will be replaced by a less-annoying visbell in the future --- README.md | 2 +- sol.c | 5 ++++- sol.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f0d5445..0fdcbf2 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,12 @@ licensing details, see `LICENSE`. ### P1 * none! \o/ - * TODO: visbell annoys /u/TooEarlyForMe ### P2 * TODO: suggest moves (`h` => hint) * TODO: cleanup: in `x2y()` functions there is a lot of replication and noise when calculating legal moves, top cards, etc. ### P3 + * 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) ### P4 diff --git a/sol.c b/sol.c index e9de19f..a034cfe 100644 --- a/sol.c +++ b/sol.c @@ -50,13 +50,14 @@ int (*action[NUM_PLACES][10])(int,int,int) = { int main(int argc, char** argv) { /* opinionated defaults: */ op.s = &unicode_large_color; + op.v = 1; /* enable fake visbell by default */ #ifdef SPIDER op.m = MEDIUM; #endif int optget; opterr = 0; /* don't print message on unrecognized option */ - while ((optget = getopt (argc, argv, "+:hs:vbcm")) != -1) { + while ((optget = getopt (argc, argv, "+:hs:vbcmV")) != -1) { switch (optget) { #ifdef SPIDER case 's': /* number of suits */ @@ -70,6 +71,7 @@ int main(int argc, char** argv) { case 'b': op.s = &unicode_large_mono; break; case 'c': op.s = &unicode_large_color; break; case 'm': op.s = &unicode_small_mono; break; /* "mini" */ + case 'V': op.v = 0; /* WARN: experimental; might change */ case 'h': default: goto error; error: fprintf (stderr, SHORTHELP LONGHELP KEYHELP, argv[0]); @@ -1179,6 +1181,7 @@ void print_table(const struct cursor* active, const struct cursor* inactive) { } void visbell (void) { + if (!op.v) return; printf ("\033[?5h"); fflush (stdout); usleep (100000); printf ("\033[?5l"); fflush (stdout); diff --git a/sol.h b/sol.h index 833d415..1826c7f 100644 --- a/sol.h +++ b/sol.h @@ -166,6 +166,7 @@ struct opts { unsigned short w[2]; /* terminal window rows/columns */ const struct scheme* s; int h; /* show active highlight? (disabled when mouse used) */ + int v; /* (simulated) visbell enabled? */ }; struct cursor { int pile; @@ -195,6 +196,7 @@ struct undo undo_sentinel; " -b(land colorscheme)\n" \ " -c(olorful colorscheme)\n" \ " -m(iniature colorscheme)\n" \ + " -V(isual bell disable; experimental)\n" \ " -h(elp)\n" \ "\n" #define KEYHELP \ -- 2.39.3