diff options
| author | Jonas Kölker <jonaskoelker@yahoo.com> | 2015-09-21 17:39:47 +0200 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2015-10-03 16:58:50 +0100 |
| commit | d5f7c4f871200f9808e284408e28defaa8afbcd3 (patch) | |
| tree | 8576c3e1002bc8406c71977170c8f8a73305b4c7 | |
| parent | 7478275c8b46c24eb457dd3458ace3a31263295b (diff) | |
| download | puzzles-d5f7c4f871200f9808e284408e28defaa8afbcd3.zip puzzles-d5f7c4f871200f9808e284408e28defaa8afbcd3.tar.gz puzzles-d5f7c4f871200f9808e284408e28defaa8afbcd3.tar.bz2 puzzles-d5f7c4f871200f9808e284408e28defaa8afbcd3.tar.xz | |
Range: add pencil marks to squares by Shift-cursor keys.
| -rw-r--r-- | puzzles.but | 4 | ||||
| -rw-r--r-- | range.c | 33 |
2 files changed, 35 insertions, 2 deletions
diff --git a/puzzles.but b/puzzles.but index ef96ad1..e22c438 100644 --- a/puzzles.but +++ b/puzzles.but @@ -2917,7 +2917,9 @@ dotted or empty) in opposite directions. You can also use the cursor keys to move around the grid squares. Pressing Return does the same as clicking with the left button, while -pressing Space does the same as a right button click. +pressing Space does the same as a right button click. Moving with the +cursor keys while holding Shift will place dots in all squares that +are moved through. (All the actions described in \k{common-actions} are also available.) @@ -1273,6 +1273,8 @@ static char *interpret_move(const game_state *state, game_ui *ui, enum {none, forwards, backwards, hint}; int const w = state->params.w, h = state->params.h; int r = ui->r, c = ui->c, action = none, cell; + int shift = button & MOD_SHFT; + button &= ~shift; if (IS_CURSOR_SELECT(button) && !ui->cursor_show) return NULL; @@ -1330,7 +1332,36 @@ static char *interpret_move(const game_state *state, game_ui *ui, int i; for (i = 0; i < 4 && cursors[i] != button; ++i); assert (i < 4); - if (!out_of_bounds(ui->r + dr[i], ui->c + dc[i], w, h)) { + if (shift) { + int pre_r = r, pre_c = c, do_pre, do_post; + cell = state->grid[idx(r, c, state->params.w)]; + do_pre = (cell == EMPTY); + + if (out_of_bounds(ui->r + dr[i], ui->c + dc[i], w, h)) { + if (do_pre) + return nfmtstr(40, "W,%d,%d", pre_r, pre_c); + else + return NULL; + } + + ui->r += dr[i]; + ui->c += dc[i]; + + cell = state->grid[idx(ui->r, ui->c, state->params.w)]; + do_post = (cell == EMPTY); + + /* (do_pre ? "..." : "") concat (do_post ? "..." : "") */ + if (do_pre && do_post) + return nfmtstr(80, "W,%d,%dW,%d,%d", + pre_r, pre_c, ui->r, ui->c); + else if (do_pre) + return nfmtstr(40, "W,%d,%d", pre_r, pre_c); + else if (do_post) + return nfmtstr(40, "W,%d,%d", ui->r, ui->c); + else + return ""; + + } else if (!out_of_bounds(ui->r + dr[i], ui->c + dc[i], w, h)) { ui->r += dr[i]; ui->c += dc[i]; } |