diff options
author | rillig <rillig@NetBSD.org> | 2021-02-21 22:21:56 +0000 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2021-04-13 15:28:33 -0400 |
commit | e7cd658820ba2c7119b98f1c8959b6fbe8e379b7 (patch) | |
tree | a1af60bfa9dabcdf339e4baad2dc52bd59ec80cb | |
parent | 6535b2e014adf4ec8033eaf18a55e8476d124cda (diff) | |
download | bsdgames-darwin-e7cd658820ba2c7119b98f1c8959b6fbe8e379b7.tar.gz bsdgames-darwin-e7cd658820ba2c7119b98f1c8959b6fbe8e379b7.tar.zst bsdgames-darwin-e7cd658820ba2c7119b98f1c8959b6fbe8e379b7.zip |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
-rw-r--r-- | cgram/cgram.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/cgram/cgram.c b/cgram/cgram.c index e9e5813e..9379dcfe 100644 --- a/cgram/cgram.c +++ b/cgram/cgram.c @@ -1,4 +1,4 @@ -/* $NetBSD: cgram.c,v 1.10 2021/02/21 20:33:42 rillig Exp $ */ +/* $NetBSD: cgram.c,v 1.11 2021/02/21 22:21:56 rillig Exp $ */ /*- * Copyright (c) 2013, 2021 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.c,v 1.10 2021/02/21 20:33:42 rillig Exp $"); +__RCSID("$NetBSD: cgram.c,v 1.11 2021/02/21 22:21:56 rillig Exp $"); #endif #include <assert.h> @@ -361,8 +361,8 @@ closecurses(void) static void saturate_cursor(void) { - assert(cursor_y >= 0); - assert(cursor_y <= cur_max_y()); + cursor_y = imax(cursor_y, 0); + cursor_y = imin(cursor_y, cur_max_y()); assert(cursor_x >= 0); cursor_x = imin(cursor_x, cur_max_x()); @@ -445,13 +445,17 @@ handle_key(void) break; case 14: /* ^N */ case KEY_DOWN: - if (cursor_y < cur_max_y()) - cursor_y++; + cursor_y++; break; case 16: /* ^P */ case KEY_UP: - if (cursor_y > 0) - cursor_y--; + cursor_y--; + break; + case KEY_PPAGE: + cursor_y -= LINES - 2; + break; + case KEY_NPAGE: + cursor_y += LINES - 2; break; case '*': hinting = !hinting; |