Skip to content

Commit

Permalink
Merge branch 'obsd-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAdam committed Aug 28, 2024
2 parents 3480738 + 141cd78 commit 3d8ead8
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 96 deletions.
5 changes: 3 additions & 2 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,12 @@ client_send_identify(const char *ttynam, const char *termname, char **caps,
{
char **ss;
size_t sslen;
int fd, flags = client_flags;
int fd;
uint64_t flags = client_flags;
pid_t pid;
u_int i;

proc_send(client_peer, MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags);
proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &flags, sizeof flags);
proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &client_flags,
sizeof client_flags);

Expand Down
6 changes: 4 additions & 2 deletions cmd-copy-mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const struct cmd_entry cmd_copy_mode_entry = {
.name = "copy-mode",
.alias = NULL,

.args = { "eHMs:t:uq", 0, 0, NULL },
.usage = "[-eHMuq] [-s src-pane] " CMD_TARGET_PANE_USAGE,
.args = { "deHMs:t:uq", 0, 0, NULL },
.usage = "[-deHMuq] [-s src-pane] " CMD_TARGET_PANE_USAGE,

.source = { 's', CMD_FIND_PANE, 0 },
.target = { 't', CMD_FIND_PANE, 0 },
Expand Down Expand Up @@ -91,6 +91,8 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
}
if (args_has(args, 'u'))
window_copy_pageup(wp, 0);
if (args_has(args, 'd'))
window_copy_pagedown(wp, 0, args_has(args, 'e'));

return (CMD_RETURN_NORMAL);
}
14 changes: 9 additions & 5 deletions colour.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,13 +942,17 @@ colour_byname(const char *name)
{ "yellow3", 0xcdcd00 },
{ "yellow4", 0x8b8b00 }
};
u_int i;
int c;
u_int i;
int c;
const char *errstr;

if (strncmp(name, "grey", 4) == 0 || strncmp(name, "gray", 4) == 0) {
if (!isdigit((u_char)name[4]))
return (0xbebebe|COLOUR_FLAG_RGB);
c = round(2.55 * atoi(name + 4));
if (name[4] == '\0')
return (-1);
c = strtonum(name + 4, 0, 100, &errstr);
if (errstr != NULL)
return (-1);
c = round(2.55 * c);
if (c < 0 || c > 255)
return (-1);
return (colour_join_rgb(c, c, c));
Expand Down
6 changes: 2 additions & 4 deletions format.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,7 @@ format_cb_mouse_word(struct format_tree *ft)
return (NULL);

if (!TAILQ_EMPTY(&wp->modes)) {
if (TAILQ_FIRST(&wp->modes)->mode == &window_copy_mode ||
TAILQ_FIRST(&wp->modes)->mode == &window_view_mode)
if (window_pane_mode(wp) != WINDOW_PANE_NO_MODE)
return (window_copy_get_word(wp, x, y));
return (NULL);
}
Expand Down Expand Up @@ -1181,8 +1180,7 @@ format_cb_mouse_line(struct format_tree *ft)
return (NULL);

if (!TAILQ_EMPTY(&wp->modes)) {
if (TAILQ_FIRST(&wp->modes)->mode == &window_copy_mode ||
TAILQ_FIRST(&wp->modes)->mode == &window_view_mode)
if (window_pane_mode(wp) != WINDOW_PANE_NO_MODE)
return (window_copy_get_line(wp, y));
return (NULL);
}
Expand Down
16 changes: 14 additions & 2 deletions hyperlinks.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct hyperlinks {
u_int next_inner;
struct hyperlinks_by_inner_tree by_inner;
struct hyperlinks_by_uri_tree by_uri;
u_int references;
};

static int
Expand Down Expand Up @@ -205,6 +206,15 @@ hyperlinks_init(void)
hl->next_inner = 1;
RB_INIT(&hl->by_uri);
RB_INIT(&hl->by_inner);
hl->references = 1;
return (hl);
}

/* Copy hyperlink set. */
struct hyperlinks *
hyperlinks_copy(struct hyperlinks *hl)
{
hl->references++;
return (hl);
}

Expand All @@ -222,6 +232,8 @@ hyperlinks_reset(struct hyperlinks *hl)
void
hyperlinks_free(struct hyperlinks *hl)
{
hyperlinks_reset(hl);
free(hl);
if (--hl->references == 0) {
hyperlinks_reset(hl);
free(hl);
}
}
5 changes: 3 additions & 2 deletions input-keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,9 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key)
* key and no modifiers.
*/
if (!(key & ~KEYC_MASK_KEY)) {
if (key == C0_BS || key == C0_HT ||
key == C0_CR || key == C0_ESC ||
if (key == C0_HT ||
key == C0_CR ||
key == C0_ESC ||
(key >= 0x20 && key <= 0x7f)) {
ud.data[0] = key;
input_key_write(__func__, bev, &ud.data[0], 1);
Expand Down
71 changes: 38 additions & 33 deletions screen-redraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ screen_redraw_two_panes(struct window *w, int direction)

/* Check if cell is on the border of a pane. */
static enum screen_redraw_border_type
screen_redraw_pane_border(struct window_pane *wp, u_int px, u_int py,
int pane_status)
screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
u_int px, u_int py)
{
struct options *oo = wp->window->options;
int split = 0;
u_int ex = wp->xoff + wp->sx, ey = wp->yoff + wp->sy;
u_int ex = wp->xoff + wp->sx, ey = wp->yoff + wp->sy;
int pane_status = ctx->pane_status;

/* Inside pane. */
if (px >= wp->xoff && px < ex && py >= wp->yoff && py < ey)
Expand Down Expand Up @@ -189,8 +190,9 @@ screen_redraw_pane_border(struct window_pane *wp, u_int px, u_int py,

/* Check if a cell is on a border. */
static int
screen_redraw_cell_border(struct client *c, u_int px, u_int py, int pane_status)
screen_redraw_cell_border(struct screen_redraw_ctx *ctx, u_int px, u_int py)
{
struct client *c = ctx->c;
struct window *w = c->session->curw->window;
struct window_pane *wp;

Expand All @@ -206,7 +208,7 @@ screen_redraw_cell_border(struct client *c, u_int px, u_int py, int pane_status)
TAILQ_FOREACH(wp, &w->panes, entry) {
if (!window_pane_visible(wp))
continue;
switch (screen_redraw_pane_border(wp, px, py, pane_status)) {
switch (screen_redraw_pane_border(ctx, wp, px, py)) {
case SCREEN_REDRAW_INSIDE:
return (0);
case SCREEN_REDRAW_OUTSIDE:
Expand All @@ -221,9 +223,10 @@ screen_redraw_cell_border(struct client *c, u_int px, u_int py, int pane_status)

/* Work out type of border cell from surrounding cells. */
static int
screen_redraw_type_of_cell(struct client *c, u_int px, u_int py,
int pane_status)
screen_redraw_type_of_cell(struct screen_redraw_ctx *ctx, u_int px, u_int py)
{
struct client *c = ctx->c;
int pane_status = ctx->pane_status;
struct window *w = c->session->curw->window;
u_int sx = w->sx, sy = w->sy;
int borders = 0;
Expand All @@ -236,28 +239,28 @@ screen_redraw_type_of_cell(struct client *c, u_int px, u_int py,
* Construct a bitmask of whether the cells to the left (bit 4), right,
* top, and bottom (bit 1) of this cell are borders.
*/
if (px == 0 || screen_redraw_cell_border(c, px - 1, py, pane_status))
if (px == 0 || screen_redraw_cell_border(ctx, px - 1, py))
borders |= 8;
if (px <= sx && screen_redraw_cell_border(c, px + 1, py, pane_status))
if (px <= sx && screen_redraw_cell_border(ctx, px + 1, py))
borders |= 4;
if (pane_status == PANE_STATUS_TOP) {
if (py != 0 &&
screen_redraw_cell_border(c, px, py - 1, pane_status))
screen_redraw_cell_border(ctx, px, py - 1))
borders |= 2;
if (screen_redraw_cell_border(c, px, py + 1, pane_status))
if (screen_redraw_cell_border(ctx, px, py + 1))
borders |= 1;
} else if (pane_status == PANE_STATUS_BOTTOM) {
if (py == 0 ||
screen_redraw_cell_border(c, px, py - 1, pane_status))
screen_redraw_cell_border(ctx, px, py - 1))
borders |= 2;
if (py != sy - 1 &&
screen_redraw_cell_border(c, px, py + 1, pane_status))
screen_redraw_cell_border(ctx, px, py + 1))
borders |= 1;
} else {
if (py == 0 ||
screen_redraw_cell_border(c, px, py - 1, pane_status))
screen_redraw_cell_border(ctx, px, py - 1))
borders |= 2;
if (screen_redraw_cell_border(c, px, py + 1, pane_status))
if (screen_redraw_cell_border(ctx, px, py + 1))
borders |= 1;
}

Expand Down Expand Up @@ -295,11 +298,13 @@ screen_redraw_type_of_cell(struct client *c, u_int px, u_int py,

/* Check if cell inside a pane. */
static int
screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,
screen_redraw_check_cell(struct screen_redraw_ctx *ctx, u_int px, u_int py,
struct window_pane **wpp)
{
struct client *c = ctx->c;
struct window *w = c->session->curw->window;
struct window_pane *wp, *active;
int pane_status = ctx->pane_status;
int border;
u_int right, line;

Expand All @@ -308,7 +313,7 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,
if (px > w->sx || py > w->sy)
return (CELL_OUTSIDE);
if (px == w->sx || py == w->sy) /* window border */
return (screen_redraw_type_of_cell(c, px, py, pane_status));
return (screen_redraw_type_of_cell(ctx, px, py));

if (pane_status != PANE_STATUS_OFF) {
active = wp = server_client_get_pane(c);
Expand Down Expand Up @@ -342,12 +347,12 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,
* If definitely inside, return. If not on border, skip.
* Otherwise work out the cell.
*/
border = screen_redraw_pane_border(wp, px, py, pane_status);
border = screen_redraw_pane_border(ctx, wp, px, py);
if (border == SCREEN_REDRAW_INSIDE)
return (CELL_INSIDE);
if (border == SCREEN_REDRAW_OUTSIDE)
goto next2;
return (screen_redraw_type_of_cell(c, px, py, pane_status));
return (screen_redraw_type_of_cell(ctx, px, py));

next2:
wp = TAILQ_NEXT(wp, entry);
Expand All @@ -360,12 +365,12 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,

/* Check if the border of a particular pane. */
static int
screen_redraw_check_is(u_int px, u_int py, int pane_status,
screen_redraw_check_is(struct screen_redraw_ctx *ctx, u_int px, u_int py,
struct window_pane *wp)
{
enum screen_redraw_border_type border;

border = screen_redraw_pane_border(wp, px, py, pane_status);
border = screen_redraw_pane_border(ctx, wp, px, py);
if (border != SCREEN_REDRAW_INSIDE && border != SCREEN_REDRAW_OUTSIDE)
return (1);
return (0);
Expand Down Expand Up @@ -409,11 +414,11 @@ screen_redraw_make_pane_status(struct client *c, struct window_pane *wp,

for (i = 0; i < width; i++) {
px = wp->xoff + 2 + i;
if (rctx->pane_status == PANE_STATUS_TOP)
if (pane_status == PANE_STATUS_TOP)
py = wp->yoff - 1;
else
py = wp->yoff + wp->sy;
cell_type = screen_redraw_type_of_cell(c, px, py, pane_status);
cell_type = screen_redraw_type_of_cell(rctx, px, py);
screen_redraw_border_set(w, wp, pane_lines, cell_type, &gc);
screen_write_cell(&ctx, &gc);
}
Expand Down Expand Up @@ -496,8 +501,8 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx)
}

/* Update status line and change flags if unchanged. */
static int
screen_redraw_update(struct client *c, int flags)
static uint64_t
screen_redraw_update(struct client *c, uint64_t flags)
{
struct window *w = c->session->curw->window;
struct window_pane *wp;
Expand Down Expand Up @@ -567,7 +572,7 @@ void
screen_redraw_screen(struct client *c)
{
struct screen_redraw_ctx ctx;
int flags;
uint64_t flags;

if (c->flags & CLIENT_SUSPENDED)
return;
Expand Down Expand Up @@ -638,7 +643,7 @@ screen_redraw_draw_borders_style(struct screen_redraw_ctx *ctx, u_int x,
wp->border_gc_set = 1;

ft = format_create_defaults(NULL, c, s, s->curw, wp);
if (screen_redraw_check_is(x, y, ctx->pane_status, active))
if (screen_redraw_check_is(ctx, x, y, active))
style_apply(&wp->border_gc, oo, "pane-active-border-style", ft);
else
style_apply(&wp->border_gc, oo, "pane-border-style", ft);
Expand All @@ -663,15 +668,15 @@ screen_redraw_draw_borders_cell(struct screen_redraw_ctx *ctx, u_int i, u_int j)
struct overlay_ranges r;
u_int cell_type, x = ctx->ox + i, y = ctx->oy + j;
int arrows = 0, border;
int pane_status = ctx->pane_status, isolates;
int isolates;

if (c->overlay_check != NULL) {
c->overlay_check(c, c->overlay_data, x, y, 1, &r);
if (r.nx[0] + r.nx[1] == 0)
return;
}

cell_type = screen_redraw_check_cell(c, x, y, pane_status, &wp);
cell_type = screen_redraw_check_cell(ctx, x, y, &wp);
if (cell_type == CELL_INSIDE)
return;

Expand All @@ -692,7 +697,7 @@ screen_redraw_draw_borders_cell(struct screen_redraw_ctx *ctx, u_int i, u_int j)
memcpy(&gc, tmp, sizeof gc);

if (server_is_marked(s, s->curw, marked_pane.wp) &&
screen_redraw_check_is(x, y, pane_status, marked_pane.wp))
screen_redraw_check_is(ctx, x, y, marked_pane.wp))
gc.attr ^= GRID_ATTR_REVERSE;
}
screen_redraw_border_set(w, wp, ctx->pane_lines, cell_type, &gc);
Expand All @@ -719,7 +724,7 @@ screen_redraw_draw_borders_cell(struct screen_redraw_ctx *ctx, u_int i, u_int j)
}

if (wp != NULL && arrows) {
border = screen_redraw_pane_border(active, x, y, pane_status);
border = screen_redraw_pane_border(ctx, active, x, y);
if (((i == wp->xoff + 1 &&
(cell_type == CELL_LEFTRIGHT ||
(cell_type == CELL_TOPJOIN &&
Expand All @@ -732,7 +737,7 @@ screen_redraw_draw_borders_cell(struct screen_redraw_ctx *ctx, u_int i, u_int j)
border == SCREEN_REDRAW_BORDER_RIGHT) ||
(cell_type == CELL_RIGHTJOIN &&
border == SCREEN_REDRAW_BORDER_LEFT)))) &&
screen_redraw_check_is(x, y, pane_status, active)) {
screen_redraw_check_is(ctx, x, y, active)) {
gc.attr |= GRID_ATTR_CHARSET;
utf8_set(&gc.data, BORDER_MARKERS[border]);
}
Expand All @@ -751,7 +756,7 @@ screen_redraw_draw_borders(struct screen_redraw_ctx *ctx)
struct session *s = c->session;
struct window *w = s->curw->window;
struct window_pane *wp;
u_int i, j;
u_int i, j;

log_debug("%s: %s @%u", __func__, c->name, w->id);

Expand Down
Loading

0 comments on commit 3d8ead8

Please sign in to comment.