Example #1
0
/* Navigates the view to given mark if it's valid.  Returns new value for
 * save_msg flag. */
static int
navigate_to_bookmark(FileView *view, char mark)
{
	const bookmark_t *const bmark = get_bookmark(mark);

	if(is_bmark_valid(bmark))
	{
		if(change_directory(view, bmark->directory) >= 0)
		{
			load_dir_list(view, 1);
			(void)ensure_file_is_selected(view, bmark->file);
		}
	}
	else
	{
		if(!char_is_one_of(valid_bookmarks, mark))
			status_bar_message("Invalid mark name");
		else if(is_bmark_empty(bmark))
			status_bar_message("Mark is not set");
		else
			status_bar_message("Mark is invalid");

		move_to_list_pos(view, view->list_pos);
		return 1;
	}
	return 0;
}
Example #2
0
void
execute_volumes_cb(FileView *view, menu_info *m)
{
	char path_buf[4];
	snprintf(path_buf, 4, "%s", m->items[m->pos]);

	if(change_directory(view, path_buf) < 0)
		return;

	load_dir_list(view, 0);
	move_to_list_pos(view, 0);
}
Example #3
0
/* leaves properties change dialog */
static void
leave_attr_mode(void)
{
	vle_mode_set(NORMAL_MODE, VMT_PRIMARY);
	curr_stats.use_input_bar = 1;

	clean_selected_files(view);
	load_dir_list(view, 1);
	move_to_list_pos(view, view->list_pos);

	update_all_windows();
}
Example #4
0
static void
leave_attr_mode(void)
{
	*mode = NORMAL_MODE;
	curs_set(FALSE);
	curr_stats.use_input_bar = 1;

	clean_selected_files(view);
	load_dir_list(view, 1);
	move_to_list_pos(view, view->list_pos);

	update_all_windows();
}
Example #5
0
static void
leave_change_mode(int clean_selection)
{
	*mode = NORMAL_MODE;

	if(clean_selection)
	{
		clean_selected_files(view);
		load_saving_pos(view, 1);
		move_to_list_pos(view, view->list_pos);
	}

	update_all_windows();
}
Example #6
0
File: fuse.c Project: lyuts/vifm
static void
updir_from_mount(FileView *view, fuse_mount_t *runner)
{
	char *file;
	int pos;

	if(change_directory(view, runner->source_file_dir) < 0)
		return;

	load_dir_list(view, 0);

	file = runner->source_file_name;
	file += strlen(runner->source_file_dir) + 1;
	pos = find_file_pos_in_list(view, file);
	move_to_list_pos(view, pos);
}
Example #7
0
int
goto_bookmark(FileView *view, char mark)
{
	switch(mark)
	{
		case '\'':
			navigate_to(view, view->last_dir);
			return 0;
		case '\x03': /* Ctrl-C. */
		case '\x1b': /* Escape. */
			move_to_list_pos(view, view->list_pos);
			return 0;

		default:
			return navigate_to_bookmark(view, mark);
	}
}
Example #8
0
File: cmdline.c Project: sklnd/vifm
static void
leave_cmdline_mode(void)
{
	int attr;

	if(getmaxy(status_bar) > 1)
	{
		curr_stats.need_redraw = 2;
		wresize(status_bar, 1, getmaxx(stdscr) - 19);
		mvwin(status_bar, getmaxy(stdscr) - 1, 0);
		if(prev_mode == MENU_MODE)
		{
			wresize(menu_win, getmaxy(stdscr) - 1, getmaxx(stdscr));
			update_menu();
		}
	}
	else
	{
		wresize(status_bar, 1, getmaxx(stdscr) - 19);
	}

	curs_set(FALSE);
	curr_stats.save_msg = 0;
	free(input_stat.line);
	free(input_stat.line_buf);
	clean_status_bar();

	if(*mode == CMDLINE_MODE)
		*mode = prev_mode;

	if(*mode != MENU_MODE)
		update_pos_window(curr_view);

	attr = cfg.cs.color[CMD_LINE_COLOR].attr;
	wattroff(status_bar, COLOR_PAIR(DCOLOR_BASE + CMD_LINE_COLOR) | attr);

	if(prev_mode != MENU_MODE && prev_mode != VIEW_MODE)
	{
		draw_dir_list(curr_view, curr_view->top_line);
		move_to_list_pos(curr_view, curr_view->list_pos);
	}
}
Example #9
0
/* Initiates leaving of command-line mode and reverting related changes in other
 * parts of the interface. */
static void
cmd_ctrl_c(key_info_t key_info, keys_info_t *keys_info)
{
	stop_completion();
	werase(status_bar);
	wnoutrefresh(status_bar);

	if(input_stat.line != NULL)
	{
		char *mbstr = to_multibyte(input_stat.line);
		save_input_to_history(keys_info, mbstr);
		free(mbstr);

		input_stat.line[0] = L'\0';
	}
	if(sub_mode != FILTER_SUBMODE)
	{
		input_line_changed();
	}

	leave_cmdline_mode();

	if(prev_mode == VISUAL_MODE)
	{
		if(!input_stat.search_mode)
		{
			leave_visual_mode(curr_stats.save_msg, 1, 1);
			move_to_list_pos(curr_view, check_mark_directory(curr_view, '<'));
		}
	}
	if(sub_mode == CMD_SUBMODE)
	{
		curr_stats.save_msg = exec_commands("", curr_view, GET_COMMAND);
	}
	else if(sub_mode == FILTER_SUBMODE)
	{
		local_filter_cancel(curr_view);
		curr_view->top_line = input_stat.old_top;
		curr_view->list_pos = input_stat.old_pos;
		redraw_current_view();
	}
}
Example #10
0
File: cmdline.c Project: sklnd/vifm
static void
cmd_ctrl_c(key_info_t key_info, keys_info_t *keys_info)
{
	stop_completion();
	werase(status_bar);
	wnoutrefresh(status_bar);

	if(input_stat.line != NULL)
		input_stat.line[0] = L'\0';
	input_line_changed();

	leave_cmdline_mode();

	if(prev_mode == VISUAL_MODE)
	{
		leave_visual_mode(curr_stats.save_msg, 1, 1);
		move_to_list_pos(curr_view, check_mark_directory(curr_view, '<'));
	}
	if(sub_mode == CMD_SUBMODE)
	{
		int save_hist = !keys_info->mapped;
		curr_stats.save_msg = exec_commands("", curr_view, save_hist, GET_COMMAND);
	}
}
Example #11
0
void
enter_attr_mode(FileView *active_view)
{
	int i;
	mode_t fmode;
	mode_t diff;
	uid_t uid = geteuid();

	if(curr_stats.load_stage < 2)
		return;

	view = active_view;
	memset(perms, 0, sizeof(perms));

	diff = 0;
	i = 0;
	while(i < view->list_rows && !view->dir_entry[i].selected)
		i++;
	file_is_dir = 0;
	if(i == view->list_rows)
	{
		i = view->list_pos;
		file_is_dir = is_dir(view->dir_entry[i].name);
	}
	fmode = view->dir_entry[i].mode;
	if(uid != 0 && view->dir_entry[i].uid != uid)
	{
		show_error_msgf("Access error", "You are not owner of %s",
				view->dir_entry[i].name);
		clean_selected_files(view);
		load_dir_list(view, 1);
		move_to_list_pos(view, view->list_pos);
		return;
	}
	while(i < view->list_rows)
	{
		if(view->dir_entry[i].selected)
		{
			diff |= (view->dir_entry[i].mode ^ fmode);
			file_is_dir = file_is_dir || is_dir(view->dir_entry[i].name);

			if(uid != 0 && view->dir_entry[i].uid != uid)
			{
				show_error_msgf("Access error", "You are not owner of %s",
						view->dir_entry[i].name);
				return;
			}
		}

		i++;
	}

	*mode = ATTR_MODE;
	clear_input_bar();
	curr_stats.use_input_bar = 0;

	perms[0] = !(diff & S_IRUSR) ? (int)(fmode & S_IRUSR) : -1;
	perms[1] = !(diff & S_IWUSR) ? (int)(fmode & S_IWUSR) : -1;
	perms[2] = !(diff & S_IXUSR) ? (int)(fmode & S_IXUSR) : -1;
	perms[3] = !(diff & S_ISUID) ? (int)(fmode & S_ISUID) : -1;
	perms[4] = !(diff & S_IRGRP) ? (int)(fmode & S_IRGRP) : -1;
	perms[5] = !(diff & S_IWGRP) ? (int)(fmode & S_IWGRP) : -1;
	perms[6] = !(diff & S_IXGRP) ? (int)(fmode & S_IXGRP) : -1;
	perms[7] = !(diff & S_ISGID) ? (int)(fmode & S_ISGID) : -1;
	perms[8] = !(diff & S_IROTH) ? (int)(fmode & S_IROTH) : -1;
	perms[9] = !(diff & S_IWOTH) ? (int)(fmode & S_IWOTH) : -1;
	perms[10] = !(diff & S_IXOTH) ? (int)(fmode & S_IXOTH) : -1;
	perms[11] = !(diff & S_ISVTX) ? (int)(fmode & S_ISVTX) : -1;
	adv_perms[0] = 0;
	adv_perms[1] = 0;
	adv_perms[2] = 0;
	memcpy(origin_perms, perms, sizeof(perms));

	top = 3;
	bottom = file_is_dir ? 18 : 16;
	curr = 3;
	permnum = 0;
	step = 1;
	while(perms[permnum] < 0 && curr <= bottom)
	{
		inc_curr();
		permnum++;
	}

	if(curr > bottom)
	{
		show_error_msg("Permissions change error",
				"Selected files have no common access state");
		leave_attr_mode();
		return;
	}

	col = 9;
	changed = 0;
	redraw_attr_dialog();
}
Example #12
0
File: cmdline.c Project: sklnd/vifm
static void
input_line_changed(void)
{
	static wchar_t *previous;

	if(!cfg.inc_search || !input_stat.search_mode)
		return;

	if(prev_mode != MENU_MODE)
	{
		curr_view->top_line = input_stat.old_top;
		curr_view->list_pos = input_stat.old_pos;
	}
	else
	{
		load_menu_pos();
	}

	if(input_stat.line == NULL || input_stat.line[0] == L'\0')
	{
		if(cfg.hl_search)
		{
			clean_selected_files(curr_view);
			draw_dir_list(curr_view, curr_view->top_line);
			move_to_list_pos(curr_view, curr_view->list_pos);
		}
		free(previous);
		previous = NULL;
	}
	else if(previous == NULL || wcscmp(previous, input_stat.line) != 0)
	{
		char *p;

		free(previous);
		previous = my_wcsdup(input_stat.line);

		p = to_multibyte(input_stat.line);

		if(sub_mode == SEARCH_FORWARD_SUBMODE)
			exec_command(p, curr_view, GET_FSEARCH_PATTERN);
		else if(sub_mode == SEARCH_BACKWARD_SUBMODE)
			exec_command(p, curr_view, GET_BSEARCH_PATTERN);
		else if(sub_mode == MENU_SEARCH_FORWARD_SUBMODE ||
				sub_mode == MENU_SEARCH_BACKWARD_SUBMODE)
			search_menu_list(p, sub_mode_ptr);
		else if(sub_mode == VSEARCH_FORWARD_SUBMODE)
			exec_command(p, curr_view, GET_VFSEARCH_PATTERN);
		else if(sub_mode == VSEARCH_BACKWARD_SUBMODE)
			exec_command(p, curr_view, GET_VBSEARCH_PATTERN);

		free(p);
	}

	if(prev_mode != MENU_MODE)
	{
		draw_dir_list(curr_view, curr_view->top_line);
		move_to_list_pos(curr_view, curr_view->list_pos);
	}
	else
	{
		menu_redraw();
	}
}