Refactor button & ~MOD_MASK' as STRIP_BUTTON_MODIFIERS(button)'.

This refactors all instances of bitwise-ANDs with `~MOD_MASK'. There is
a handful of more complex instances I left unchanged (in cube.c, midend.c,
and twiddle.c), since those AND with `~MOD_MASK | MOD_NUM_KEYPAD' or
similar. I don't think it's worth writing a macro for those cases.

Also document this new macro's usage in devel.but.
This commit is contained in:
Franklin Wei
2024-07-21 18:06:37 -04:00
committed by Simon Tatham
parent c010ca122f
commit 5de69c22b0
20 changed files with 32 additions and 22 deletions

View File

@ -1161,8 +1161,10 @@ input probably just wants to treat the numeric keypad as numbers).
\dt \cw{MOD_MASK}
\dd This mask is the bitwise OR of all the available modifiers; you
can bitwise-AND with \cw{~MOD_MASK} to strip all the modifiers off
any input value.
can bitwise-AND with \cw{~MOD_MASK} to strip all the modifiers off any
input value; as this is a common operation, the
\cw{STRIP_BUTTON_MODIFIERS()} macro can do this for you (see
\k{utils-strip-button-modifiers}).
\S{backend-execute-move} \cw{execute_move()}
@ -5322,6 +5324,12 @@ many domino tilings of the same grid.
The returned array is delivered in \c{grid}.
\S{utils-strip-button-modifiers} \cw{STRIP_BUTTON_MODIFIERS()}
This macro, defined in the main Puzzles header file, strips the
modifier flags from the key code passed as an argument. It is
equivalent to a bitwise-AND with \cw{~MOD_MASK}.
\C{writing} How to write a new puzzle
This chapter gives a guide to how to actually write a new puzzle: