示例#1
0
文件: tabs.c 项目: acklinr/vifm
/* Creates new global tab with the specified name, which might be NULL.  Returns
 * zero on success, otherwise non-zero is returned. */
static int
tabs_new_global(const char name[])
{
	global_tab_t new_tab = {};

	if(DA_EXTEND(gtabs) == NULL)
	{
		return 1;
	}

	if(tabs_new_pane(&new_tab.left, &lwin, NULL) == NULL ||
			tabs_new_pane(&new_tab.right, &rwin, NULL) == NULL)
	{
		free_global_tab(&new_tab);
		return 1;
	}
	update_string(&new_tab.name, name);
	capture_global_state(&new_tab);
	new_tab.preview.on = curr_stats.preview.on;

	DA_COMMIT(gtabs);

	/* We're called from tabs_init(). */
	if(DA_SIZE(gtabs) == 1U)
	{
		gtabs[0U] = new_tab;
		return 0;
	}

	memmove(gtabs + current_tab + 2, gtabs + current_tab + 1,
			sizeof(*gtabs)*(DA_SIZE(gtabs) - (current_tab + 2)));
	gtabs[current_tab + 1] = new_tab;
	tabs_goto(current_tab + 1);
	return 0;
}
示例#2
0
文件: tabs.c 项目: phantasea/vifm
/* Switches to global tab specified by its index if the index is valid. */
static void
tabs_goto_global(int idx)
{
	if(current_tab == idx)
	{
		return;
	}

	//add by sim1 +++++++++++++++++++++++++++++
	if(idx < 0)
	{
		idx = last_tab;
	}
	//add by sim1 -----------------------------

	if(idx < 0 || idx >= (int)DA_SIZE(gtabs))
	{
		return;
	}

	gtabs[current_tab].left.tabs[gtabs[current_tab].left.current].view = lwin;
	gtabs[current_tab].right.tabs[gtabs[current_tab].right.current].view = rwin;
	capture_global_state(&gtabs[current_tab]);
	assign_preview(&gtabs[current_tab].preview, &curr_stats.preview);

	lwin = gtabs[idx].left.tabs[gtabs[idx].left.current].view;
	rwin = gtabs[idx].right.tabs[gtabs[idx].right.current].view;
	if(gtabs[idx].active_pane != (curr_view == &rwin))
	{
		swap_view_roles();
	}
	curr_stats.number_of_windows = (gtabs[idx].only_mode ? 1 : 2);
	curr_stats.split = gtabs[idx].split;
	curr_stats.splitter_pos = gtabs[idx].splitter_pos;
	assign_preview(&curr_stats.preview, &gtabs[idx].preview);

	last_tab = current_tab;  //add by sim1
	current_tab = idx;

	stats_set_quickview(curr_stats.preview.on);
	ui_view_schedule_redraw(&lwin);
	ui_view_schedule_redraw(&rwin);

	load_view_options(curr_view);

	(void)vifm_chdir(flist_get_dir(curr_view));
}