Пример #1
0
static void		is_special_action(char *key)
{
	if (key[0] == 27 && key[1] == 91 && key[2] == 72)
		go_to_start();
	else if (key[0] == 27 && key[1] == 91 && key[2] == 70)
		go_to_end();
	else if (key[0] == 21 && key[1] == 0 && key[2] == 0)
		cut_entire_line();
	else if (key[0] == 11 && key[1] == 0 && key[2] == 0)
		cut_end_of_line();
	else if (key[0] == 16 && key[2] == 0 && key[2] == 0)
		paste();
	else if (key[0] == 12 && key[1] == 0 && key[2] == 0)
		clear();
	else if (key[0] == 3 && key[1] == 0 && key[2] == 0)
		handle_ctrl_c();
	else if (key[0] == 2 && key[1] == 0 && key[2] == 0)
		move_back_word();
	else if (key[0] == 14 && key[1] == 0 && key[2] == 0)
		move_next_word();
	else if (key[0] == 27 && key[1] == 91 && key[2] == 53)
		go_up();
	else if (key[0] == 27 && key[1] == 91 && key[2] == 54)
		go_down();
}
Пример #2
0
void		cut_entire_line(void)
{
	free(g_main_line.clipboard);
	g_main_line.clipboard = ft_strdup(g_main_line.cmd);
	go_to_start();
	ft_puts("cd");
	init_new_line();
}
Пример #3
0
void MainWindow::setup_shortcuts(){
	static struct Pair{
		const char *command;
		const char *slot;
	} pairs[] = {
#define SETUP_SHORTCUT(command, slot) { command, SLOT(slot)},
		SETUP_SHORTCUT(quit_command, quit_slot())
		SETUP_SHORTCUT(quit2_command, quit2_slot())
		SETUP_SHORTCUT(next_command, next_slot())
		SETUP_SHORTCUT(back_command, back_slot())
		SETUP_SHORTCUT(background_swap_command, background_swap_slot())
		SETUP_SHORTCUT(close_command, close_slot())
		SETUP_SHORTCUT(zoom_in_command, zoom_in_slot())
		SETUP_SHORTCUT(zoom_out_command, zoom_out_slot())
		SETUP_SHORTCUT(reset_zoom_command, reset_zoom_slot())
		SETUP_SHORTCUT(up_command, up_slot())
		SETUP_SHORTCUT(down_command, down_slot())
		SETUP_SHORTCUT(left_command, left_slot())
		SETUP_SHORTCUT(right_command, right_slot())
		SETUP_SHORTCUT(up_big_command, up_big_slot())
		SETUP_SHORTCUT(down_big_command, down_big_slot())
		SETUP_SHORTCUT(left_big_command, left_big_slot())
		SETUP_SHORTCUT(right_big_command, right_big_slot())
		SETUP_SHORTCUT(cycle_zoom_mode_command, cycle_zoom_mode_slot())
		SETUP_SHORTCUT(toggle_lock_zoom_command, toggle_lock_zoom_slot())
		SETUP_SHORTCUT(go_to_start_command, go_to_start())
		SETUP_SHORTCUT(go_to_end_command, go_to_end())
		SETUP_SHORTCUT(toggle_fullscreen_command, toggle_fullscreen())
		SETUP_SHORTCUT(rotate_left_command, rotate_left())
		SETUP_SHORTCUT(rotate_right_command, rotate_right())
		SETUP_SHORTCUT(rotate_left_fine_command, rotate_left_fine())
		SETUP_SHORTCUT(rotate_right_fine_command, rotate_right_fine())
		SETUP_SHORTCUT(flip_h_command, flip_h())
		SETUP_SHORTCUT(flip_v_command, flip_v())
		SETUP_SHORTCUT(minimize_command, minimize_slot())
		SETUP_SHORTCUT(minimize_all_command, minimize_all_slot())
		SETUP_SHORTCUT(show_options_command, show_options_dialog())
	};

	for (auto &c : this->connections)
		this->disconnect(c);
	
	this->connections.clear();
	this->shortcuts.clear();

	auto &shortcuts = this->app->get_shortcuts();
	for (auto &p : pairs){
		auto setting = shortcuts.get_shortcut_setting(p.command);
		if (!setting)
			continue;
		for (auto &seq : setting->sequences)
			this->setup_shortcut(seq, p.slot);
	}
}