From: Eric S. Raymond Date: Fri, 5 Nov 2004 01:23:34 +0000 (+0000) Subject: Set up pre- and post-command hooks. X-Git-Tag: 2.0~425 X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=commitdiff_plain;h=bed74efa98d15a3f6497c9cc721785c6e7387c07 Set up pre- and post-command hooks. --- diff --git a/io.c b/io.c index 572d395..a5ac6d9 100644 --- a/io.c +++ b/io.c @@ -98,7 +98,7 @@ void pause(int i) { } if (curses) { - waddch('\n'); + waddch(stdscr, '\n'); waddstr(stdscr, prompt); wgetnstr(stdscr, buf, sizeof(buf)); wclear(stdscr); @@ -189,8 +189,7 @@ void prouts(char *fmt, ...) { } } -void getline(char *line, int max) -{ +void getline(char *line, int max) { if (curses) { wgetnstr(stdscr, line, max); wrefresh(stdscr); @@ -199,3 +198,6 @@ void getline(char *line, int max) line[strlen(line)-1] = '\0'; } } + +void commandhook(char *cmd, int before) { +} diff --git a/sst.c b/sst.c index 77fbeb8..ee80b3f 100644 --- a/sst.c +++ b/sst.c @@ -190,6 +190,7 @@ static void makemoves(void) { } else prout("UNRECOGNIZED COMMAND."); } + commandhook(commands[i], TRUE); switch (i) { /* command switch */ case 0: // srscan srscan(1); @@ -314,6 +315,7 @@ static void makemoves(void) { helpme(); // get help break; } + commandhook(commands[i], FALSE); for (;;) { if (alldone) break; // Game has ended #ifdef DEBUG diff --git a/sst.h b/sst.h index b0da117..375e7aa 100644 --- a/sst.h +++ b/sst.h @@ -426,3 +426,4 @@ void clearscreen(void); void iostart(int); void ioend(void); void getline(char *, int); +void commandhook(char *, int);