Example #1
0
/*
 * Return the (numeric) option id.
 * Numeric options look like
 *	li#80
 * i.e. the option string is separated from the numeric value by
 * a # character.  If the option is not found we return -1.
 * Note that we handle octal numbers beginning with 0.
 *
 * Slip in implicit knowledge here that li/co are window geometry,
 * and that FD 0 is the place whose geometry concerns us.
 */
int
tgetnum(char *id)
{
	int i, base, rows, cols;
	char *bp = tbuf;

	if (!strcmp(id, "li")) {
		if (ttysize(&rows, &cols) >= 0) {
			return(rows);
		}
	} else if (!strcmp(id, "co")) {
		if (ttysize(&rows, &cols) >= 0) {
			return(cols);
		}
	}
	for (;;) {
		bp = tskip(bp);
		if (*bp == 0)
			return (-1);
		if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1])
			continue;
		if (*bp == '@')
			return(-1);
		if (*bp != '#')
			continue;
		bp++;
		base = 10;
		if (*bp == '0')
			base = 8;
		i = 0;
		while (isdigit(*bp))
			i *= base, i += *bp++ - '0';
		return (i);
	}
}
Example #2
0
void stop_ne(void)
{
    unset_interactive_mode();
    kill(0, SIGTSTP);
    set_interactive_mode();
    clear_entire_screen();
    ttysize();
    reset_window();
}
Example #3
0
void handle_winch(const int sig)
{
    signal(sig, SIG_IGN);
    window_changed_size = ttysize();
    signal(sig, handle_winch);
}