コード例 #1
0
ファイル: routines.c プロジェクト: zcw159357/citadel
/* Destructive backspace */
void back(int spaces) {
	int a;
	for (a=0; a<spaces; ++a) {
		scr_putc(8);
		scr_putc(32);
		scr_putc(8);
	}
}
コード例 #2
0
ファイル: screen.c プロジェクト: mingodad/citadel
/*
 * Issue the paginator prompt (more / hit any key to continue)
 */
void hit_any_key(void) {
	int a, b;

	color(COLOR_PUSH);
	color(DIM_RED);
	scr_printf("%s\r", moreprompt);
	color(COLOR_POP);
	b=inkey();
	for (a=0; a<screenwidth; ++a) {
		scr_putc(' ');
	}
	scr_printf("\r");

	if ( (rc_prompt_control == 1) || ((rc_prompt_control == 3) && (userflags & US_PROMPTCTL)) ) {
		if (b == 'q' || b == 'Q' || b == 's' || b == 'S') {
			b = STOP_KEY;
		}
		if (b == 'n' || b == 'N') {
			b = NEXT_KEY;
		}
	}

	if (b==NEXT_KEY) sigcaught = SIGINT;
	if (b==STOP_KEY) sigcaught = SIGQUIT;
}
コード例 #3
0
ファイル: screen.c プロジェクト: mingodad/citadel
/*
 * scr_printf() outputs to the terminal
 */
int scr_printf(char *fmt, ...)
{
	static char outbuf[4096];	/* static for performance -- not re-entrant -- change if needed */
	va_list ap;
	register int retval;
	int i, len;

	va_start(ap, fmt);
	retval = vsnprintf(outbuf, sizeof outbuf, fmt, ap);
	va_end(ap);

	len = strlen(outbuf);
	for (i=0; i<len; ++i) {
		scr_putc(outbuf[i]);
	}
	return retval;
}
コード例 #4
0
ファイル: screen.c プロジェクト: mingodad/citadel
/*
 * Output one character to the terminal
 */
int scr_putc(int c)
{
	/* handle tabs normally */
	if (c == '\t') {
		do {
			scr_putc(' ');
		} while ((cols_printed % 8) != 0);
		return(c);
	}

	/* Output the character... */
	if (putc(c, stdout) == EOF) {
		logoff(NULL, 3);
	}

	if (c == '\n') {
		++lines_printed;
		cols_printed = 0;
	}
	else if (c == '\r') {
		cols_printed = 0;
	}
	else if (isprint(c)) {
		++cols_printed;
		if ((screenwidth > 0) && (cols_printed > screenwidth)) {
			++lines_printed;
			cols_printed = 0;
		}
	}

	/* How many lines output before stopping for the paginator?
	 * Depends on whether we are displaying a status line.
	 */
	int height_offset = ( ((enable_color) && (screenwidth > 0) && (enable_status_line)) ? (3) : (2) ) ;

	/* Ok, go check it.  Stop and display the paginator prompt if necessary. */
	if ((screenheight > 0) && (lines_printed > (screenheight-height_offset))) {
		lines_printed = 0;
		hit_any_key();
		lines_printed = 0;
		cols_printed = 0;
	}

	return c;
}