simon-git: puzzles (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Wed Sep 20 18:17:16 BST 2017


TL;DR:
  e4d05c3 Generate special fake keypresses from menu options.
  d72db91 Map Ctrl-Shift-Z to Redo.
  61e7111 Build test HTML wrapper pages for the Javascript puzzles.

Repository:     https://git.tartarus.org/simon/puzzles.git
On the web:     https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2017-09-20 18:17:16

commit e4d05c36d996c3053a66ca29cfe84e9652d501e3
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=e4d05c36d996c3053a66ca29cfe84e9652d501e3;hp=666c528326b881460f2b677e20a2a9bc4d86898f
Author: Simon Tatham <anakin at pobox.com>
Date:   Wed Sep 20 10:13:36 2017 +0100

    Generate special fake keypresses from menu options.
    
    This fixes an amusing UI bug that I think can currently only come up
    in the unpublished puzzle 'Group', but there's no reason why other
    puzzles _couldn't_ do the thing that triggers the bug, if they wanted
    to.
    
    Group has unusual keyboard handling, in that sometimes (when a cell is
    selected for input and the key in question is valid for the current
    puzzle size) the game's interpret_move function will eat keystrokes
    like 'n' and 'u' that would otherwise trigger special UI events like
    New Game or Undo.
    
    The bug is that fake keypress events generated from the GUI menus
    looked enough like those keystrokes that interpret_move would eat
    those too. So if you start, say, a 16x16 Group puzzle, select an empty
    cell, and then choose 'new game' from the menu, Group will enter 'n'
    into the cell instead of starting a new game!
    
    I've fixed this by inventing a new set of special keystroke values
    called things like UI_NEWGAME and UI_UNDO, and having the GUI menus in
    all my front ends generate those in place of 'n' and 'u'. So now the
    midend can tell the difference between 'n' on the keyboard and New
    Game from the menu, and so Group can treat them differently too. In
    fact, out of sheer overcaution, midend.c will spot keystrokes in this
    range and not even _pass_ them to the game back end, so Group
    shouldn't be able to override these special events even by mistake.
    
    One fiddly consequence is that in gtk.c I've had to rethink the menu
    accelerator system. I was adding visible menu accelerators to a few
    menu items, so that (for example) 'U' and 'R' showed up to the right
    of Undo and Redo in the menu. Of course this had the side effect of
    making them real functioning accelerators from GTK's point of view,
    which activate the menu item in the same way as usual, causing it to
    send whatever keystroke the menu item generates. In other words,
    whenever I entered 'n' into a cell in a large Group game, this was the
    route followed by even a normal 'n' originated from a real keystroke -
    it activated the New Game menu item by mistake, which would then send
    'n' by mistake instead of starting a new game!
    
    Those mistakes cancelled each other out, but now I've fixed the
    latter, I've had to fix the former too or else the GTK front end would
    now undo all of this good work, by _always_ translating 'n' on the
    keyboard to UI_NEWGAME, even if the puzzle would have wanted to treat
    a real press of 'n' differently. So I've fixed _that_ in turn by
    putting those menu accelerators in a GtkAccelGroup that is never
    actually enabled on the main window, so the accelerator keys will be
    displayed in the menu but not processed by GTK's keyboard handling.
    
    (Also, while I was redoing this code, I've removed the logic in
    add_menu_item_with_key that reverse-engineered an ASCII value into
    Control and Shift modifiers plus a base key, because the only
    arguments to that function were fixed at compile time anyway so it's
    easier to just write the results of that conversion directly into the
    call sites; and I've added the GTK_ACCEL_LOCKED flag, in recognition
    of the fact that _because_ these accelerators are processed by a weird
    mechanism, they cannot be dynamically reconfigured by users and
    actually work afterwards.)

 PuzzleApplet.java | 12 +++------
 emcc.c            |  6 ++---
 gtk.c             | 73 ++++++++++++++++++++++++++-----------------------------
 midend.c          | 27 ++++++++++++--------
 nestedvm.c        | 28 +++++++++++++++++++--
 osx.m             |  6 ++---
 puzzles.h         | 10 ++++++++
 windows.c         |  8 +++---
 8 files changed, 101 insertions(+), 69 deletions(-)

commit d72db91888c1efddd56c67eee665b0a83c9329eb
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=d72db91888c1efddd56c67eee665b0a83c9329eb;hp=e4d05c36d996c3053a66ca29cfe84e9652d501e3
Author: Simon Tatham <anakin at pobox.com>
Date:   Wed Sep 20 16:38:31 2017 +0100

    Map Ctrl-Shift-Z to Redo.
    
    This is in addition to the existing keystrokes r, ^R and ^Y. I've
    become used to Ctrl-Shift-Z in other GUI games, and my fingers keep
    getting confused when my own puzzles don't handle it the same way.

 PuzzleApplet.java |  7 ++++++-
 emcc.c            |  6 ++++--
 gtk.c             |  2 ++
 osx.m             |  4 ++++
 windows.c         | 14 ++++++++++++--
 5 files changed, 28 insertions(+), 5 deletions(-)

commit 61e711178455dbd0ec8f78d15791b7e25fbf7156
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=61e711178455dbd0ec8f78d15791b7e25fbf7156;hp=d72db91888c1efddd56c67eee665b0a83c9329eb
Author: Simon Tatham <anakin at pobox.com>
Date:   Wed Sep 20 10:22:28 2017 +0100

    Build test HTML wrapper pages for the Javascript puzzles.
    
    This should make it less annoying for me to do local testing of the JS
    output of a build, before I push a change. There's a new
    build.out/jstest directory containing .html files suitable for loading
    in a local browser, which refer to the JS files via an appropriate
    relative path to the existing build.out/js directory.

 Buildscr       | 11 +++++++++++
 html/jspage.pl | 13 ++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)



More information about the tartarus-commits mailing list