mirror of
https://github.com/tmux/tmux.git
synced 2025-11-24 19:06:07 +00:00
Merge branch 'obsd-master'
This commit is contained in:
@@ -54,8 +54,8 @@ const struct cmd_entry cmd_display_popup_entry = {
|
|||||||
.name = "display-popup",
|
.name = "display-popup",
|
||||||
.alias = "popup",
|
.alias = "popup",
|
||||||
|
|
||||||
.args = { "Bb:Cc:d:e:Eh:ks:S:t:T:w:x:y:", 0, -1, NULL },
|
.args = { "Bb:Cc:d:e:Eh:kNs:S:t:T:w:x:y:", 0, -1, NULL },
|
||||||
.usage = "[-BCEk] [-b border-lines] [-c target-client] "
|
.usage = "[-BCEkN] [-b border-lines] [-c target-client] "
|
||||||
"[-d start-directory] [-e environment] [-h height] "
|
"[-d start-directory] [-e environment] [-h height] "
|
||||||
"[-s style] [-S border-style] " CMD_TARGET_PANE_USAGE
|
"[-s style] [-S border-style] " CMD_TARGET_PANE_USAGE
|
||||||
" [-T title] [-w width] [-x position] [-y position] "
|
" [-T title] [-w width] [-x position] [-y position] "
|
||||||
@@ -92,7 +92,7 @@ cmd_display_menu_args_parse(struct args *args, u_int idx, __unused char **cause)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
|
cmd_display_menu_get_pos(struct client *tc, struct cmdq_item *item,
|
||||||
struct args *args, u_int *px, u_int *py, u_int w, u_int h)
|
struct args *args, u_int *px, u_int *py, u_int w, u_int h)
|
||||||
{
|
{
|
||||||
struct tty *tty = &tc->tty;
|
struct tty *tty = &tc->tty;
|
||||||
@@ -353,8 +353,8 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
menu_free(menu);
|
menu_free(menu);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (!cmd_display_menu_get_position(tc, item, args, &px, &py,
|
if (!cmd_display_menu_get_pos(tc, item, args, &px, &py, menu->width + 4,
|
||||||
menu->width + 4, menu->count + 2)) {
|
menu->count + 2)) {
|
||||||
menu_free(menu);
|
menu_free(menu);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
@@ -392,8 +392,10 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
const char *value, *shell, *shellcmd = NULL;
|
const char *value, *shell, *shellcmd = NULL;
|
||||||
const char *style = args_get(args, 's');
|
const char *style = args_get(args, 's');
|
||||||
const char *border_style = args_get(args, 'S');
|
const char *border_style = args_get(args, 'S');
|
||||||
char *cwd, *cause = NULL, **argv = NULL, *title;
|
char *cwd = NULL, *cause = NULL, **argv = NULL;
|
||||||
int flags = 0, argc = 0;
|
char *title;
|
||||||
|
int modify = popup_present(tc);
|
||||||
|
int flags = -1, argc = 0;
|
||||||
enum box_lines lines = BOX_LINES_DEFAULT;
|
enum box_lines lines = BOX_LINES_DEFAULT;
|
||||||
u_int px, py, w, h, count = args_count(args);
|
u_int px, py, w, h, count = args_count(args);
|
||||||
struct args_value *av;
|
struct args_value *av;
|
||||||
@@ -405,36 +407,68 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
server_client_clear_overlay(tc);
|
server_client_clear_overlay(tc);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (tc->overlay_draw != NULL)
|
if (!modify && tc->overlay_draw != NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
h = tty->sy / 2;
|
if (!modify) {
|
||||||
if (args_has(args, 'h')) {
|
h = tty->sy / 2;
|
||||||
h = args_percentage(args, 'h', 1, tty->sy, tty->sy, &cause);
|
if (args_has(args, 'h')) {
|
||||||
if (cause != NULL) {
|
h = args_percentage(args, 'h', 1, tty->sy, tty->sy,
|
||||||
cmdq_error(item, "height %s", cause);
|
&cause);
|
||||||
free(cause);
|
if (cause != NULL) {
|
||||||
return (CMD_RETURN_ERROR);
|
cmdq_error(item, "height %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
w = tty->sx / 2;
|
||||||
|
if (args_has(args, 'w')) {
|
||||||
|
w = args_percentage(args, 'w', 1, tty->sx, tty->sx,
|
||||||
|
&cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "width %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w > tty->sx)
|
||||||
|
w = tty->sx;
|
||||||
|
if (h > tty->sy)
|
||||||
|
h = tty->sy;
|
||||||
|
if (!cmd_display_menu_get_pos(tc, item, args, &px, &py, w, h))
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
value = args_get(args, 'd');
|
||||||
|
if (value != NULL)
|
||||||
|
cwd = format_single_from_target(item, value);
|
||||||
|
else
|
||||||
|
cwd = xstrdup(server_client_get_cwd(tc, s));
|
||||||
|
if (count == 0) {
|
||||||
|
shellcmd = options_get_string(s->options,
|
||||||
|
"default-command");
|
||||||
|
} else if (count == 1)
|
||||||
|
shellcmd = args_string(args, 0);
|
||||||
|
if (count <= 1 && (shellcmd == NULL || *shellcmd == '\0')) {
|
||||||
|
shellcmd = NULL;
|
||||||
|
shell = options_get_string(s->options, "default-shell");
|
||||||
|
if (!checkshell(shell))
|
||||||
|
shell = _PATH_BSHELL;
|
||||||
|
cmd_append_argv(&argc, &argv, shell);
|
||||||
|
} else
|
||||||
|
args_to_vector(args, &argc, &argv);
|
||||||
|
|
||||||
|
if (args_has(args, 'e') >= 1) {
|
||||||
|
env = environ_create();
|
||||||
|
av = args_first_value(args, 'e');
|
||||||
|
while (av != NULL) {
|
||||||
|
environ_put(env, av->string, 0);
|
||||||
|
av = args_next_value(av);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w = tty->sx / 2;
|
|
||||||
if (args_has(args, 'w')) {
|
|
||||||
w = args_percentage(args, 'w', 1, tty->sx, tty->sx, &cause);
|
|
||||||
if (cause != NULL) {
|
|
||||||
cmdq_error(item, "width %s", cause);
|
|
||||||
free(cause);
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w > tty->sx)
|
|
||||||
w = tty->sx;
|
|
||||||
if (h > tty->sy)
|
|
||||||
h = tty->sy;
|
|
||||||
if (!cmd_display_menu_get_position(tc, item, args, &px, &py, w, h))
|
|
||||||
return (CMD_RETURN_NORMAL);
|
|
||||||
|
|
||||||
value = args_get(args, 'b');
|
value = args_get(args, 'b');
|
||||||
if (args_has(args, 'B'))
|
if (args_has(args, 'B'))
|
||||||
lines = BOX_LINES_NONE;
|
lines = BOX_LINES_NONE;
|
||||||
@@ -449,43 +483,33 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
value = args_get(args, 'd');
|
|
||||||
if (value != NULL)
|
|
||||||
cwd = format_single_from_target(item, value);
|
|
||||||
else
|
|
||||||
cwd = xstrdup(server_client_get_cwd(tc, s));
|
|
||||||
if (count == 0)
|
|
||||||
shellcmd = options_get_string(s->options, "default-command");
|
|
||||||
else if (count == 1)
|
|
||||||
shellcmd = args_string(args, 0);
|
|
||||||
if (count <= 1 && (shellcmd == NULL || *shellcmd == '\0')) {
|
|
||||||
shellcmd = NULL;
|
|
||||||
shell = options_get_string(s->options, "default-shell");
|
|
||||||
if (!checkshell(shell))
|
|
||||||
shell = _PATH_BSHELL;
|
|
||||||
cmd_append_argv(&argc, &argv, shell);
|
|
||||||
} else
|
|
||||||
args_to_vector(args, &argc, &argv);
|
|
||||||
|
|
||||||
if (args_has(args, 'e') >= 1) {
|
|
||||||
env = environ_create();
|
|
||||||
av = args_first_value(args, 'e');
|
|
||||||
while (av != NULL) {
|
|
||||||
environ_put(env, av->string, 0);
|
|
||||||
av = args_next_value(av);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args_has(args, 'T'))
|
if (args_has(args, 'T'))
|
||||||
title = format_single_from_target(item, args_get(args, 'T'));
|
title = format_single_from_target(item, args_get(args, 'T'));
|
||||||
else
|
else
|
||||||
title = xstrdup("");
|
title = xstrdup("");
|
||||||
if (args_has(args, 'E') > 1)
|
|
||||||
|
if (args_has(args, 'N') || !modify)
|
||||||
|
flags = 0;
|
||||||
|
if (args_has(args, 'E') > 1) {
|
||||||
|
if (flags == -1)
|
||||||
|
flags = 0;
|
||||||
flags |= POPUP_CLOSEEXITZERO;
|
flags |= POPUP_CLOSEEXITZERO;
|
||||||
else if (args_has(args, 'E'))
|
} else if (args_has(args, 'E')) {
|
||||||
|
if (flags == -1)
|
||||||
|
flags = 0;
|
||||||
flags |= POPUP_CLOSEEXIT;
|
flags |= POPUP_CLOSEEXIT;
|
||||||
if (args_has(args, 'k'))
|
}
|
||||||
|
if (args_has(args, 'k')) {
|
||||||
|
if (flags == -1)
|
||||||
|
flags = 0;
|
||||||
flags |= POPUP_CLOSEANYKEY;
|
flags |= POPUP_CLOSEANYKEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modify) {
|
||||||
|
popup_modify(tc, title, style, border_style, lines, flags);
|
||||||
|
free(title);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc,
|
if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc,
|
||||||
argv, cwd, title, tc, s, style, border_style, NULL, NULL) != 0) {
|
argv, cwd, title, tc, s, style, border_style, NULL, NULL) != 0) {
|
||||||
cmd_free_argv(argc, argv);
|
cmd_free_argv(argc, argv);
|
||||||
|
|||||||
50
popup.c
50
popup.c
@@ -639,6 +639,56 @@ popup_job_complete_cb(struct job *job)
|
|||||||
server_client_clear_overlay(pd->c);
|
server_client_clear_overlay(pd->c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
popup_present(struct client *c)
|
||||||
|
{
|
||||||
|
return (c->overlay_draw == popup_draw_cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
popup_modify(struct client *c, const char *title, const char *style,
|
||||||
|
const char *border_style, enum box_lines lines, int flags)
|
||||||
|
{
|
||||||
|
struct popup_data *pd = c->overlay_data;
|
||||||
|
struct style sytmp;
|
||||||
|
|
||||||
|
if (title != NULL) {
|
||||||
|
if (pd->title != NULL)
|
||||||
|
free(pd->title);
|
||||||
|
pd->title = xstrdup(title);
|
||||||
|
}
|
||||||
|
if (border_style != NULL) {
|
||||||
|
style_set(&sytmp, &pd->border_cell);
|
||||||
|
if (style_parse(&sytmp, &pd->border_cell, border_style) == 0) {
|
||||||
|
pd->border_cell.fg = sytmp.gc.fg;
|
||||||
|
pd->border_cell.bg = sytmp.gc.bg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (style != NULL) {
|
||||||
|
style_set(&sytmp, &pd->defaults);
|
||||||
|
if (style_parse(&sytmp, &pd->defaults, style) == 0) {
|
||||||
|
pd->defaults.fg = sytmp.gc.fg;
|
||||||
|
pd->defaults.bg = sytmp.gc.bg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lines != BOX_LINES_DEFAULT) {
|
||||||
|
if (lines == BOX_LINES_NONE && pd->border_lines != lines) {
|
||||||
|
screen_resize(&pd->s, pd->sx, pd->sy, 1);
|
||||||
|
job_resize(pd->job, pd->sx, pd->sy);
|
||||||
|
} else if (pd->border_lines == BOX_LINES_NONE && pd->border_lines != lines) {
|
||||||
|
screen_resize(&pd->s, pd->sx - 2, pd->sy - 2, 1);
|
||||||
|
job_resize(pd->job, pd->sx - 2, pd->sy - 2);
|
||||||
|
}
|
||||||
|
pd->border_lines = lines;
|
||||||
|
tty_resize(&c->tty);
|
||||||
|
}
|
||||||
|
if (flags != -1)
|
||||||
|
pd->flags = flags;
|
||||||
|
|
||||||
|
server_redraw_client(c);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
popup_display(int flags, enum box_lines lines, struct cmdq_item *item, u_int px,
|
popup_display(int flags, enum box_lines lines, struct cmdq_item *item, u_int px,
|
||||||
u_int py, u_int sx, u_int sy, struct environ *env, const char *shellcmd,
|
u_int py, u_int sx, u_int sy, struct environ *env, const char *shellcmd,
|
||||||
|
|||||||
19
tmux.1
19
tmux.1
@@ -7001,7 +7001,7 @@ forwards any input read from stdin to the empty pane given by
|
|||||||
.Ar target-pane .
|
.Ar target-pane .
|
||||||
.Tg popup
|
.Tg popup
|
||||||
.It Xo Ic display-popup
|
.It Xo Ic display-popup
|
||||||
.Op Fl BCEk
|
.Op Fl BCEkN
|
||||||
.Op Fl b Ar border-lines
|
.Op Fl b Ar border-lines
|
||||||
.Op Fl c Ar target-client
|
.Op Fl c Ar target-client
|
||||||
.Op Fl d Ar start-directory
|
.Op Fl d Ar start-directory
|
||||||
@@ -7025,6 +7025,20 @@ when omitted) on
|
|||||||
.Ar target-client .
|
.Ar target-client .
|
||||||
A popup is a rectangular box drawn over the top of any panes.
|
A popup is a rectangular box drawn over the top of any panes.
|
||||||
Panes are not updated while a popup is present.
|
Panes are not updated while a popup is present.
|
||||||
|
If the command is run inside an existing popup, that popup is modified.
|
||||||
|
Only the
|
||||||
|
.Fl b ,
|
||||||
|
.Fl B ,
|
||||||
|
.Fl C ,
|
||||||
|
.Fl E ,
|
||||||
|
.Fl EE ,
|
||||||
|
.Fl K ,
|
||||||
|
.Fl N ,
|
||||||
|
.Fl s ,
|
||||||
|
and
|
||||||
|
.Fl S
|
||||||
|
options are accepted in this case;
|
||||||
|
all others are ignored.
|
||||||
.Pp
|
.Pp
|
||||||
.Fl E
|
.Fl E
|
||||||
closes the popup automatically when
|
closes the popup automatically when
|
||||||
@@ -7088,6 +7102,9 @@ is a format for the popup title (see
|
|||||||
The
|
The
|
||||||
.Fl C
|
.Fl C
|
||||||
flag closes any popup on the client.
|
flag closes any popup on the client.
|
||||||
|
.Pp
|
||||||
|
.Fl N
|
||||||
|
disables any previously specified -E, -EE, or -k option.
|
||||||
.Tg showphist
|
.Tg showphist
|
||||||
.It Xo Ic show-prompt-history
|
.It Xo Ic show-prompt-history
|
||||||
.Op Fl T Ar prompt-type
|
.Op Fl T Ar prompt-type
|
||||||
|
|||||||
3
tmux.h
3
tmux.h
@@ -3611,6 +3611,9 @@ int popup_display(int, enum box_lines, struct cmdq_item *, u_int,
|
|||||||
popup_close_cb, void *);
|
popup_close_cb, void *);
|
||||||
int popup_editor(struct client *, const char *, size_t,
|
int popup_editor(struct client *, const char *, size_t,
|
||||||
popup_finish_edit_cb, void *);
|
popup_finish_edit_cb, void *);
|
||||||
|
int popup_present(struct client *);
|
||||||
|
int popup_modify(struct client *, const char *, const char *,
|
||||||
|
const char *, enum box_lines, int);
|
||||||
|
|
||||||
/* style.c */
|
/* style.c */
|
||||||
int style_parse(struct style *,const struct grid_cell *,
|
int style_parse(struct style *,const struct grid_cell *,
|
||||||
|
|||||||
Reference in New Issue
Block a user