ask_num.c

来自「操作系统SunOS 4.1.3版本的源码」· C语言 代码 · 共 69 行

C
69
字号
#ifndef lintstatic  char    sccsid[] = 	"@(#)ask_num.c 1.1 92/07/30 SMI";#endif lint/* *	Name:		menu_ask_num() * *	Description:	Print get imput for a number, and don't let anthing *			else pass * *	Return value:	the digit typed in (as a char) */#include <curses.h>#include "menu.h"#include "menu_impl.h"charmenu_ask_num(x, y)	int	x,y;				/* location to put ? */{	char		ch = 0;			/* the char that was read */	char		ch1 = 0;		/* the char that was read */	int		done = 0;		/* are we done yet? */		move(y, x);	refresh();	while (!done) {		ch1 = read_menu_char();		switch (ch1) {		case '\n':		case '\r':			if (isdigit(ch))				done = 1;			break;			case CERASE:   			/*			 * If no characters pressed then break			 */			if (ch == 0)				break;			ch = 0;			mvaddch(y, x, ' ');			break;		default:			if (isdigit(ch1)) {				ch = ch1;				mvaddch(y, x, ch);			} else {				ch = 0;				break;			}		} /* end switch() */		move(y, x);		refresh();	}	return(ch);} /* menu_ask_num() */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?