File: mactopl.c

package info (click to toggle)
glhack 1.2-8.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,744 kB
  • sloc: ansic: 208,571; cpp: 13,139; yacc: 2,005; makefile: 1,152; lex: 377; sh: 121; awk: 89; sed: 11
file content (65 lines) | stat: -rw-r--r-- 1,398 bytes parent folder | download | duplicates (23)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*	SCCS Id: @(#)mactopl.c	3.1	91/07/23 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed.  See license for details. */

#include "hack.h"
#include "mactty.h"
#include "macwin.h"
#include "macpopup.h"

char
queued_resp(char *resp) {
	char buf[30];
	if (try_key_queue(buf)) {
		if (!resp || strchr(resp, buf[0]))
			return buf[0];
		if (digit(buf[0]) && strchr(resp, '#')) {
			yn_number = atoi(buf);
			return '#';
		}
	}
	return '\0';
}


char
topl_yn_function(const char *query, const char *resp, char def) {
	char buf[30];
	char c = queued_resp((char *) resp);
	if (!c) {
		enter_topl_mode((char *) query);
		topl_set_resp((char *) resp, def);

		do {
			c = readchar();
			if (c && resp && !strchr(resp, c)) {
				nhbell();
				c = '\0';
			}
		} while (!c);

		topl_set_resp("", '\0');
		leave_topl_mode(buf);
		if (c == '#')
			yn_number = atoi(buf);
	}
	return c;
}


char
mac_yn_function(query, resp, def)
const char *query,*resp;
char def;
/*
 *   Generic yes/no function. 'def' is the default (returned by space or
 *   return; 'esc' returns 'q', or 'n', or the default, depending on
 *   what's in the string. The 'query' string is printed before the user
 *   is asked about the string.
 *   If resp is NULL, any single character is accepted and returned.
 */
{
		return topl_yn_function(query, resp, def);
}

/* mactopl.c */