From: Eric S. Raymond Date: Tue, 25 Jul 2006 19:03:39 +0000 (+0000) Subject: Enable arrow keys. X-Git-Tag: 1.8~8 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=41a829135dc3a9e40403f8e1853c5cfe9d5a0b8f;p=vms-empire.git Enable arrow keys. E --- diff --git a/display.c b/display.c index 6f90017..bdc824e 100644 --- a/display.c +++ b/display.c @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.13 2006/07/25 17:21:51 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: display.c,v 1.14 2006/07/25 17:59:36 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -48,6 +48,7 @@ void init_colors(void) init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK); init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK); attron(A_BOLD); /* otherwise we get gray for white */ + keypad(stdscr, TRUE); } #endif /* A_COLOR */ @@ -58,6 +59,65 @@ void announce (char *msg) { (void) addstr (msg); } + +/* + * Map input character to direction offset. + * Attempts to enable arrow and keypad keys. + */ +int direction(c) +chtype c; +{ + switch (c) + { + case 'w': + case 'W': + case KEY_UP: + return 0; + + case 'e': + case 'E': + case KEY_A3: + case KEY_PPAGE: + return 1; + + case 'd': + case 'D': + case KEY_RIGHT: + return 2; + + case 'c': + case 'C': + case KEY_C3: + case KEY_NPAGE: + return 3; + + case 'x': + case 'X': + case KEY_DOWN: + return 4; + + case 'z': + case 'Z': + case KEY_C1: + case KEY_END: + return 5; + + case 'a': + case 'A': + case KEY_LEFT: + return 6; + + case 'q': + case 'Q': + case KEY_A1: + case KEY_HOME: + return 7; + + default: + return -1; + } +} + /* This routine is called when the current display has been trashed and no sector is shown on the screen. diff --git a/edit.c b/edit.c index 564cc8f..85609e3 100644 --- a/edit.c +++ b/edit.c @@ -114,14 +114,12 @@ This routine is an attempt to make cursor movement reasonably fast. */ -static char dirchars[] = "WwEeDdCcXxZzAaQq"; - char e_cursor (edit_cursor) long *edit_cursor; { - char e; - char *p; + chtype e; + int p; /* set up terminal */ (void) crmode (); @@ -130,10 +128,10 @@ long *edit_cursor; topini (); /* clear any error messages */ for (;;) { - p = strchr (dirchars, e); - if (!p) break; + p = direction (e); + if (p == -1) break; - if (!move_cursor (edit_cursor, dir_offset[(p-dirchars) / 2])) + if (!move_cursor (edit_cursor, dir_offset[p])) (void) beep (); (void) refresh (); diff --git a/extern.h b/extern.h index a9f8957..a9a57c0 100644 --- a/extern.h +++ b/extern.h @@ -1,4 +1,4 @@ -/* $Id: extern.h,v 1.10 2006/07/25 16:58:26 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: extern.h,v 1.11 2006/07/25 17:21:51 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -166,6 +166,7 @@ void pos_str1 (int row, int col, char *str, char *a, int b, int c, int d, int e, void addprintf (char *str, int a, int b, int c, int d, int e, int f, int g, int h); void addprintf1 (char *str, char *a, int b, int c, int d, int e, int f, int g, int h); void addprintf2 (char *str, char *a, int b, int c, int d, char *e, char *f, int g, int h); +int direction(); void init_game (void); /* game routines */ void save_game (void); diff --git a/vms-empire.6 b/vms-empire.6 index d43a5f0..2aa6da5 100644 --- a/vms-empire.6 +++ b/vms-empire.6 @@ -1,4 +1,4 @@ -.\" $Id: vms-empire.6,v 1.4 2002/08/01 18:58:22 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +.\" $Id: vms-empire.6,v 1.5 2006/07/25 15:21:01 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ .\" .\" Copyright (C) 1987, 1988 Chuck Simmons .\" @@ -459,6 +459,8 @@ following keys: .fi .ft 1 .P +The arrow and keypad keys on your terminal, if any, should also work. +.P These keys move in the direction of the key from S. The characters are not echoed and only 1 character is accepted, so there is no need for a . Hit the @@ -651,6 +653,8 @@ reverse engineered the program and wrote a version completely written in C. In doing so, he completely modified the computer strategy, the commands, the piece types, many of the piece attributes, and the algorithm for creating maps. +.P +In 1994 Eric Raymond colorized the game. .SH FILES .TP 10 \f2empsave.dat\f1 diff --git a/vms-empire.spec b/vms-empire.spec index 830c2be..1940beb 100644 --- a/vms-empire.spec +++ b/vms-empire.spec @@ -42,6 +42,7 @@ cp vms-empire.6 "$RPM_BUILD_ROOT"%{_mandir}/man6/ * Tue Jul 25 2006 Eric S. Raymond - 1.8-1 - Joe Wells's patch to enable different-sized worlds. Minor fixes to map functions by Andrew Morrow. More on the history of the game. + Enable arrow keys in edit mode. * Mon Sep 27 2004 Eric S. Raymond 1.7-1 - Documentation fixes. The old empire.doc file has been replaced