예제 #1
0
파일: trace.c 프로젝트: rodrigc/bz-vimage
void
dlg_trace_win(WINDOW *win)
{
    if (myFP != 0) {
	int y, x;
	int j, k;
	int rc = getmaxy(win);
	int cc = getmaxx(win);
	chtype ch, c2;

	fprintf(myFP, "window %dx%d at %d,%d\n",
		rc, cc, getbegy(win), getbegx(win));

	getyx(win, y, x);
	for (j = 0; j < rc; ++j) {
	    fprintf(myFP, "%3d:", j);
	    for (k = 0; k < cc; ++k) {
		ch = mvwinch(win, j, k) & (A_CHARTEXT | A_ALTCHARSET);
		c2 = dlg_asciibox(ch);
		if (c2 != 0) {
		    ch = c2;
		} else if (unctrl(ch) == 0 || strlen(unctrl(ch)) > 1) {
		    ch = '.';
		}
		fputc((int) (ch & 0xff), myFP);
	    }
	    fputc('\n', myFP);
	}
	wmove(win, y, x);
	fflush(myFP);
    }
}
예제 #2
0
void
chase_it(coord *runner, struct thing *th)
{
    struct linked_list  *item;
    struct thing    *tp;

    /* If we couldn't find him, something is funny */

    if ((item = find_mons(runner->y, runner->x)) == NULL)
    {
        debug("CHASER '%s'", unctrl(winat(runner->y, runner->x)));
        return;
    }

    tp = THINGPTR(item);

    /* Start the beastie running */

    tp->t_ischasing = TRUE;
    tp->t_chasee    = th;

    turn_on(*tp, ISRUN);
    turn_off(*tp, ISDISGUISE);

    return;
}
예제 #3
0
cell pp_curs_unctrl(cell x) {
	char	*s;

	if (!Running) return UNSPECIFIC;
	s = (char *) unctrl(integer_value("curs:unctrl", car(x)));
	return make_string(s, strlen(s));
}
예제 #4
0
파일: pack.c 프로젝트: Elronnd/rogomatic
/*
 * get_item:
 *	Pick something out of a pack for a purpose
 */
THING *
get_item(char *purpose, int type)
{
    THING *obj;
    char ch;

    if (pack == NULL)
	msg("you aren't carrying anything");
    else if (again)
	if (last_pick)
	    return last_pick;
	else
	    msg("you ran out");
    else
    {
	for (;;)
	{
	    if (!terse)
		addmsg("which object do you want to ");
	    addmsg(purpose);
	    if (terse)
		addmsg(" what");
	    msg("? (* for list): ");
	    ch = readchar();
	    mpos = 0;
	    /*
	     * Give the poor player a chance to abort the command
	     */
	    if (ch == ESCAPE)
	    {
		reset_last();
		after = FALSE;
		msg("");
		return NULL;
	    }
	    n_objs = 1;		/* normal case: person types one char */
	    if (ch == '*')
	    {
		mpos = 0;
		if (inventory(pack, type) == 0)
		{
		    after = FALSE;
		    return NULL;
		}
		continue;
	    }
	    for (obj = pack; obj != NULL; obj = next(obj))
		if (obj->o_packch == ch)
		    break;
	    if (obj == NULL)
	    {
		msg("'%s' is not a valid item",unctrl(ch));
		continue;
	    }
	    else 
		return obj;
	}
    }
    return NULL;
}
예제 #5
0
파일: pack.c 프로젝트: Elronnd/rogomatic
void
picky_inven()
{
    THING *obj;
    char mch;

    if (pack == NULL)
	msg("you aren't carrying anything");
    else if (next(pack) == NULL)
	msg("a) %s", inv_name(pack, FALSE));
    else
    {
	msg(terse ? "item: " : "which item do you wish to inventory: ");
	mpos = 0;
	if ((mch = readchar()) == ESCAPE)
	{
	    msg("");
	    return;
	}
	for (obj = pack; obj != NULL; obj = next(obj))
	    if (mch == obj->o_packch)
	    {
		msg("%c) %s", mch, inv_name(obj, FALSE));
		return;
	    }
	msg("'%s' not in pack", unctrl(mch));
    }
}
예제 #6
0
/*
 * picky_inven:
 *	Allow player to inventory a single item
 */
void
picky_inven()
{
    struct linked_list *item;
    int ch, mch;

    if (pack == NULL)
	msg("You aren't carrying anything");
    else if (next(pack) == NULL)
	msg("a) %s", inv_name((struct object *) ldata(pack), FALSE));
    else
    {
	msg(terse ? "Item: " : "Which item do you wish to inventory: ");
	mpos = 0;
	if ((mch = readchar(cw)) == ESCAPE)
	{
	    msg("");
	    return;
	}
	for (ch = 'a', item = pack; item != NULL; item = next(item), ch++)
	    if (ch == mch)
	    {
		msg("%c) %s",ch,inv_name((struct object *) ldata(item), FALSE));
		return;
	    }
	if (!terse)
	    msg("'%s' not in pack", unctrl(mch));
	msg("Range is 'a' to '%c'", --ch);
    }
}
예제 #7
0
파일: background.c 프로젝트: ryo/netbsd-src
/*
 * wbkgd --
 *	Set new background and new background attributes.
 */
int
wbkgd(WINDOW *win, chtype ch)
{
	int	y, x;

#ifdef DEBUG
	__CTRACE(__CTRACE_ATTR, "wbkgd: (%p), '%s', %08x\n",
	    win, unctrl(ch & +__CHARTEXT), ch & __ATTRIBUTES);
#endif

	/* Background attributes (check colour). */
	if (__using_color && !(ch & __COLOR))
		ch |= __default_color;

	win->battr = (attr_t) ch & __ATTRIBUTES;
	wbkgdset(win, ch);
	for (y = 0; y < win->maxy; y++)
		for (x = 0; x < win->maxx; x++) {
			/* Copy character if space */
			if (ch & A_CHARTEXT && win->alines[y]->line[x].ch == ' ')
				win->alines[y]->line[x].ch = ch & __CHARTEXT;
			/* Merge attributes */
			if (win->alines[y]->line[x].attr & __ALTCHARSET)
				win->alines[y]->line[x].attr =
				    (ch & __ATTRIBUTES) | __ALTCHARSET;
			else
				win->alines[y]->line[x].attr =
				    ch & __ATTRIBUTES;
#ifdef HAVE_WCHAR
			SET_WCOL(win->alines[y]->line[x], 1);
#endif
		}
	__touchwin(win);
	return(OK);
}
예제 #8
0
static chtype *
ChStr(const char *source)
{
    if (source != 0) {
        size_t need = ChLen(source) + 1;
        int n = 0;

        if (need > temp_length) {
            temp_length = need * 2;
            temp_buffer = typeRealloc(chtype, temp_length, temp_buffer);
        }
        do {
            const char *s;
            chtype ch = UChar(*source++);
            if (!pass_ctls && (s = unctrl(ch)) != 0) {
                while (*s != '\0') {
                    temp_buffer[n++] = UChar(*s++);
                }
            } else {
                temp_buffer[n++] = ch;
            }
        } while (source[0] != 0);
        temp_buffer[n] = 0;
    } else if (temp_buffer != 0) {
        free(temp_buffer);
        temp_buffer = 0;
        temp_length = 0;
    }
    return temp_buffer;
}
예제 #9
0
파일: io.c 프로젝트: lattera/openbsd
/*
 * get_line:
 *      Reads the next line up to '\n' or EOF.  Multiple spaces are
 *	compressed to one space; a space is inserted before a ','
 */
char *
get_line(void)
{
	size_t pos;
	int c, oy, ox;
	WINDOW *oscr;

	oscr = stdscr;
	stdscr = Msgwin;
	getyx(stdscr, oy, ox);
	refresh();
	/* loop reading in the string, and put it in a temporary buffer */
	for (pos = 0; (c = readchar()) != '\n'; clrtoeol(), refresh()) {
		if (c == -1)
			continue;
		if (c == ' ' && (pos == 0 || linebuf[pos - 1] == ' '))
			continue;
		if (c == erasechar()) {
			if (pos > 0) {
				int i;
				pos--;
				for (i = strlen(unctrl(linebuf[pos])); i; i--)
					addch('\b');
			}
			continue;
		}
		if (c == killchar()) {
			pos = 0;
			move(oy, ox);
			continue;
		}
		if (pos >= LINESIZE - 1 || !(isalnum(c) || c == ' ')) {
			beep();
			continue;
		}
		if (islower(c))
			c = toupper(c);
		linebuf[pos++] = c;
		addstr(unctrl(c));
		Mpos++;
	}
	while (pos < sizeof(linebuf))
		linebuf[pos++] = '\0';
	stdscr = oscr;
	return (linebuf);
}
예제 #10
0
파일: putchar.c 프로젝트: andreiw/polaris
int
_putchar(char c)
{
#ifdef DEBUG
	fprintf(outf, "_PUTCHAR(%s)\n", unctrl(c));
#endif
	return (putchar(c));
}
예제 #11
0
파일: io.c 프로젝트: ajinkya93/netbsd-src
/*
 * get_line:
 *      Reads the next line up to '\n' or EOF.  Multiple spaces are
 *	compressed to one space; a space is inserted before a ','
 */
char *
get_line(void)
{
	size_t pos;
	int c, oy, ox;
	WINDOW *oscr;

	oscr = stdscr;
	stdscr = Msgwin;
	getyx(stdscr, oy, ox);
	refresh();
	/* loop reading in the string, and put it in a temporary buffer */
	for (pos = 0; (c = readchar()) != '\n'; clrtoeol(), refresh()) {
			if (c == erasechar()) {	/* process erase character */
				if (pos > 0) {
					int i;

					pos--;
					for (i = strlen(unctrl(linebuf[pos])); i; i--)
						addch('\b');
				}
				continue;
			} else
				if (c == killchar()) {	/* process kill
							 * character */
					pos = 0;
					move(oy, ox);
					continue;
				} else
					if (pos == 0 && c == ' ')
						continue;
		if (pos >= LINESIZE - 1 || !(isprint(c) || c == ' '))
			putchar(CTRL('G'));
		else {
			if (islower(c))
				c = toupper(c);
			linebuf[pos++] = c;
			addstr(unctrl(c));
			Mpos++;
		}
	}
	linebuf[pos] = '\0';
	stdscr = oscr;
	return (linebuf);
}
예제 #12
0
void
dlg_trace_chr(int ch, int fkey)
{
    if (myFP != 0) {
	const char *fkey_name = "?";
	if (fkey) {
	    if (fkey > KEY_MAX || (fkey_name = keyname(fkey)) == 0) {
#define CASE(name) case name: fkey_name = #name; break
		switch ((DLG_KEYS_ENUM) fkey) {
		    CASE(DLGK_MIN);
		    CASE(DLGK_OK);
		    CASE(DLGK_CANCEL);
		    CASE(DLGK_EXTRA);
		    CASE(DLGK_HELP);
		    CASE(DLGK_ESC);
		    CASE(DLGK_PAGE_FIRST);
		    CASE(DLGK_PAGE_LAST);
		    CASE(DLGK_PAGE_NEXT);
		    CASE(DLGK_PAGE_PREV);
		    CASE(DLGK_ITEM_FIRST);
		    CASE(DLGK_ITEM_LAST);
		    CASE(DLGK_ITEM_NEXT);
		    CASE(DLGK_ITEM_PREV);
		    CASE(DLGK_FIELD_FIRST);
		    CASE(DLGK_FIELD_LAST);
		    CASE(DLGK_FIELD_NEXT);
		    CASE(DLGK_FIELD_PREV);
		    CASE(DLGK_GRID_UP);
		    CASE(DLGK_GRID_DOWN);
		    CASE(DLGK_GRID_LEFT);
		    CASE(DLGK_GRID_RIGHT);
		    CASE(DLGK_DELETE_LEFT);
		    CASE(DLGK_DELETE_RIGHT);
		    CASE(DLGK_DELETE_ALL);
		    CASE(DLGK_ENTER);
		    CASE(DLGK_BEGIN);
		    CASE(DLGK_FINAL);
		    CASE(DLGK_SELECT);
		    CASE(DLGK_HELPFILE);
		    CASE(DLGK_TRACE);
		}
	    }
	} else if (ch == ERR) {
	    fkey_name = "ERR";
	} else {
	    fkey_name = unctrl((chtype) ch);
	    if (fkey_name == 0)
		fkey_name = "UNKNOWN";
	}
	fprintf(myFP, "chr %s (ch=%#x, fkey=%d)\n",
		fkey_name,
		ch, fkey);
	fflush(myFP);
    }
}
 /*
  * copy string using unctrl for things
  */
 void
 strucpy(char *s1, char *s2, size_t len)
 {
     const char *sp;
 
     while (len--)
     {
 	strcpy(s1, (sp = unctrl(*s2++)));
 	s1 += strlen(sp);
     }
     *s1 = '\0';
 }
예제 #14
0
char *
unctrl(chtype ch)
{
	char	*str;
	int	c, msb;
	static char	chr[5];


	/* Map wide character to a wide string. */
	c = (int)(ch & A_CHARTEXT);
	msb = 1 << (CHAR_BIT-1);

	if (c & ~((1 << CHAR_BIT) - 1)) {
		/* Only know about single-byte characters I guess ... */
		return (NULL);
	}
	if (iscntrl(c)) {
		/* ASCII DEL */
		if (c == 127)
			return ((char *)carat[0]);

		/* ASCII control codes. */
		if (0 <= c && c < 32)
			return ((char *)carat[c+1]);

		/* Something we don't know what to do with. */
		return (NULL);
	} else if (c & msb) {
		/* Meta key notation if high bit is set on character. */
		c &= ~msb;

		chr[0] = 'M';
		chr[1] = '-';

		if (iscntrl(c)) {
			str = (char *) unctrl(c);
			chr[2] = *str++;
			chr[3] = *str;
			chr[4] = '\0';
		} else {
			chr[2] = (char)c;
			chr[3] = '\0';
		}
	} else {
		/* Return byte as is. */
		chr[0] = (char)c;
		chr[1] = '\0';
	}

	return (chr);
}
예제 #15
0
int main(void)
{
	char ch;

	initscr();

	ch = erasechar();
	printw("The Erasechar is 0x%02x or %s\n",ch,unctrl(ch));
	refresh();
	getch();

	endwin();
	return 0;
}
예제 #16
0
wunctrl(cchar_t *wc)
{
    static wchar_t str[CCHARW_MAX + 1], *sp;

    if (Charable(*wc)) {
	const char *p = unctrl((unsigned) _nc_to_char((wint_t) CharOf(*wc)));

	for (sp = str; *p; ++p) {
	    *sp++ = _nc_to_widechar(*p);
	}
	*sp = 0;
	return str;
    } else
	return wc->chars;
}
예제 #17
0
파일: trace.c 프로젝트: andreiw/polaris
char *
_asciify(char *str)
{
	static	char	string[1024];
	char	*p1 = string;
	char	*p2;
	char	c;

	while (c = *str++) {
		p2 = unctrl(c);
		while (*p1 = *p2++)
			p1++;
	}
	return (string);
}
예제 #18
0
파일: misc.c 프로젝트: mikekmv/aeriebsd-src
CARD
getcard()
{
	int	c, c1;

	for (;;) {
		while ((c = readch()) == '\n' || c == '\r' || c == ' ')
			continue;
		if (islower(c))
			c = toupper(c);
		if (c == killchar() || c == erasechar())
			return -1;
		addstr(unctrl(c));
		clrtoeol();
		switch (c) {
		  case '1':	case '2':	case '3':
		  case '4':	case '5':	case '6':
			c -= '0';
			break;
		  case '0':	case 'P':	case 'p':
			c = 0;
			break;
		  default:
			beep();
			addch('\b');
			if (!isprint(c))
				addch('\b');
			c = -1;
			break;
		}
		refresh();
		if (c >= 0) {
			while ((c1 = readch()) != '\r' && c1 != '\n' && c1 != ' ')
				if (c1 == killchar())
					return -1;
				else if (c1 == erasechar()) {
					addch('\b');
					clrtoeol();
					refresh();
					goto cont;
				}
				else
					beep();
			return c;
		}
cont:		;
	}
}
예제 #19
0
/*
 * This routine gets all the terminal flags from the termcap database
 */
static void
zap()
{
	register char	*namp;
	register bool	**fp;
	register char	***sp;
#ifdef	DEBUG
	register char	*cp;
#endif

	namp = "ambsdadbeohchzinmimsncnsosulxbxnxtxsxx";
	fp = sflags;
	do {
		*(*fp++) = tgetflag(namp);
#ifdef DEBUG
		fprintf(outf, "%2.2s = %s\n", namp, *fp[-1] ? "TRUE" : "FALSE");
#endif
		namp += 2;
	} while (*namp);
	namp = "albcbtcdceclcmcrcsdcdldmdoedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmandnlpcrcscsesfsosrtatetiucueupusvbvsveALDLUPDOLERI";
	sp = sstrs;
	do {
		*(*sp++) = tgetstr(namp, &aoftspace);
#ifdef DEBUG
		fprintf(outf, "%2.2s = %s", namp, *sp[-1] == NULL ? "NULL\n" : "\"");
		if (*sp[-1] != NULL) {
			for (cp = *sp[-1]; *cp; cp++)
				fprintf(outf, "%s", unctrl(*cp));
			fprintf(outf, "\"\n");
		}
#endif
		namp += 2;
	} while (*namp);
	if (XS)
		SO = SE = NULL;
	else {
		if (tgetnum("sg") > 0)
			SO = NULL;
		if (tgetnum("ug") > 0)
			US = NULL;
		if (!SO && US) {
			SO = US;
			SE = UE;
		}
	}
	if (DO && !NL)
	        NL = DO;
}
예제 #20
0
파일: background.c 프로젝트: ryo/netbsd-src
/*
 * wbkgdset
 *	Set new background attributes.
 */
void
wbkgdset(WINDOW *win, chtype ch)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_ATTR, "wbkgdset: (%p), '%s', %08x\n",
	    win, unctrl(ch & +__CHARTEXT), ch & __ATTRIBUTES);
#endif

	/* Background character. */
	if (ch & __CHARTEXT)
		win->bch = (wchar_t) ch & __CHARTEXT;

	/* Background attributes (check colour). */
	if (__using_color && !(ch & __COLOR))
		ch |= __default_color;
	win->battr = (attr_t) ch & __ATTRIBUTES;
}
예제 #21
0
파일: getch.c 프로젝트: AgamAgarwal/minix
/*
 * Init_getch - initialise all the pointers & structures needed to make
 * getch work in keypad mode.
 *
 */
void
__init_getch(SCREEN *screen)
{
	char entry[1024], *p;
	const char *s;
	int     i;
	size_t limit, l;
#ifdef DEBUG
	int k, length;
#endif

	/* init the inkey state variable */
	state = INKEY_NORM;

	/* init the base keymap */
	screen->base_keymap = new_keymap();

	/* key input buffer pointers */
	start = end = working = 0;

	/* now do the terminfo snarfing ... */

	for (i = 0; i < num_tcs; i++) {
		p = entry;
		limit = 1023;
		s = screen->term->strs[tc[i].code];
		if (s == NULL)
			continue;
		l = strlen(s) + 1;
		if (limit < l)
			continue;
		strlcpy(p, s, limit);
		p += l;
		limit -= l;
#ifdef DEBUG
			__CTRACE(__CTRACE_INIT,
			    "Processing terminfo entry %d, sequence ",
			    tc[i].code);
			length = (int) strlen(entry);
			for (k = 0; k <= length -1; k++)
				__CTRACE(__CTRACE_INIT, "%s", unctrl(entry[k]));
			__CTRACE(__CTRACE_INIT, "\n");
#endif
		add_key_sequence(screen, entry, tc[i].symbol);
	}
}
예제 #22
0
/*
 * getguess:
 *	Get another guess
 */
void
getguess(void)
{
	int i;
	int ch, uch;
	bool correct;

	leaveok(stdscr, FALSE);
	for (;;) {
		move(PROMPTY, PROMPTX + sizeof("Guess: "));
		refresh();
		ch = readch();
		if (isalpha(ch)) {
			if (isupper(ch))
				ch = tolower(ch);
			if (Guessed[ch - 'a'])
				mvprintw(MESGY, MESGX, "Already guessed '%c'", ch);
			else
				break;
		}
		else if (ch == CTRL('D'))
			die(0);
		else
			mvprintw(MESGY, MESGX, "Not a valid guess: '%s'",
				unctrl(ch));
	}
	leaveok(stdscr, TRUE);
	move(MESGY, MESGX);
	clrtoeol();

	Guessed[ch - 'a'] = TRUE;
	correct = FALSE;
	uch = toupper(ch);
	for (i = 0; Word[i] != '\0'; i++) {
		if (Word[i] == ch) {
			Known[i] = ch;
			correct = TRUE;
		} else if (Word[i] == uch) {
			Known[i] = uch;
			correct = TRUE;
		}
	}
	if (!correct)
		Errors++;
}
예제 #23
0
static char *
save_tc_char(char *bufptr, int c1)
{
    char temp[80];

    if (is7bits(c1) && isprint(c1)) {
	if (c1 == ':' || c1 == '\\')
	    bufptr = save_char(bufptr, '\\');
	bufptr = save_char(bufptr, c1);
    } else {
	if (c1 == (c1 & 0x1f))	/* iscntrl() returns T on 255 */
	    _nc_STRCPY(temp, unctrl((chtype) c1), sizeof(temp));
	else
	    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "\\%03o", c1);
	bufptr = save_string(bufptr, temp);
    }
    return bufptr;
}
예제 #24
0
static
#if !USE_WIDEC_SUPPORT		/* cannot be inline if it is recursive */
NCURSES_INLINE
#endif
int
waddch_literal(WINDOW *win, NCURSES_CH_T ch)
{
    int x;
    int y;
    struct ldat *line;

    x = win->_curx;
    y = win->_cury;

    CHECK_POSITION(win, x, y);

    ch = render_char(win, ch);

    line = win->_line + y;

    CHANGED_CELL(line, x);

    /*
     * Build up multibyte characters until we have a wide-character.
     */
    if_WIDEC({
	if (WINDOW_EXT(win, addch_used) != 0 || !Charable(ch)) {
	    int len = _nc_build_wch(win, CHREF(ch));

	    if (len >= -1) {
		/* handle EILSEQ */
		if (is8bits(CharOf(ch))) {
		    const char *s = unctrl((chtype) CharOf(ch));
		    if (s[1] != 0) {
			return waddstr(win, s);
		    }
		}
		if (len == -1)
		    return waddch(win, ' ');
	    } else {
		return OK;
	    }
	}
    });
예제 #25
0
static size_t
ChLen(const char *source)
{
    size_t result = strlen(source);

    if (!pass_ctls) {
        size_t adjust = 0;
        size_t n;

        for (n = 0; n < result; ++n) {
            const char *s = unctrl(UChar(source[n]));
            if (s != 0) {
                adjust += (strlen(s) - 1);
            }
        }
        result += adjust;
    }
    return result;
}
예제 #26
0
static size_t
ChWLen(const wchar_t *source)
{
    size_t result = wcslen(source);

    if (!pass_ctls) {
	size_t adjust = 0;
	size_t n;
	const char *s;

	for (n = 0; n < result; ++n) {
	    if (source[n] < 256 && (s = unctrl((chtype) source[n])) != 0) {
		adjust += (strlen(s) - 1);
	    }
	}
	result += adjust;
    }
    return result;
}
예제 #27
0
/*
 * runto:
 *	Set a mosnter running after something
 *	or stop it from running (for when it dies)
 */
void
runto(coord *runner, coord *spot)
{
    register struct linked_list *item;
    register struct thing *tp;

    /*
     * If we couldn't find him, something is funny
     */
    if ((item = find_mons(runner->y, runner->x)) == NULL) {
	debug("CHASER '%s'", unctrl(winat(runner->y, runner->x)));
	return;
    }
    tp = (struct thing *) ldata(item);
    /*
     * Start the beastie running
     */
    tp->t_dest = spot;
    turn_on(*tp, ISRUN);
    turn_off(*tp, ISDISGUISE);
}
예제 #28
0
void
runto(coord *runner, coord *spot)
{
    struct linked_list *item;
    struct thing *tp;

    /*
     * If we couldn't find him, something is funny
     */
    if ((item = find_mons(runner->y, runner->x)) == NULL)
    {
	msg("CHASER '%s'", unctrl(winat(runner->y, runner->x)));
	return;
    }
    tp = (struct thing *) ldata(item);
    /*
     * Start the beastie running
     */
    tp->t_dest = spot;
    tp->t_flags |= ISRUN;
    tp->t_flags &= ~ISHELD;
}
예제 #29
0
파일: misc.c 프로젝트: ajinkya93/netbsd-src
/*
 *	Get a yes or no answer to the given question.  Saves are
 * also allowed.  Return TRUE if the answer was yes, FALSE if no.
 */
int
getyn(int promptno)
{
	char	c;

	Saved = FALSE;
	for (;;) {
		leaveok(Board, FALSE);
		prompt(promptno);
		clrtoeol();
		refresh();
		switch (c = readch()) {
		  case 'n':	case 'N':
			addch('N');
			refresh();
			leaveok(Board, TRUE);
			return FALSE;
		  case 'y':	case 'Y':
			addch('Y');
			refresh();
			leaveok(Board, TRUE);
			return TRUE;
		  case 's':	case 'S':
			addch('S');
			refresh();
			Saved = save();
			continue;
		  case CTRL('L'):
			wrefresh(curscr);
			break;
		  default:
			addstr(unctrl(c));
			refresh();
			putchar('\07');
			break;
		}
	}
}
예제 #30
0
파일: pack.c 프로젝트: Elronnd/rogomatic
void
pick_up(char ch)
{
    THING *obj;

    if (on(player, ISLEVIT))
	return;

    obj = find_obj(hero.y, hero.x);
    if (move_on)
	move_msg(obj);
    else
	switch (ch)
	{
	    case GOLD:
		if (obj == NULL)
		    return;
		money(obj->o_goldval);
		detach(lvl_obj, obj);
		discard(obj);
		proom->r_goldval = 0;
		break;
	    default:
#ifdef MASTER
		debug("Where did you pick a '%s' up???", unctrl(ch));
#endif
	    case ARMOR:
	    case POTION:
	    case FOOD:
	    case WEAPON:
	    case SCROLL:	
	    case AMULET:
	    case RING:
	    case STICK:
		add_pack((THING *) NULL, FALSE);
		break;
	}
}