Ejemplo n.º 1
0
Archivo: tabs.c Proyecto: acklinr/vifm
/* Creates new tab with the specified name, which might be NULL.  Returns newly
 * created tab on success or NULL on error. */
static pane_tab_t *
tabs_new_pane(pane_tabs_t *ptabs, view_t *view, const char name[])
{
	pane_tab_t new_tab = {};

	if(DA_EXTEND(ptabs->tabs) == NULL)
	{
		return NULL;
	}

	DA_COMMIT(ptabs->tabs);

	/* We're called from tabs_init() and just need to create internal structures
	 * without cloning data (or it will leak). */
	if(DA_SIZE(gtabs) == 0U)
	{
		ptabs->tabs[0] = new_tab;
		return &ptabs->tabs[0];
	}

	clone_view(&new_tab.view, view);
	update_string(&new_tab.name, name);

	if(DA_SIZE(ptabs->tabs) == 1U)
	{
		ptabs->tabs[0] = new_tab;
		return &ptabs->tabs[0];
	}

	memmove(ptabs->tabs + ptabs->current + 2, ptabs->tabs + ptabs->current + 1,
			sizeof(*ptabs->tabs)*(DA_SIZE(ptabs->tabs) - (ptabs->current + 2)));
	ptabs->tabs[ptabs->current + 1] = new_tab;

	return &ptabs->tabs[ptabs->current + 1];
}
Ejemplo n.º 2
0
/* Reloads all views in all tabs on one side (left/top or right/bottom). */
static void
reload_views(view_t *side)
{
	int i;
	tab_info_t tab_info;

	for(i = 0; enum_tabs(side, i, &tab_info); ++i)
	{
		if(tab_info.view != side)
		{
			char *path = strdup(flist_get_dir(tab_info.view));
			flist_free_view(tab_info.view);
			memset(tab_info.view, 0, sizeof(*tab_info.view));
			clone_view(tab_info.view, side, path);
			free(path);
		}
	}
}