version 1.37, 2021/10/13 09:28:36 |
version 1.38, 2021/10/14 13:19:01 |
|
|
struct client *c; |
struct client *c; |
struct cmdq_item *item; |
struct cmdq_item *item; |
int flags; |
int flags; |
|
enum box_lines lines; |
|
|
struct screen s; |
struct screen s; |
struct colour_palette palette; |
struct colour_palette palette; |
|
|
ttyctx->wsx = c->tty.sx; |
ttyctx->wsx = c->tty.sx; |
ttyctx->wsy = c->tty.sy; |
ttyctx->wsy = c->tty.sy; |
|
|
if (pd->flags & POPUP_NOBORDER) { |
if (pd->lines == BOX_LINES_NONE) { |
ttyctx->xoff = ttyctx->rxoff = pd->px; |
ttyctx->xoff = ttyctx->rxoff = pd->px; |
ttyctx->yoff = ttyctx->ryoff = pd->py; |
ttyctx->yoff = ttyctx->ryoff = pd->py; |
} else { |
} else { |
|
|
if (pd->md != NULL) |
if (pd->md != NULL) |
return (menu_mode_cb(c, pd->md, cx, cy)); |
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; |
*cx = pd->px + pd->s.cx; |
*cy = pd->py + pd->s.cy; |
*cy = pd->py + pd->s.cy; |
} else { |
} else { |
|
|
screen_write_clearscreen(&ctx, 8); |
screen_write_clearscreen(&ctx, 8); |
|
|
memcpy(&bgc, &grid_default_cell, sizeof bgc); |
memcpy(&bgc, &grid_default_cell, sizeof bgc); |
|
bgc.attr = 0; |
style_apply(&bgc, o, "popup-border-style", NULL); |
style_apply(&bgc, o, "popup-border-style", NULL); |
bgc.attr = 0; |
bgc.attr = 0; |
|
|
if (pd->flags & POPUP_NOBORDER) { |
if (pd->lines == BOX_LINES_NONE) { |
screen_write_cursormove(&ctx, 0, 0, 0); |
screen_write_cursormove(&ctx, 0, 0, 0); |
screen_write_fast_copy(&ctx, &pd->s, 0, 0, pd->sx, pd->sy); |
screen_write_fast_copy(&ctx, &pd->s, 0, 0, pd->sx, pd->sy); |
} else if (pd->sx > 2 && pd->sy > 2) { |
} 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_cursormove(&ctx, 1, 1, 0); |
screen_write_fast_copy(&ctx, &pd->s, 0, 0, pd->sx - 2, |
screen_write_fast_copy(&ctx, &pd->s, 0, 0, pd->sx - 2, |
pd->sy - 2); |
pd->sy - 2); |
|
|
pd->px = pd->ppx; |
pd->px = pd->ppx; |
|
|
/* Avoid zero size screens. */ |
/* Avoid zero size screens. */ |
if (pd->flags & POPUP_NOBORDER) { |
if (pd->lines == BOX_LINES_NONE) { |
screen_resize(&pd->s, pd->sx, pd->sy, 0); |
screen_resize(&pd->s, pd->sx, pd->sy, 0); |
if (pd->job != NULL) |
if (pd->job != NULL) |
job_resize(pd->job, pd->sx, pd->sy ); |
job_resize(pd->job, pd->sx, pd->sy ); |
|
|
pd->ppy = py; |
pd->ppy = py; |
server_redraw_client(c); |
server_redraw_client(c); |
} else if (pd->dragging == SIZE) { |
} else if (pd->dragging == SIZE) { |
if (pd->flags & POPUP_NOBORDER) { |
if (pd->lines == BOX_LINES_NONE) { |
if (m->x < pd->px + 1) |
if (m->x < pd->px + 1) |
return; |
return; |
if (m->y < pd->py + 1) |
if (m->y < pd->py + 1) |
|
|
pd->psx = pd->sx; |
pd->psx = pd->sx; |
pd->psy = pd->sy; |
pd->psy = pd->sy; |
|
|
if (pd->flags & POPUP_NOBORDER) { |
if (pd->lines == BOX_LINES_NONE) { |
screen_resize(&pd->s, pd->sx, pd->sy, 0); |
screen_resize(&pd->s, pd->sx, pd->sy, 0); |
if (pd->job != NULL) |
if (pd->job != NULL) |
job_resize(pd->job, pd->sx, pd->sy); |
job_resize(pd->job, pd->sx, pd->sy); |
|
|
goto menu; |
goto menu; |
return (0); |
return (0); |
} |
} |
if (~pd->flags & POPUP_NOBORDER) { |
if (pd->lines != BOX_LINES_NONE) { |
if (m->x == pd->px) |
if (m->x == pd->px) |
border = LEFT; |
border = LEFT; |
else if (m->x == pd->px + pd->sx - 1) |
else if (m->x == pd->px + pd->sx - 1) |
|
|
if (pd->job != NULL) { |
if (pd->job != NULL) { |
if (KEYC_IS_MOUSE(event->key)) { |
if (KEYC_IS_MOUSE(event->key)) { |
/* Must be inside, checked already. */ |
/* Must be inside, checked already. */ |
if (pd->flags & POPUP_NOBORDER) { |
if (pd->lines == BOX_LINES_NONE) { |
px = m->x - pd->px; |
px = m->x - pd->px; |
py = m->y - pd->py; |
py = m->y - pd->py; |
} else { |
} else { |
|
|
} |
} |
|
|
int |
int |
popup_display(int flags, struct cmdq_item *item, u_int px, u_int py, u_int sx, |
popup_display(int flags, enum box_lines lines, struct cmdq_item *item, u_int px, |
u_int sy, struct environ *env, const char *shellcmd, int argc, char **argv, |
u_int py, u_int sx, u_int sy, struct environ *env, const char *shellcmd, |
const char *cwd, struct client *c, struct session *s, popup_close_cb cb, |
int argc, char **argv, const char *cwd, struct client *c, struct session *s, |
void *arg) |
popup_close_cb cb, void *arg) |
{ |
{ |
struct popup_data *pd; |
struct popup_data *pd; |
u_int jx, jy; |
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) |
if (sx < 1 || sy < 1) |
return (-1); |
return (-1); |
jx = sx; |
jx = sx; |
|
|
pd = xcalloc(1, sizeof *pd); |
pd = xcalloc(1, sizeof *pd); |
pd->item = item; |
pd->item = item; |
pd->flags = flags; |
pd->flags = flags; |
|
pd->lines = lines; |
|
|
pd->c = c; |
pd->c = c; |
pd->c->references++; |
pd->c->references++; |
|
|
py = (c->tty.sy / 2) - (sy / 2); |
py = (c->tty.sy / 2) - (sy / 2); |
|
|
xasprintf(&cmd, "%s %s", editor, path); |
xasprintf(&cmd, "%s %s", editor, path); |
if (popup_display(POPUP_INTERNAL|POPUP_CLOSEEXIT, NULL, px, py, sx, sy, |
if (popup_display(POPUP_INTERNAL|POPUP_CLOSEEXIT, BOX_LINES_DEFAULT, |
NULL, cmd, 0, NULL, _PATH_TMP, c, NULL, popup_editor_close_cb, pe) != 0) { |
NULL, px, py, sx, sy, NULL, cmd, 0, NULL, _PATH_TMP, c, NULL, |
|
popup_editor_close_cb, pe) != 0) { |
popup_editor_free(pe); |
popup_editor_free(pe); |
free(cmd); |
free(cmd); |
return (-1); |
return (-1); |