/* 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; }
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); }