Exemple #1
0
static void
curses_set_opts(tv_t *attrs)
{
	while (attrs) {
		if (!strcasecmp(attrs->type, "fgchar") && attrs->value)
			set_fg_char(attrs->value[0]);
		else if (!strcasecmp(attrs->type, "bgchar") && attrs->value)
			set_bg_char(attrs->value[0]);
		else if (!strcasecmp(attrs->type, "nchar") && attrs->value)
			set_noise_char(attrs->value[0]);
		else if (!strcasecmp(attrs->type, "xunit") && attrs->value)
			set_x_unit(attrs->value, 1);
		else if (!strcasecmp(attrs->type, "yunit") && attrs->value)
			set_y_unit(attrs->value);
		else if (!strcasecmp(attrs->type, "height") && attrs->value)
			c_graph_height = strtol(attrs->value, NULL, 0);
		else if (!strcasecmp(attrs->type, "cnl"))
			c_combined_node_list = 1;
		else if (!strcasecmp(attrs->type, "graph"))
			c_graphical_in_list = 1;
		else if (!strcasecmp(attrs->type, "detail"))
			c_detailed_in_list = 1;
		else if (!strcasecmp(attrs->type, "nocolors"))
			c_use_colors = 0;
		else if (!strcasecmp(attrs->type, "help")) {
			print_module_help();
			exit(0);
		}
		
		attrs = attrs->next;
	}
}
Exemple #2
0
static void
ascii_set_opts(tv_t *attrs)
{
	while (attrs) {
		if (!strcasecmp(attrs->type, "diagram") && attrs->value)
			set_diagram_type(attrs->value);
		else if (!strcasecmp(attrs->type, "fgchar") && attrs->value)
			set_fg_char(attrs->value[0]);
		else if (!strcasecmp(attrs->type, "bgchar") && attrs->value)
			set_bg_char(attrs->value[0]);
		else if (!strcasecmp(attrs->type, "nchar") && attrs->value)
			set_noise_char(attrs->value[0]);
		else if (!strcasecmp(attrs->type, "xunit") && attrs->value)
			set_x_unit(attrs->value, 1);
		else if (!strcasecmp(attrs->type, "yunit") && attrs->value)
			set_y_unit(attrs->value);
		else if (!strcasecmp(attrs->type, "height") && attrs->value)
			c_graph_height = strtol(attrs->value, NULL, 0);
		else if (!strcasecmp(attrs->type, "header")) {
			if (attrs->value)
				c_print_header = strtol(attrs->value, NULL, 0);
			else
				c_print_header = INT_MAX;
		} else if (!strcasecmp(attrs->type, "noheader"))
			c_print_header = 0;
		else if (!strcasecmp(attrs->type, "quitafter") && attrs->value)
			c_quit_after = strtol(attrs->value, NULL, 0);
		else if (!strcasecmp(attrs->type, "help")) {
			print_help();
			exit(0);
		}
		
		attrs = attrs->next;
	}
}
Exemple #3
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;
}