-/* $OpenBSD: cmd-display-menu.c,v 1.35 2021/10/14 13:19:01 nicm Exp $ */
+/* $OpenBSD: cmd-display-menu.c,v 1.36 2021/10/20 09:50:40 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
.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 },
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);
}
}
+ 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);
}
-/* $OpenBSD: mode-tree.c,v 1.57 2021/10/14 13:19:01 nicm Exp $ */
+/* $OpenBSD: mode-tree.c,v 1.58 2021/10/20 09:50:40 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
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,
-/* $OpenBSD: popup.c,v 1.38 2021/10/14 13:19:01 nicm Exp $ */
+/* $OpenBSD: popup.c,v 1.39 2021/10/20 09:50:40 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
struct cmdq_item *item;
int flags;
enum box_lines lines;
+ char *title;
struct screen s;
struct colour_palette palette;
screen_write_cursormove(&ctx, 0, 0, 0);
screen_write_fast_copy(&ctx, &pd->s, 0, 0, pd->sx, pd->sy);
} else if (pd->sx > 2 && pd->sy > 2) {
- screen_write_box(&ctx, pd->sx, pd->sy, pd->lines, &bgc);
+ screen_write_box(&ctx, pd->sx, pd->sy, pd->lines, &bgc,
+ pd->title);
screen_write_cursormove(&ctx, 1, 1, 0);
screen_write_fast_copy(&ctx, &pd->s, 0, 0, pd->sx - 2,
pd->sy - 2);
screen_free(&pd->s);
colour_palette_free(&pd->palette);
+ free(pd->title);
free(pd);
}
int
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,
- int argc, char **argv, const char *cwd, struct client *c, struct session *s,
- popup_close_cb cb, void *arg)
+ int argc, char **argv, const char *cwd, const char *title, struct client *c,
+ struct session *s, popup_close_cb cb, void *arg)
{
struct popup_data *pd;
u_int jx, jy;
pd->item = item;
pd->flags = flags;
pd->lines = lines;
+ pd->title = xstrdup(title);
pd->c = c;
pd->c->references++;
xasprintf(&cmd, "%s %s", editor, path);
if (popup_display(POPUP_INTERNAL|POPUP_CLOSEEXIT, BOX_LINES_DEFAULT,
- NULL, px, py, sx, sy, NULL, cmd, 0, NULL, _PATH_TMP, c, NULL,
+ // TODO: Helpful to use path as a title?
+ NULL, px, py, sx, sy, NULL, cmd, 0, NULL, _PATH_TMP, NULL, c, NULL,
popup_editor_close_cb, pe) != 0) {
popup_editor_free(pe);
free(cmd);
-/* $OpenBSD: screen-write.c,v 1.201 2021/10/14 13:19:01 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.202 2021/10/20 09:50:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
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;
/* 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;
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);
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);
}
-.\" $OpenBSD: tmux.1,v 1.863 2021/10/18 09:09:46 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.864 2021/10/20 09:50:40 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: October 18 2021 $
+.Dd $Mdocdate: October 20 2021 $
.Dt TMUX 1
.Os
.Sh NAME
.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
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.
-/* $OpenBSD: tmux.h,v 1.1147 2021/10/14 13:19:01 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1148 2021/10/20 09:50:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
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 *);
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 *);
-/* $OpenBSD: window-tree.c,v 1.58 2021/10/14 13:19:01 nicm Exp $ */
+/* $OpenBSD: window-tree.c,v 1.59 2021/10/20 09:50:40 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
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);