Example #1
0
int KeyboardInput( char* string, int min_length, int max_length, int typ, int x, int y, int display_length, int num, ... )
{
	va_list key_list;
	int key;

	if( num <= 0 )
		return( EOF );
#if (PHL|PHL1000|PHL2700)
	if( typ & INPUT_ALPHA || typ & INPUT_PRINT)
		setecho( ON );
#endif
	if( display_length > max_length )
		display_length = max_length;
	display_input(string, x, y, display_length, max_length );

	cursor( ON );
	for(;;)
	{
		va_start( key_list, num );

		if( ((key = WaitForKey()) == ENT_KEY ) && (strlen( string ) < min_length ))
			continue;

		
		// map the slash to the F4 key
		if (key == F4_KEY) { 
		  key = '/';
		}

		if( check_key_input( key, num, key_list ) == OK )
		{
			va_end( key_list );	
#if (PHL|PHL1000|PHL2700)
			if( typ & INPUT_ALPHA || typ & INPUT_PRINT)
				setecho( OFF );
#endif
		

			cursor( OFF );
			return( key );
		}
		va_end( key_list );

		if( key == BS_KEY )
		{
			remove_key_from_buffer( string );
			display_input( string, x, y, display_length, max_length );
			continue;
		}
		
		store_key_in_string( key,  string, max_length, typ );
		display_input(string, x, y, display_length, max_length );
	}
}
static int do_getline(const char *prompt, char *buffer, int length, int echo)
{
	int fd;
	char *result;
	FILE *stream;

	fd = open("/dev/tty", O_RDWR);
	if(fd < 0)
		return 0;

	if(!echo) {
		if(!setecho(fd, 0)) {
			close(fd);
			return 0;
		}
	}

	stream = fdopen(fd, "r+");
	if(!stream) {
		if(!echo) {
			setecho(fd, 1);
		}
		close(fd);
		return 0;
	}

	fprintf(stream, "%s", prompt);
	fflush(stream);

	result = fgets(buffer, length, stream);

	string_chomp(buffer);

	if(!echo) {
		fprintf(stream, "\n");
		fflush(stream);
		setecho(fd, 1);
	}

	fclose(stream);

	return result != 0;
}
Example #3
0
// general: cleanup
void cleanup_terminal_noncurses(void)
{
	setecho(STDIN_FILENO, 1);
	printf("\033[0m\n");
	system("setfont /usr/share/consolefonts/Lat2-Fixed16.psf.gz  >/dev/null 2>&1");
	system("setterm -cursor on");
	system("setterm -blank 10");
	system("clear");

}
Example #4
0
int init_terminal_noncurses(int col, int bgcol, int w, int h, int bw) {

	int n, i;
	//clearing barstrings
	for (n = 0; n < 8; n++) {

		ttybarstring[n] = 0;
		barstring[n][0] ='\0';
		spacestring[0] ='\0';
	}

	//creating barstrings for drawing
	for (n = 0; n < bw; n++) {

		wcscat(barstring[0],L"\u2588");
		wcscat(barstring[1],L"\u2581");
		wcscat(barstring[2],L"\u2582");
		wcscat(barstring[3],L"\u2583");
		wcscat(barstring[4],L"\u2584");
		wcscat(barstring[5],L"\u2585");
		wcscat(barstring[6],L"\u2586");
		wcscat(barstring[7],L"\u2587");
		strcat(spacestring, " ");

		for (i = 0; i < 8; i++) {
			ttybarstring[i] += (i + 1) * pow(10, n);
		}
	}

	col += 30;
	bgcol += 40;

	system("setterm -cursor off");
	system("setterm -blank 0");

	// output: reset console
	printf("\033[0m\n");
	system("clear");

	printf("\033[%dm", col); //setting color


	printf("\033[1m"); //setting "bright" color mode, looks cooler... I think

	if (bgcol != 0)
		printf("\033[%dm", bgcol);
	{
		for (n = (h); n >= 0; n--) {
			for (i = 0; i < w; i++) {

				printf(" "); //setting backround color

			}
			printf("\n");
		}
		printf("\033[%dA", h); //moving cursor back up
	}

	setecho(STDIN_FILENO, 0);


	return 0;
}