Exemplo n.º 1
0
void
tabs_next(int n)
{
	if(cfg.pane_tabs)
	{
		pane_tabs_t *const ptabs = get_pane_tabs(curr_view);
		const int count = (int)DA_SIZE(ptabs->tabs);
		tabs_goto((ptabs->current + n)%count);
	}
	else
	{
		tabs_goto((current_tab + 1)%(int)DA_SIZE(gtabs));
	}
}
Exemplo n.º 2
0
void
tabs_previous(int n)
{
	if(cfg.pane_tabs)
	{
		pane_tabs_t *const ptabs = get_pane_tabs(curr_view);
		const int count = (int)DA_SIZE(ptabs->tabs);
		tabs_goto((ptabs->current + count - n)%count);
	}
	else
	{
		const int count = DA_SIZE(gtabs);
		tabs_goto((current_tab + count - n)%count);
	}
}
Exemplo n.º 3
0
Arquivo: tabs.c Projeto: 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;
}
Exemplo n.º 4
0
void
tabs_close(void)
{
	// XXX: FUSE filesystems aren't exited this way, but this might be OK because
	//      usually we exit from them on explicit ".." by a user.

	if(cfg.pane_tabs)
	{
		pane_tabs_t *const ptabs = get_pane_tabs(curr_view);
		pane_tab_t *const ptab = &ptabs->tabs[ptabs->current];
		const int n = (int)DA_SIZE(ptabs->tabs);
		if(n != 1)
		{
			tabs_goto(ptabs->current + (ptabs->current == n - 1 ? -1 : +1));
			if(ptabs->current > ptab - ptabs->tabs)
			{
				--ptabs->current;
			}
			free_pane_tab(ptab);
			DA_REMOVE(ptabs->tabs, ptab);
		}

		//add by sim1 for test
		//ui_sb_msgf("tabs_close: curr=%d, last=%d, tabs=%d", ptabs->current, ptabs->last, (int)DA_SIZE(ptabs->tabs));
	}
	else
	{
		global_tab_t *const gtab = &gtabs[current_tab];
		const int n = (int)DA_SIZE(gtabs);
		if(n != 1)
		{
			tabs_goto(current_tab == n - 1 ? current_tab - 1 : current_tab + 1);
			if(current_tab > gtab - gtabs)
			{
				--current_tab;
			}
			free_global_tab(gtab);
			DA_REMOVE(gtabs, gtab);
		}
	}
}
Exemplo n.º 5
0
int
tabs_new(const char name[], const char path[])
{
	if(cfg.pane_tabs)
	{
		pane_tabs_t *const ptabs = get_pane_tabs(curr_view);
		pane_tab_t *const ptab = tabs_new_pane(ptabs, curr_view, name, path);
		if(ptab == NULL)
		{
			return 1;
		}

		ptab->preview.on = curr_stats.preview.on;
		tabs_goto(ptab - ptabs->tabs);
		return 0;
	}

	return tabs_new_global(name, path);
}