示例#1
0
void process_command(int c)
{
			switch(c) {
			case 'q':
				exit(0);

			case 'h':
			case KEY_LEFT:
				screen_move_left(current_buf);
				break;

			case 'l':
			case KEY_RIGHT:
				screen_move_right(current_buf);
				break;

			case 'j':
			case KEY_DOWN:
				screen_move_down(current_buf);
				break;

			case 'k':
			case KEY_UP:
				screen_move_up(current_buf);
				break;

			case 'w':
				write_buffer(current_buf);
				break;

			case 'x':
				screen_delete_char(current_buf);
				break;

			case 'i':
			case 0x1B: /* escape */
			case KEY_END:
				/* switch between command and input mode */
				command_mode = 0;
				miniprintf("-- INPUT --");
				break;

			case 'v':

			case 'b':
			default:
				miniprintf("%c - invalid command", c);
				break;
			}
}
示例#2
0
文件: sys.c 项目: sonsoohoon/Bit
void main()
{
		int n = 20;
		double d = 24.23;
		char msg[] = "hello";
		miniprintf("miniprintf: %d %f %s\n",n,d,msg);
}
示例#3
0
/*
  notifyprintf : display a message in the minibuffer and wait that the user
  		 presses a key.
 */
void notifyprintf(char *fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
	miniprintf(fmt, ap);
	va_end(ap);

	getch(); /* discard input */
}
示例#4
0
void input_loop(void)
{
	while(1) {

		int c = getch();
		
		if (command_mode)
			process_command(c);
		else 
			process_input(c);

		refresh();

		miniprintf("%c, line length: %d, y: %d, x%d",
			   (bchar(current_buf->contents, current_buf->point) == '\n') ? 'N' : bchar(current_buf->contents, current_buf->point),
			   screen_line_length(current_buf->contents, current_buf->point),
			   current_buf->y, current_buf->x);

	}

}
示例#5
0
void process_input(int c)
{
			switch(c) {
			case KEY_ENTER:
				screen_insert_char(current_buf, '\n');
				break;

			case KEY_BACKSPACE:
				screen_delete_char(current_buf);
				break;

			case KEY_LEFT:
				screen_move_left(current_buf);
				break;

			case KEY_RIGHT:
				screen_move_right(current_buf);
				break;

			case KEY_DOWN:
				screen_move_down(current_buf);
				break;

			case KEY_UP:
				screen_move_up(current_buf);
				break;

			case 0x1B: /* escape */
			case KEY_END:
				command_mode = 1;
				miniprintf("-- COMMAND --");
				break;

			default:
				screen_insert_char(current_buf, c);
				refresh();
				break;
			}

}
示例#6
0
char *ask_user(char *fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
	miniprintf(fmt, ap);
	va_end(ap);

	char *s = zalloc(255);
	int c = 0;
	int i = 0;

	if (s == NULL)
		fail("Unable to allocate memory at __FILE__:__LINE__\n");

	do {
		c = wgetch(minibuffer_win);
		wechochar(minibuffer_win, c);
		s[i] = c;
		i++;
	} while (i < 255 && c != '\n');

	return s;
}
示例#7
0
文件: trick1.c 项目: password636/C
int main(void)
{
	miniprintf("will print something\n");
	miniprintf("now %d %s %f\n", 10, "hello, world!", 9.9);
	return 0;
}