-/* $OpenBSD: popup.c,v 1.28 2021/08/13 19:25:24 nicm Exp $ */
+/* $OpenBSD: popup.c,v 1.29 2021/08/13 19:27:25 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
{ "", KEYC_NONE, NULL },
{ "Fill Space", 'F', NULL },
{ "Centre", 'C', NULL },
+ { "", KEYC_NONE, NULL },
+ { "Make Pane (H)", 'h', NULL },
+ { "Make Pane (V)", 'v', NULL },
+
+ { NULL, KEYC_NONE, NULL }
+};
+
+static const struct menu_item popup_internal_menu_items[] = {
+ { "Close", 'q', NULL },
+ { "", KEYC_NONE, NULL },
+ { "Fill Space", 'F', NULL },
+ { "Centre", 'C', NULL },
{ NULL, KEYC_NONE, NULL }
};
}
}
+static void
+popup_make_pane(struct popup_data *pd, enum layout_type type)
+{
+ struct client *c = pd->c;
+ struct session *s = c->session;
+ struct window *w = s->curw->window;
+ struct layout_cell *lc;
+ struct window_pane *wp = w->active, *new_wp;
+ u_int hlimit;
+
+ window_unzoom(w);
+
+ lc = layout_split_pane(wp, type, -1, 0);
+ hlimit = options_get_number(s->options, "history-limit");
+ new_wp = window_add_pane(wp->window, NULL, hlimit, 0);
+ layout_assign_pane(lc, new_wp, 0);
+
+ new_wp->fd = job_transfer(pd->job);
+ pd->job = NULL;
+
+ screen_free(&new_wp->base);
+ memcpy(&new_wp->base, &pd->s, sizeof wp->base);
+ screen_resize(&new_wp->base, new_wp->sx, new_wp->sy, 1);
+ screen_init(&pd->s, 1, 1, 0);
+
+ window_pane_set_event(new_wp);
+ window_set_active_pane(w, new_wp, 1);
+
+ pd->close = 1;
+}
+
static void
popup_menu_done(__unused struct menu *menu, __unused u_int choice,
key_code key, void *data)
pd->py = c->tty.sy / 2 - pd->sy / 2;
server_redraw_client(c);
break;
+ case 'h':
+ popup_make_pane(pd, LAYOUT_LEFTRIGHT);
+ break;
+ case 'v':
+ popup_make_pane(pd, LAYOUT_TOPBOTTOM);
+ break;
case 'q':
pd->close = 1;
break;
menu:
pd->menu = menu_create("");
- menu_add_items(pd->menu, popup_menu_items, NULL, NULL, NULL);
+ if (pd->flags & POPUP_INTERNAL) {
+ menu_add_items(pd->menu, popup_internal_menu_items, NULL, NULL,
+ NULL);
+ } else
+ menu_add_items(pd->menu, popup_menu_items, NULL, NULL, NULL);
if (m->x >= (pd->menu->width + 4) / 2)
x = m->x - (pd->menu->width + 4) / 2;
else
py = (c->tty.sy / 2) - (sy / 2);
xasprintf(&cmd, "%s %s", editor, path);
- if (popup_display(POPUP_CLOSEEXIT, NULL, px, py, sx, sy, cmd, 0, NULL,
- _PATH_TMP, c, NULL, popup_editor_close_cb, pe) != 0) {
+ if (popup_display(POPUP_INTERNAL|POPUP_CLOSEEXIT, NULL, px, py, sx, sy,
+ cmd, 0, NULL, _PATH_TMP, c, NULL, popup_editor_close_cb, pe) != 0) {
popup_editor_free(pe);
free(cmd);
return (-1);
-/* $OpenBSD: tmux.h,v 1.1120 2021/08/13 18:54:54 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1121 2021/08/13 19:27:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
const char *, job_update_cb, job_complete_cb, job_free_cb,
void *, int, int, int);
void job_free(struct job *);
+int job_transfer(struct job *);
void job_resize(struct job *, u_int, u_int);
void job_check_died(pid_t, int);
int job_get_status(struct job *);
#define POPUP_CLOSEEXIT 0x1
#define POPUP_CLOSEEXITZERO 0x2
#define POPUP_NOBORDER 0x4
+#define POPUP_INTERNAL 0x8
typedef void (*popup_close_cb)(int, void *);
typedef void (*popup_finish_edit_cb)(char *, size_t, void *);
int popup_display(int, struct cmdq_item *, u_int, u_int, u_int,