Merge branch 'obsd-master' into master

pull/2951/head
Thomas Adam 2021-10-26 16:01:11 +01:00
commit c77924bb56
6 changed files with 31 additions and 11 deletions

View File

@ -677,7 +677,8 @@ format_draw_many(struct screen_write_ctx *ctx, struct style *sy, char ch,
/* Draw a format to a screen. */
void
format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
u_int available, const char *expanded, struct style_ranges *srs)
u_int available, const char *expanded, struct style_ranges *srs,
int default_colours)
{
enum { LEFT,
CENTRE,
@ -819,6 +820,10 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
log_debug("%s: style '%s' -> '%s'", __func__, tmp,
style_tostring(&sy));
free(tmp);
if (default_colours) {
sy.gc.bg = base->bg;
sy.gc.fg = base->fg;
}
/* If this style has a fill colour, store it for later. */
if (sy.fill != 8)

View File

@ -716,14 +716,14 @@ mode_tree_draw(struct mode_tree_data *mtd)
screen_write_nputs(&ctx, w, &gc0, "%s", text);
if (mti->text != NULL) {
format_draw(&ctx, &gc0, w - width, mti->text,
NULL);
NULL, 0);
}
} else {
screen_write_clearendofline(&ctx, gc.bg);
screen_write_nputs(&ctx, w, &gc, "%s", text);
if (mti->text != NULL) {
format_draw(&ctx, &gc, w - width, mti->text,
NULL);
NULL, 0);
}
}
free(text);

View File

@ -400,7 +400,7 @@ screen_redraw_make_pane_status(struct client *c, struct window_pane *wp,
gc.attr &= ~GRID_ATTR_CHARSET;
screen_write_cursormove(&ctx, 0, 0, 0);
format_draw(&ctx, &gc, width, expanded, NULL);
format_draw(&ctx, &gc, width, expanded, NULL, 0);
screen_write_stop(&ctx);
free(expanded);

View File

@ -665,10 +665,12 @@ screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu,
if (*name == '-') {
name++;
default_gc.attr |= GRID_ATTR_DIM;
format_draw(ctx, gc, menu->width, name, NULL);
format_draw(ctx, gc, menu->width, name, NULL,
0);
default_gc.attr &= ~GRID_ATTR_DIM;
} else
format_draw(ctx, gc, menu->width, name, NULL);
format_draw(ctx, gc, menu->width, name, NULL,
gc == choice_gc);
gc = &default_gc;
}
}
@ -764,7 +766,7 @@ screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny,
if (title != NULL) {
gc.attr &= ~GRID_ATTR_CHARSET;
screen_write_cursormove(ctx, cx + 2, cy, 0);
format_draw(ctx, &gc, nx - 4, title, NULL);
format_draw(ctx, &gc, nx - 4, title, NULL, 0);
}
screen_write_set_cursor(ctx, cx, cy);

View File

@ -439,7 +439,8 @@ status_redraw(struct client *c)
screen_write_cursormove(&ctx, 0, i, 0);
status_free_ranges(&sle->ranges);
format_draw(&ctx, &gc, width, expanded, &sle->ranges);
format_draw(&ctx, &gc, width, expanded, &sle->ranges,
0);
free(sle->expanded);
sle->expanded = expanded;
@ -562,7 +563,7 @@ status_message_redraw(struct client *c)
if (c->message_ignore_styles)
screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
else
format_draw(&ctx, &gc, c->tty.sx, c->message_string, NULL);
format_draw(&ctx, &gc, c->tty.sx, c->message_string, NULL, 0);
screen_write_stop(&ctx);
if (grid_compare(sl->active->grid, old_screen.grid) == 0) {
@ -809,14 +810,23 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
{
if (c->prompt_mode == PROMPT_ENTRY) {
switch (key) {
case '\001': /* C-a */
case '\003': /* C-c */
case '\005': /* C-e */
case '\007': /* C-g */
case '\010': /* C-h */
case '\011': /* Tab */
case '\013': /* C-k */
case '\016': /* C-n */
case '\020': /* C-p */
case '\024': /* C-t */
case '\025': /* C-u */
case '\027': /* C-w */
case '\031': /* C-y */
case '\n':
case '\r':
case KEYC_LEFT|KEYC_CTRL:
case KEYC_RIGHT|KEYC_CTRL:
case KEYC_BSPACE:
case KEYC_DC:
case KEYC_DOWN:
@ -837,6 +847,9 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
}
switch (key) {
case KEYC_BSPACE:
*new_key = KEYC_LEFT;
return (1);
case 'A':
case 'I':
case 'C':
@ -882,7 +895,7 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
*new_key = 'B'|KEYC_VI;
return (1);
case 'd':
*new_key = '\025';
*new_key = '\025'; /* C-u */
return (1);
case 'e':
*new_key = 'e'|KEYC_VI;

2
tmux.h
View File

@ -2033,7 +2033,7 @@ char *format_grid_line(struct grid *, u_int);
/* format-draw.c */
void format_draw(struct screen_write_ctx *,
const struct grid_cell *, u_int, const char *,
struct style_ranges *);
struct style_ranges *, int);
u_int format_width(const char *);
char *format_trim_left(const char *, u_int);
char *format_trim_right(const char *, u_int);