shithub: puzzles

Download patch

ref: bbbbc8b22bae0aa15b48273f763b0e215df0c7af
parent: fcf1d274c3f512e6f70cba71832e0ecc97b656d3
author: Ben Harris <bjh21@bjh21.me.uk>
date: Mon Apr 24 18:25:12 EDT 2023

Pattern: Reduce row clue spacing if there are lots of them

Normally, we put two spaces between row clues, but if there are a lot
then even with a smaller font size they might overflow the left edge
of the window.  To compensate, go down to one space between clues
instead of two if there are a lot of them.  On my laptop the GTK build
demonstrates overflow with "13x1:1//1//1//1//1//1//1/1.1.1.1.1.1.1".

--- a/pattern.c
+++ b/pattern.c
@@ -1853,11 +1853,15 @@
     } else {
         int x, y;
         size_t off = 0;
+        const char *spaces = "  ";
 
         assert(rowlen <= state->common->rowsize);
         *ds->strbuf = '\0';
+        /* Squish up a bit if there are lots of clues. */
+        if (rowlen > TLBORDER(state->common->w)) spaces++;
         for (j = 0; j < rowlen; j++)
-            off += sprintf(ds->strbuf + off, "%s%d", j ? "  " : "", rowdata[j]);
+            off += sprintf(ds->strbuf + off, "%s%d",
+                           j ? spaces : "", rowdata[j]);
         y = ry;
         x = BORDER + TILE_SIZE * (TLBORDER(state->common->w)-1);
         draw_text(dr, x+TILE_SIZE, y+TILE_SIZE/2, FONT_VARIABLE,