Esempio n. 1
0
File: keyboard.c Progetto: ahf/irssi
void keyboard_init(void)
{
	keys = g_hash_table_new((GHashFunc) g_str_hash,
				(GCompareFunc) g_str_equal);
	default_keys = g_hash_table_new((GHashFunc) g_str_hash,
					(GCompareFunc) g_str_equal);
	keyinfos = NULL;
	key_states = g_tree_new((GCompareFunc) g_strcmp0);
        key_config_frozen = 0;
	memset(used_keys, 0, sizeof(used_keys));

	settings_add_int("misc", "key_timeout", 0);

	key_bind("command", "Run any command", NULL, NULL, (SIGNAL_FUNC) sig_command);
	key_bind("key", "Specify name for key binding", NULL, NULL, (SIGNAL_FUNC) sig_key);
	key_bind("multi", "Run multiple commands", NULL, NULL, (SIGNAL_FUNC) sig_multi);
	key_bind("nothing", "Do nothing", NULL, NULL, (SIGNAL_FUNC) sig_nothing);

	/* read the keyboard config when all key binds are known */
	signal_add("irssi init read settings", (SIGNAL_FUNC) read_keyboard_config);
	signal_add("setup reread", (SIGNAL_FUNC) read_keyboard_config);
	signal_add("complete command bind", (SIGNAL_FUNC) sig_complete_bind);

	command_bind("bind", NULL, (SIGNAL_FUNC) cmd_bind);
	command_set_options("bind", "delete list");
}
Esempio n. 2
0
void keyboard_init(void)
{
	keys = g_hash_table_new((GHashFunc) g_str_hash, (GCompareFunc) g_str_equal);
	keyinfos = NULL;

	key_bind("command", NULL, "Run any IRC command", NULL, (SIGNAL_FUNC) sig_command);

	read_keyboard_config();
        signal_add("setup reread", (SIGNAL_FUNC) read_keyboard_config);
}
Esempio n. 3
0
void keyboard_init(void)
{
	keys = g_hash_table_new((GHashFunc) g_istr_hash, (GCompareFunc) g_istr_equal);
	keyinfos = NULL;

	key_bind("command", "Run any IRC command", NULL, NULL, (SIGNAL_FUNC) sig_command);

	/* read the keyboard config when all key binds are known */
	signal_add("irssi init read settings", (SIGNAL_FUNC) read_keyboard_config);
	signal_add("setup reread", (SIGNAL_FUNC) read_keyboard_config);
	signal_add("complete command bind", (SIGNAL_FUNC) sig_complete_bind);

	command_bind("bind", NULL, (SIGNAL_FUNC) cmd_bind);
	command_set_options("bind", "delete");
}
Esempio n. 4
0
void gui_readline_init(void)
{
	static char changekeys[] = "1234567890QWERTYUIO";
	char *key, data[MAX_INT_STRLEN];
	int n;

	cutbuffer = NULL;
	redir = NULL;
	idle_time = time(NULL);
	readtag = g_input_add_full(g_io_channel_unix_new(0),
				   G_PRIORITY_HIGH, G_INPUT_READ,
				   (GInputFunction) readline, NULL);

	settings_add_str("history", "scroll_page_count", "/2");

	key_bind("backward_character", "", "Left", NULL, (SIGNAL_FUNC) key_backward_character);
	key_bind("forward_character", "", "Right", NULL, (SIGNAL_FUNC) key_forward_character);
 	key_bind("backward_word", "", "Ctrl-Left", NULL, (SIGNAL_FUNC) key_backward_word);
	key_bind("forward_word", "", "Ctrl-Right", NULL, (SIGNAL_FUNC) key_forward_word);
	key_bind("beginning_of_line", "", "Home", NULL, (SIGNAL_FUNC) key_beginning_of_line);
	key_bind("beginning_of_line", NULL, "Ctrl-A", NULL, (SIGNAL_FUNC) key_beginning_of_line);
	key_bind("end_of_line", "", "End", NULL, (SIGNAL_FUNC) key_end_of_line);
	key_bind("end_of_line", NULL, "Ctrl-E", NULL, (SIGNAL_FUNC) key_end_of_line);

	key_bind("backward_history", "", "Up", NULL, (SIGNAL_FUNC) key_backward_history);
	key_bind("forward_history", "", "Down", NULL, (SIGNAL_FUNC) key_forward_history);

	key_bind("backspace", "", "Backspace", NULL, (SIGNAL_FUNC) key_backspace);
	key_bind("delete_character", "", "Delete", NULL, (SIGNAL_FUNC) key_delete_character);
	key_bind("delete_character", NULL, "Ctrl-D", NULL, (SIGNAL_FUNC) key_delete_character);
	key_bind("delete_next_word", "", NULL, NULL, (SIGNAL_FUNC) key_delete_next_word);
	key_bind("delete_previous_word", "", NULL, NULL, (SIGNAL_FUNC) key_delete_previous_word);
	key_bind("delete_to_previous_space", "", "Ctrl-W", NULL, (SIGNAL_FUNC) key_delete_to_previous_space);
	key_bind("erase_line", "", "Ctrl-U", NULL, (SIGNAL_FUNC) key_erase_line);
	key_bind("erase_to_beg_of_line", "", NULL, NULL, (SIGNAL_FUNC) key_erase_to_beg_of_line);
	key_bind("erase_to_end_of_line", "", "Ctrl-K", NULL, (SIGNAL_FUNC) key_erase_to_end_of_line);
	key_bind("yank_from_cutbuffer", "", "Ctrl-Y", NULL, (SIGNAL_FUNC) key_yank_from_cutbuffer);
	key_bind("transpose_characters", "Swap current and previous character", "Ctrl-T", NULL, (SIGNAL_FUNC) key_transpose_characters);
        
	key_bind("word_completion", "", "Tab", NULL, (SIGNAL_FUNC) key_word_completion);
	key_bind("check_replaces", "Check word replaces", " ", NULL, (SIGNAL_FUNC) key_check_replaces);
	key_bind("check_replaces", NULL, "Return", NULL, (SIGNAL_FUNC) key_check_replaces);

	key_bind("previous_window", "Previous window", "CTRL-P", NULL, (SIGNAL_FUNC) key_previous_window);
	key_bind("left_window", "Window in left", "ALT-Left", NULL, (SIGNAL_FUNC) key_left_window);
	key_bind("next_window", "Next window", "CTRL-N", NULL, (SIGNAL_FUNC) key_next_window);
	key_bind("right_window", "Window in right", "ALT-Right", NULL, (SIGNAL_FUNC) key_right_window);
	key_bind("upper_window", "Upper window", "ALT-Up", NULL, (SIGNAL_FUNC) key_upper_window);
	key_bind("lower_window", "Lower window", "ALT-Down", NULL, (SIGNAL_FUNC) key_lower_window);
	key_bind("active_window", "Go to next window with the highest activity", "ALT-A", NULL, (SIGNAL_FUNC) key_active_window);
	key_bind("next_window_item", "Next channel/query", "CTRL-X", NULL, (SIGNAL_FUNC) key_next_window_item);
	key_bind("previous_window_item", "Previous channel/query", NULL, NULL, (SIGNAL_FUNC) key_previous_window_item);

	key_bind("refresh_screen", "Redraw screen", "CTRL-L", NULL, (SIGNAL_FUNC) irssi_redraw);
	key_bind("scroll_backward", "Previous page", "Prior", NULL, (SIGNAL_FUNC) key_scroll_backward);
	key_bind("scroll_backward", NULL, "ALT-P", NULL, (SIGNAL_FUNC) key_scroll_backward);
	key_bind("scroll_forward", "Next page", "Next", NULL, (SIGNAL_FUNC) key_scroll_forward);
	key_bind("scroll_forward", NULL, "ALT-N", NULL, (SIGNAL_FUNC) key_scroll_forward);
	key_bind("scroll_start", "Beginning of the window", "", NULL, (SIGNAL_FUNC) key_scroll_start);
	key_bind("scroll_end", "End of the window", "", NULL, (SIGNAL_FUNC) key_scroll_end);

	key_bind("special_char", "Insert special character", "CTRL-B", "\002", (SIGNAL_FUNC) key_addchar);
	key_bind("special_char", NULL, "CTRL--", "\037", (SIGNAL_FUNC) key_addchar);
	key_bind("special_char", NULL, "CTRL-C", "\003", (SIGNAL_FUNC) key_addchar);
	key_bind("special_char", NULL, "CTRL-V", "\026", (SIGNAL_FUNC) key_addchar);
	key_bind("special_char", NULL, "CTRL-G", "\007", (SIGNAL_FUNC) key_addchar);
	key_bind("special_char", NULL, "CTRL-O", "\017", (SIGNAL_FUNC) key_addchar);

	for (n = 0; changekeys[n] != '\0'; n++) {
		key = g_strdup_printf("ALT-%c", changekeys[n]);
		ltoa(data, n+1);
		key_bind("change_window", "Change window", key, data, (SIGNAL_FUNC) key_change_window);
		g_free(key);
	}

	signal_add("window changed automatic", (SIGNAL_FUNC) sig_window_auto_changed);
	signal_add("gui entry redirect", (SIGNAL_FUNC) sig_gui_entry_redirect);
}
Esempio n. 5
0
void cfg_set_opt(char *key, char *value, int initial) {
	#ifdef USE_XFT
	XftFont *newxftfont;
	#endif
	XFontStruct *newfont;
	long i;
	if(strcmp(key, "resetkeys") == 0)
		keys_free();
	if(!value)
		return;
	if(strcmp(key, "key") == 0)
		key_bind(value);
	if(strcmp(key, "exec") == 0 && initial)
		spawn(value);
	if(strcmp(key, "exec_onload") == 0)
		spawn(value);
	if(strcmp(key, "background") == 0)
		str_color(value, &bg);
	if(strcmp(key, "inactive_background") == 0)
		str_color(value, &ibg);
	if(strcmp(key, "foreground") == 0)
		str_color(value, &fg);
	if(strcmp(key, "inactive_foreground") == 0)
		str_color(value, &ifg);
	if(strcmp(key, "border_color") == 0)
		str_color(value, &bfg);
	if(strcmp(key, "inactive_border_color") == 0)
		str_color(value, &ibfg);
	if(strcmp(key, "font") == 0) {
		newfont = XLoadQueryFont(dpy, value);
		if(newfont) {
			if(font)
				XFreeFont(dpy, font);
			#ifdef USE_XFT
			if(xftfont) {
				XftFontClose(dpy, xftfont);
				xftfont = NULL;
			}
			#endif
			font = newfont;
		}
		#ifdef USE_XFT
		else {
			newxftfont = XftFontOpenName(dpy, screen, value);
			if(newxftfont) {
				if(xftfont)
					XftFontClose(dpy, xftfont);
				if(font) {
					XFreeFont(dpy, font);
					font = NULL;
				}
				xftfont = newxftfont;
			}
		}
		#endif
	}
	if(strcmp(key, "border_width") == 0) {
		i = strtol(value, NULL, 0);
		if(i >= 0)
		  border_width = i;
	}
	if(strcmp(key, "border_spacing") == 0) {
		i = strtol(value, NULL, 0);
		if(i >= 0)
			border_spacing = i;
	}
	if(strcmp(key, "title_spacing") == 0) {
		i = strtol(value, NULL, 0);
		if(i >= 0)
			title_spacing = i;
	}
	if(strcmp(key, "button_spacing") == 0) {
		i = strtol(value, NULL, 0);
		if(i >= 0)
			button_spacing = i;
	}
	if(strcmp(key, "wlist_margin") == 0) {
		i = strtol(value, NULL, 0);
		if(i >= 0)
			wlist_margin = i;
	}
	if(strcmp(key, "wlist_maxwidth") == 0) {
		i = strtol(value, NULL, 0);
		if(i >= 0)
			wlist_maxwidth = i;
	}
	if(strcmp(key, "doubleclick_time") == 0) {
		i = strtol(value, NULL, 0);
		if(i > 0)
			doubleclick_time = i;
	}
	if(strcmp(key, "snap") == 0)
		snapat = strtol(value, NULL, 0);
	if(strcmp(key, "desktops") == 0) {
		i = strtol(value, NULL, 0);
		if(i > 0)
			dc = i;
	}
	if(strcmp(key, "ewmh_screen") == 0) {
		i = strtol(value, NULL, 0);
		if(i > 0)
			ewmh_screen = i;
	}
	if(strcmp(key, "button1") == 0)
	 	str_action(value, &button1);
	if(strcmp(key, "button2") == 0)
		str_action(value, &button2);
	if(strcmp(key, "button3") == 0)
		str_action(value, &button3);
	if(strcmp(key, "button4") == 0)
		str_action(value, &button4);
	if(strcmp(key, "button5") == 0)
		str_action(value, &button5);
	if(strcmp(key, "double1") == 0)
		str_action(value, &double1);
	if(strcmp(key, "double2") == 0)
		str_action(value, &double2);
	if(strcmp(key, "double3") == 0)
		str_action(value, &double3);
	if(strcmp(key, "double4") == 0)
		str_action(value, &double4);
	if(strcmp(key, "double5") == 0)
		str_action(value, &double5);
	if(strcmp(key, "root_button1") == 0)
	 	str_action(value, &root_button1);
	if(strcmp(key, "root_button2") == 0)
		str_action(value, &root_button2);
	if(strcmp(key, "root_button3") == 0)
		str_action(value, &root_button3);
	if(strcmp(key, "root_button4") == 0)
		str_action(value, &root_button4);
	if(strcmp(key, "root_button5") == 0)
		str_action(value, &root_button5);
	if(strcmp(key, "root_double1") == 0)
		str_action(value, &root_double1);
	if(strcmp(key, "root_double2") == 0)
		str_action(value, &root_double2);
	if(strcmp(key, "root_double3") == 0)
		str_action(value, &root_double3);
	if(strcmp(key, "root_double4") == 0)
		str_action(value, &root_double4);
	if(strcmp(key, "root_double5") == 0)
		str_action(value, &double5);
	if(strcmp(key, "click_focus") == 0)
		str_bool(value, &click_focus);
	if(strcmp(key, "click_raise") == 0)
		str_bool(value, &click_raise);
	if(strcmp(key, "focus_new") == 0)
		str_bool(value, &focus_new);
	if(strcmp(key, "fullscreen_stacking") == 0)
		str_fsstacking(value, &fullscreen_stacking);
	if(strcmp(key, "taskbar_ontop") == 0)
		str_bool(value, &taskbar_ontop);
	if(strcmp(key, "center_title") == 0)
		str_bool(value, &center_title);
	if(strcmp(key, "center_wlist_items") == 0)
		str_bool(value, &center_wlist_items);
	if(strcmp(key, "map_center") == 0)
		str_bool(value, &map_center);
	if(strcmp(key, "drag_warp") == 0)
		str_bool(value, &drag_warp);
	if(strcmp(key, "allow_focus_stealing") == 0)
		str_bool(value, &allow_focus_stealing);
	if(strcmp(key, "correct_center") == 0)
		str_bool(value, &correct_center);
	if(strcmp(key, "correct_center_unmanaged") == 0)
		str_bool(value, &correct_center_unmanaged);
	if(strcmp(key, "correct_center_separate") == 0)
		str_bool(value, &correct_center_separate);
	if(strcmp(key, "click_root") == 0)
		str_bool(value, &click_root);
	if(strcmp(key, "mouse_modifier") == 0)
		str_key(&value, &mousemodmask);
	if(strcmp(key, "no_snap_modifier") == 0)
		str_key(&value, &nosnapmodmask);
	if(strcmp(key, "ignore_modifier") == 0) {
		if(mod_ignore) {
			nmod_ignore = 0;
			free((void *) mod_ignore);
			mod_ignore = NULL;
		}
		while(value) {
			mod_ignore = (unsigned int *) _realloc((void *) mod_ignore, (nmod_ignore + nmod_ignore + 1) * sizeof(unsigned int));
			skiprealloc:
			mod_ignore[nmod_ignore] = str_modifier(eat(&value, " \t"));
			if(mod_ignore[nmod_ignore] == None)
				goto skiprealloc;
			for(i = 0; i < nmod_ignore; i++)
				mod_ignore[nmod_ignore + 1 + i] = mod_ignore[i] | mod_ignore[nmod_ignore];
			nmod_ignore += nmod_ignore + 1;
		}
	}
	if(strcmp(key, "buttons_left") == 0)
		str_buttons(value, &buttons_left, &nbuttons_left);
	if(strcmp(key, "buttons_right") == 0)
		str_buttons(value, &buttons_right, &nbuttons_right);
}