mirror of
https://github.com/tmux/tmux.git
synced 2024-11-17 18:08:51 +00:00
Add -T to set a popup title, from Alexis Hildebrandt in GitHub issue 2941.
This commit is contained in:
parent
f26b8c57ff
commit
8a9bfd0cdd
@ -53,10 +53,10 @@ const struct cmd_entry cmd_display_popup_entry = {
|
||||
.name = "display-popup",
|
||||
.alias = "popup",
|
||||
|
||||
.args = { "Bb:Cc:d:e:Eh:t:w:x:y:", 0, -1, NULL },
|
||||
.args = { "Bb:Cc:d:e:Eh:t:T:w:x:y:", 0, -1, NULL },
|
||||
.usage = "[-BCE] [-b border-lines] [-c target-client] "
|
||||
"[-d start-directory] [-e environment] [-h height] "
|
||||
CMD_TARGET_PANE_USAGE " "
|
||||
CMD_TARGET_PANE_USAGE " [-T title] "
|
||||
"[-w width] [-x position] [-y position] [shell-command]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, 0 },
|
||||
@ -355,7 +355,7 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct tty *tty = &tc->tty;
|
||||
const char *value, *shell, *shellcmd = NULL;
|
||||
char *cwd, *cause = NULL, **argv = NULL;
|
||||
char *cwd, *cause = NULL, **argv = NULL, *title;
|
||||
int flags = 0, argc = 0;
|
||||
enum box_lines lines = BOX_LINES_DEFAULT;
|
||||
u_int px, py, w, h, count = args_count(args);
|
||||
@ -439,19 +439,25 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
}
|
||||
|
||||
if (args_has(args, 'T'))
|
||||
title = format_single_from_target(item, args_get(args, 'T'));
|
||||
else
|
||||
title = xstrdup("");
|
||||
if (args_has(args, 'E') > 1)
|
||||
flags |= POPUP_CLOSEEXITZERO;
|
||||
else if (args_has(args, 'E'))
|
||||
flags |= POPUP_CLOSEEXIT;
|
||||
if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc,
|
||||
argv, cwd, tc, s, NULL, NULL) != 0) {
|
||||
argv, cwd, title, tc, s, NULL, NULL) != 0) {
|
||||
cmd_free_argv(argc, argv);
|
||||
if (env != NULL)
|
||||
environ_free(env);
|
||||
free(title);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
if (env != NULL)
|
||||
environ_free(env);
|
||||
free(title);
|
||||
cmd_free_argv(argc, argv);
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ mode_tree_draw(struct mode_tree_data *mtd)
|
||||
mti = mti->parent;
|
||||
|
||||
screen_write_cursormove(&ctx, 0, h, 0);
|
||||
screen_write_box(&ctx, w, sy - h, BOX_LINES_DEFAULT, NULL);
|
||||
screen_write_box(&ctx, w, sy - h, BOX_LINES_DEFAULT, NULL, NULL);
|
||||
|
||||
if (mtd->sort_list != NULL) {
|
||||
xasprintf(&text, " %s (sort: %s%s)", mti->name,
|
||||
|
@ -646,9 +646,7 @@ screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu,
|
||||
memcpy(&default_gc, &grid_default_cell, sizeof default_gc);
|
||||
|
||||
screen_write_box(ctx, menu->width + 4, menu->count + 2,
|
||||
BOX_LINES_DEFAULT, NULL);
|
||||
screen_write_cursormove(ctx, cx + 2, cy, 0);
|
||||
format_draw(ctx, &default_gc, menu->width, menu->title, NULL);
|
||||
BOX_LINES_DEFAULT, &default_gc, menu->title);
|
||||
|
||||
for (i = 0; i < menu->count; i++) {
|
||||
name = menu->items[i].name;
|
||||
@ -714,7 +712,7 @@ screen_write_box_border_set(enum box_lines box_lines, int cell_type,
|
||||
/* Draw a box on screen. */
|
||||
void
|
||||
screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny,
|
||||
enum box_lines l, const struct grid_cell *gcp)
|
||||
enum box_lines lines, const struct grid_cell *gcp, const char *title)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
struct grid_cell gc;
|
||||
@ -727,30 +725,31 @@ screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny,
|
||||
memcpy(&gc, gcp, sizeof gc);
|
||||
else
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
|
||||
gc.attr |= GRID_ATTR_CHARSET;
|
||||
gc.flags |= GRID_FLAG_NOPALETTE;
|
||||
|
||||
/* Draw top border */
|
||||
screen_write_box_border_set(l, CELL_TOPLEFT, &gc);
|
||||
screen_write_box_border_set(lines, CELL_TOPLEFT, &gc);
|
||||
screen_write_cell(ctx, &gc);
|
||||
screen_write_box_border_set(l, CELL_LEFTRIGHT, &gc);
|
||||
screen_write_box_border_set(lines, CELL_LEFTRIGHT, &gc);
|
||||
for (i = 1; i < nx - 1; i++)
|
||||
screen_write_cell(ctx, &gc);
|
||||
screen_write_box_border_set(l, CELL_TOPRIGHT, &gc);
|
||||
screen_write_box_border_set(lines, CELL_TOPRIGHT, &gc);
|
||||
screen_write_cell(ctx, &gc);
|
||||
|
||||
/* Draw bottom border */
|
||||
screen_write_set_cursor(ctx, cx, cy + ny - 1);
|
||||
screen_write_box_border_set(l, CELL_BOTTOMLEFT, &gc);
|
||||
screen_write_box_border_set(lines, CELL_BOTTOMLEFT, &gc);
|
||||
screen_write_cell(ctx, &gc);
|
||||
screen_write_box_border_set(l, CELL_LEFTRIGHT, &gc);
|
||||
screen_write_box_border_set(lines, CELL_LEFTRIGHT, &gc);
|
||||
for (i = 1; i < nx - 1; i++)
|
||||
screen_write_cell(ctx, &gc);
|
||||
screen_write_box_border_set(l, CELL_BOTTOMRIGHT, &gc);
|
||||
screen_write_box_border_set(lines, CELL_BOTTOMRIGHT, &gc);
|
||||
screen_write_cell(ctx, &gc);
|
||||
|
||||
/* Draw sides */
|
||||
screen_write_box_border_set(l, CELL_TOPBOTTOM, &gc);
|
||||
screen_write_box_border_set(lines, CELL_TOPBOTTOM, &gc);
|
||||
for (i = 1; i < ny - 1; i++) {
|
||||
/* left side */
|
||||
screen_write_set_cursor(ctx, cx, cy + i);
|
||||
@ -760,6 +759,12 @@ screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny,
|
||||
screen_write_cell(ctx, &gc);
|
||||
}
|
||||
|
||||
if (title != NULL) {
|
||||
gc.attr &= ~GRID_ATTR_CHARSET;
|
||||
screen_write_cursormove(ctx, cx + 2, cy, 0);
|
||||
format_draw(ctx, &gc, nx - 4, title, NULL);
|
||||
}
|
||||
|
||||
screen_write_set_cursor(ctx, cx, cy);
|
||||
}
|
||||
|
||||
|
5
tmux.1
5
tmux.1
@ -5801,6 +5801,7 @@ forwards any input read from stdin to the empty pane given by
|
||||
.Op Fl e Ar environment
|
||||
.Op Fl h Ar height
|
||||
.Op Fl t Ar target-pane
|
||||
.Op Fl T Ar title
|
||||
.Op Fl w Ar width
|
||||
.Op Fl x Ar position
|
||||
.Op Fl y Ar position
|
||||
@ -5858,6 +5859,10 @@ takes the form
|
||||
and sets an environment variable for the popup; it may be specified multiple
|
||||
times.
|
||||
.Pp
|
||||
.Fl T
|
||||
is a format for the popup title (see
|
||||
.Sx FORMATS ) .
|
||||
.Pp
|
||||
The
|
||||
.Fl C
|
||||
flag closes any popup on the client.
|
||||
|
6
tmux.h
6
tmux.h
@ -2737,7 +2737,7 @@ void screen_write_vline(struct screen_write_ctx *, u_int, int, int);
|
||||
void screen_write_menu(struct screen_write_ctx *, struct menu *, int,
|
||||
const struct grid_cell *);
|
||||
void screen_write_box(struct screen_write_ctx *, u_int, u_int, int,
|
||||
const struct grid_cell *);
|
||||
const struct grid_cell *, const char *);
|
||||
void screen_write_preview(struct screen_write_ctx *, struct screen *, u_int,
|
||||
u_int);
|
||||
void screen_write_backspace(struct screen_write_ctx *);
|
||||
@ -3154,8 +3154,8 @@ typedef void (*popup_close_cb)(int, void *);
|
||||
typedef void (*popup_finish_edit_cb)(char *, size_t, void *);
|
||||
int popup_display(int, int, struct cmdq_item *, u_int, u_int,
|
||||
u_int, u_int, struct environ *, const char *, int, char **,
|
||||
const char *, struct client *, struct session *,
|
||||
popup_close_cb, void *);
|
||||
const char *, const char *, struct client *,
|
||||
struct session *, popup_close_cb, void *);
|
||||
int popup_editor(struct client *, const char *, size_t,
|
||||
popup_finish_edit_cb, void *);
|
||||
|
||||
|
@ -519,7 +519,8 @@ window_tree_draw_label(struct screen_write_ctx *ctx, u_int px, u_int py,
|
||||
|
||||
if (ox > 1 && ox + len < sx - 1 && sy >= 3) {
|
||||
screen_write_cursormove(ctx, px + ox - 1, py + oy - 1, 0);
|
||||
screen_write_box(ctx, len + 2, 3, BOX_LINES_DEFAULT, NULL);
|
||||
screen_write_box(ctx, len + 2, 3, BOX_LINES_DEFAULT, NULL,
|
||||
NULL);
|
||||
}
|
||||
screen_write_cursormove(ctx, px + ox, py + oy, 0);
|
||||
screen_write_puts(ctx, gc, "%s", label);
|
||||
|
Loading…
Reference in New Issue
Block a user