summaryrefslogtreecommitdiffstats
path: root/sail/pl_2.c
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2009-03-15 03:33:56 +0000
committerdholland <dholland@NetBSD.org>2009-03-15 03:33:56 +0000
commitdc08b05498e19f1e07a127935993a9ebecc7eb40 (patch)
tree7211e7d47c3911884e84082f12fa4c8eb4df45b6 /sail/pl_2.c
parent89a2669a8a8be664d488ac22db57f6c9f9f2b8ec (diff)
downloadbsdgames-darwin-dc08b05498e19f1e07a127935993a9ebecc7eb40.tar.gz
bsdgames-darwin-dc08b05498e19f1e07a127935993a9ebecc7eb40.zip
Rework curses handling.
The most visible change is that the scrolling buffer of messages now actually scrolls and keeps history, and you type on the bottom line only. For now you can page through the history with ^P/^N; that's not ideal but one can't fix everything all at once. Use resizeable array code (roughly the same that I floated a while ago in connection with make) to hold the scroll.
Diffstat (limited to 'sail/pl_2.c')
-rw-r--r--sail/pl_2.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/sail/pl_2.c b/sail/pl_2.c
index c66ddae8..57d5756e 100644
--- a/sail/pl_2.c
+++ b/sail/pl_2.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl_2.c,v 1.12 2009/03/15 00:50:47 dholland Exp $ */
+/* $NetBSD: pl_2.c,v 1.13 2009/03/15 03:33:56 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_2.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_2.c,v 1.12 2009/03/15 00:50:47 dholland Exp $");
+__RCSID("$NetBSD: pl_2.c,v 1.13 2009/03/15 03:33:56 dholland Exp $");
#endif
#endif /* not lint */
@@ -89,7 +89,7 @@ newturn(int n __unused)
leave(LEAVE_HURRICAN);
display_adjust_view();
- draw_screen();
+ display_redraw();
signal(SIGALRM, newturn);
alarm(7);
@@ -101,7 +101,17 @@ play(void)
struct ship *sp;
for (;;) {
- switch (sgetch("~\b", (struct ship *)0, 0)) {
+ blockalarm();
+ display_redraw();
+ unblockalarm();
+
+ switch (sgetch("~ ", (struct ship *)0, 0)) {
+ case 14: /* ^N */
+ display_scroll_pagedown();
+ break;
+ case 16: /* ^P */
+ display_scroll_pageup();
+ break;
case 'm':
acceptmove();
break;
@@ -139,10 +149,7 @@ play(void)
break;
case '\f':
centerview();
- blockalarm();
- draw_board();
- draw_screen();
- unblockalarm();
+ display_force_full_redraw();
break;
case 'L':
mf->loadL = L_EMPTY;
@@ -170,43 +177,25 @@ play(void)
break;
case 'C':
centerview();
- blockalarm();
- draw_view();
- unblockalarm();
break;
case 'U':
upview();
- blockalarm();
- draw_view();
- unblockalarm();
break;
case 'D':
case 'N':
downview();
- blockalarm();
- draw_view();
- unblockalarm();
break;
case 'H':
leftview();
- blockalarm();
- draw_view();
- unblockalarm();
break;
case 'J':
rightview();
- blockalarm();
- draw_view();
- unblockalarm();
break;
case 'F':
lookout();
break;
case 'S':
dont_adjust = !dont_adjust;
- blockalarm();
- draw_turn();
- unblockalarm();
break;
}
}