Пример #1
0
static int
handle_input(int ch)
{
    switch (ch) 
    {
		case 'q':
			quit_mode = quit_mode ? 0 : 1;
			return 1;

		case 0x1b:
			quit_mode = 0;
			print_help = 0;
			return 1;

		case 'y':
			if (quit_mode)
				exit(0);
			break;

		case 'n':
			if (quit_mode) {
				quit_mode = 0;
				return 1;
			}
			break;

		case 'f':
			fold();
			return 1;

		case 12:
		case KEY_CLEAR:
#ifdef HAVE_REDRAWWIN
			redrawwin(stdscr);
#endif
			clear();
			return 1;

		case 'c':
			c_combined_node_list = c_combined_node_list ? 0 : 1;
			return 1;

        case 'S':
            clear();
			set_x_unit("s", 1);
            return 1;

        case 'M':
            clear();
			set_x_unit("m", 1);
            return 1;

        case 'H':
            clear();
			set_x_unit("h", 1);
            return 1;

		case 'D':
			clear();
			set_x_unit("d", 1);
			return 1;

		case 'R':
			clear();
			set_x_unit("r", 1);
			return 1;

        case '?':
            clear();
			print_help = print_help ? 0 : 1;
			return 1;

        case 'g':
			c_graphical_in_list = c_graphical_in_list ? 0 : 1;
			return 1;

		case 'd':
			c_detailed_in_list = c_detailed_in_list ? 0 : 1;
			return 1;

		case 'l':
			c_list_in_list = c_list_in_list ? 0 : 1;
			return 1;

		case KEY_LEFT:
			prev_node();
			return 1;

		case KEY_RIGHT:
			next_node();
			return 1;

		case KEY_DOWN:
			if (next_intf() == END_OF_LIST) {
				if (next_node() != END_OF_LIST)
					first_intf();
			}
			return 1;

		case KEY_UP:
			if (prev_intf() == END_OF_LIST) {
				if (prev_node() != END_OF_LIST)
					last_intf();
			}
			return 1;
		default:
			if (get_current_intf())
				if (handle_bindings(ch, get_current_intf()->i_name))
					return 1;
			break;
    }

    return 0;
}
Пример #2
0
static int handle_input(int ch)
{
	switch (ch) 
	{
		case 'q':
			quit_mode = quit_mode ? 0 : 1;
			return 1;

		case 0x1b:
			quit_mode = 0;
			print_help = 0;
			return 1;

		case 'y':
			if (quit_mode)
				exit(0);
			break;

		case 'a':
			next_attr();
			return 1;

		case 'n':
			if (quit_mode)
				quit_mode = 0;
			else
				new_graph();
			return 1;

		case 'x':
			del_graph();
			return 1;

		case 'f':
			fold();
			return 1;

		case 12:
		case KEY_CLEAR:
#ifdef HAVE_REDRAWWIN
			redrawwin(stdscr);
#endif
			clear();
			return 1;

		case 'c':
			c_combined_node_list = c_combined_node_list ? 0 : 1;
			return 1;

		case 'S':
			clear();
			set_graph_unit(X_SEC);
			return 1;

		case 'M':
			clear();
			set_graph_unit(X_MIN);
			return 1;

		case 'H':
			clear();
			set_graph_unit(X_HOUR);
			return 1;

		case 'D':
			clear();
			set_graph_unit(X_DAY);
			return 1;

		case 'R':
			clear();
			set_graph_unit(X_READ);
			return 1;

			case '?':
			clear();
			print_help = print_help ? 0 : 1;
			return 1;

		case 'g':
			c_graphical_in_list = c_graphical_in_list ? 0 : 1;
			return 1;

		case 'd':
			c_detailed_in_list = c_detailed_in_list ? 0 : 1;
			return 1;

		case 'l':
			c_list_in_list = c_list_in_list ? 0 : 1;
			return 1;

		case KEY_PPAGE:
			if (print_help)
				help_page = help_page ? 0 : 1;
			else
				prev_node();
			return 1;

		case KEY_NPAGE:
			if (print_help)
				help_page = help_page ? 0 : 1;
			else
				next_node();
			return 1;

		case KEY_DOWN:
			if (next_item() == END_OF_LIST) {
				if (next_node() != END_OF_LIST)
					first_item();
			}
			return 1;

		case KEY_UP:
			if (prev_item() == END_OF_LIST) {
				if (prev_node() != END_OF_LIST)
					last_item();
			}
			return 1;

		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			goto_item(ch - 48);
			return 1;

		case '>':
			next_graph();
			return 1;

		case '<':
			prev_graph();
			return 1;
			
		default:
			if (get_current_item())
				if (handle_bindings(ch, get_current_item()->i_name))
					return 1;
			break;
	}

	return 0;
}