summaryrefslogtreecommitdiffstats
path: root/popup.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2021-10-14 16:01:20 +0100
committerThomas Adam <thomas@xteddy.org>2021-10-14 16:01:20 +0100
commit264fe7fc2ac87ee1d337506606f45b3ee4028afe (patch)
tree43a1dc9eb44d6a367404a2a67701c7b47f5680b3 /popup.c
parentee9885a40ced1fd34fe2eed879a40975a0691ac8 (diff)
parentadd20637f256c0118d3c687d5d1446612d14389a (diff)
Merge branch 'obsd-master' into master
Diffstat (limited to 'popup.c')
-rw-r--r--popup.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/popup.c b/popup.c
index 7616d5ca..1d684ac0 100644
--- a/popup.c
+++ b/popup.c
@@ -30,6 +30,7 @@ struct popup_data {
struct client *c;
struct cmdq_item *item;
int flags;
+ enum box_lines lines;
struct screen s;
struct colour_palette palette;
@@ -116,7 +117,7 @@ popup_set_client_cb(struct tty_ctx *ttyctx, struct client *c)
ttyctx->wsx = c->tty.sx;
ttyctx->wsy = c->tty.sy;
- if (pd->flags & POPUP_NOBORDER) {
+ if (pd->lines == BOX_LINES_NONE) {
ttyctx->xoff = ttyctx->rxoff = pd->px;
ttyctx->yoff = ttyctx->ryoff = pd->py;
} else {
@@ -146,7 +147,7 @@ popup_mode_cb(__unused struct client *c, void *data, u_int *cx, u_int *cy)
if (pd->md != NULL)
return (menu_mode_cb(c, pd->md, cx, cy));
- if (pd->flags & POPUP_NOBORDER) {
+ if (pd->lines == BOX_LINES_NONE) {
*cx = pd->px + pd->s.cx;
*cy = pd->py + pd->s.cy;
} else {
@@ -219,14 +220,15 @@ popup_draw_cb(struct client *c, void *data, struct screen_redraw_ctx *rctx)
screen_write_clearscreen(&ctx, 8);
memcpy(&bgc, &grid_default_cell, sizeof bgc);
+ bgc.attr = 0;
style_apply(&bgc, o, "popup-border-style", NULL);
bgc.attr = 0;
- if (pd->flags & POPUP_NOBORDER) {
+ if (pd->lines == BOX_LINES_NONE) {
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, &bgc);
+ screen_write_box(&ctx, pd->sx, pd->sy, pd->lines, &bgc);
screen_write_cursormove(&ctx, 1, 1, 0);
screen_write_fast_copy(&ctx, &pd->s, 0, 0, pd->sx - 2,
pd->sy - 2);
@@ -317,7 +319,7 @@ popup_resize_cb(__unused struct client *c, void *data)
pd->px = pd->ppx;
/* Avoid zero size screens. */
- if (pd->flags & POPUP_NOBORDER) {
+ if (pd->lines == BOX_LINES_NONE) {
screen_resize(&pd->s, pd->sx, pd->sy, 0);
if (pd->job != NULL)
job_resize(pd->job, pd->sx, pd->sy );
@@ -443,7 +445,7 @@ popup_handle_drag(struct client *c, struct popup_data *pd,
pd->ppy = py;
server_redraw_client(c);
} else if (pd->dragging == SIZE) {
- if (pd->flags & POPUP_NOBORDER) {
+ if (pd->lines == BOX_LINES_NONE) {
if (m->x < pd->px + 1)
return;
if (m->y < pd->py + 1)
@@ -459,7 +461,7 @@ popup_handle_drag(struct client *c, struct popup_data *pd,
pd->psx = pd->sx;
pd->psy = pd->sy;
- if (pd->flags & POPUP_NOBORDER) {
+ if (pd->lines == BOX_LINES_NONE) {
screen_resize(&pd->s, pd->sx, pd->sy, 0);
if (pd->job != NULL)
job_resize(pd->job, pd->sx, pd->sy);
@@ -507,7 +509,7 @@ popup_key_cb(struct client *c, void *data, struct key_event *event)
goto menu;
return (0);
}
- if (~pd->flags & POPUP_NOBORDER) {
+ if (pd->lines != BOX_LINES_NONE) {
if (m->x == pd->px)
border = LEFT;
else if (m->x == pd->px + pd->sx - 1)
@@ -541,7 +543,7 @@ popup_key_cb(struct client *c, void *data, struct key_event *event)
if (pd->job != NULL) {
if (KEYC_IS_MOUSE(event->key)) {
/* Must be inside, checked already. */
- if (pd->flags & POPUP_NOBORDER) {
+ if (pd->lines == BOX_LINES_NONE) {
px = m->x - pd->px;
py = m->y - pd->py;
} else {
@@ -627,15 +629,23 @@ popup_job_complete_cb(struct job *job)
}
int
-popup_display(int flags, 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)
+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)
{
struct popup_data *pd;
u_int jx, jy;
+ struct options *o;
- if (flags & POPUP_NOBORDER) {
+ if (lines == BOX_LINES_DEFAULT) {
+ if (s != NULL)
+ o = s->curw->window->options;
+ else
+ o = c->session->curw->window->options;
+ lines = options_get_number(o, "popup-border-lines");
+ }
+ if (lines == BOX_LINES_NONE) {
if (sx < 1 || sy < 1)
return (-1);
jx = sx;
@@ -652,6 +662,7 @@ popup_display(int flags, struct cmdq_item *item, u_int px, u_int py, u_int sx,
pd = xcalloc(1, sizeof *pd);
pd->item = item;
pd->flags = flags;
+ pd->lines = lines;
pd->c = c;
pd->c->references++;
@@ -763,8 +774,9 @@ popup_editor(struct client *c, const char *buf, size_t len,
py = (c->tty.sy / 2) - (sy / 2);
xasprintf(&cmd, "%s %s", editor, path);
- if (popup_display(POPUP_INTERNAL|POPUP_CLOSEEXIT, NULL, px, py, sx, sy,
- NULL, cmd, 0, NULL, _PATH_TMP, c, NULL, popup_editor_close_cb, pe) != 0) {
+ if (popup_display(POPUP_INTERNAL|POPUP_CLOSEEXIT, BOX_LINES_DEFAULT,
+ NULL, px, py, sx, sy, NULL, cmd, 0, NULL, _PATH_TMP, c, NULL,
+ popup_editor_close_cb, pe) != 0) {
popup_editor_free(pe);
free(cmd);
return (-1);