version 1.398, 2021/08/11 07:51:31 |
version 1.399, 2021/08/11 20:49:55 |
|
|
const struct tty_ctx *, u_int, u_int); |
const struct tty_ctx *, u_int, u_int); |
static void tty_invalidate(struct tty *); |
static void tty_invalidate(struct tty *); |
static void tty_colours(struct tty *, const struct grid_cell *); |
static void tty_colours(struct tty *, const struct grid_cell *); |
static void tty_check_fg(struct tty *, int *, struct grid_cell *); |
static void tty_check_fg(struct tty *, struct colour_palette *, |
static void tty_check_bg(struct tty *, int *, struct grid_cell *); |
struct grid_cell *); |
static void tty_check_us(struct tty *, int *, struct grid_cell *); |
static void tty_check_bg(struct tty *, struct colour_palette *, |
|
struct grid_cell *); |
|
static void tty_check_us(struct tty *, struct colour_palette *, |
|
struct grid_cell *); |
static void tty_colours_fg(struct tty *, const struct grid_cell *); |
static void tty_colours_fg(struct tty *, const struct grid_cell *); |
static void tty_colours_bg(struct tty *, const struct grid_cell *); |
static void tty_colours_bg(struct tty *, const struct grid_cell *); |
static void tty_colours_us(struct tty *, const struct grid_cell *); |
static void tty_colours_us(struct tty *, const struct grid_cell *); |
|
|
static void tty_repeat_space(struct tty *, u_int); |
static void tty_repeat_space(struct tty *, u_int); |
static void tty_draw_pane(struct tty *, const struct tty_ctx *, u_int); |
static void tty_draw_pane(struct tty *, const struct tty_ctx *, u_int); |
static void tty_default_attributes(struct tty *, const struct grid_cell *, |
static void tty_default_attributes(struct tty *, const struct grid_cell *, |
int *, u_int); |
struct colour_palette *, u_int); |
static int tty_check_overlay(struct tty *, u_int, u_int); |
static int tty_check_overlay(struct tty *, u_int, u_int); |
|
|
#define tty_use_margin(tty) \ |
#define tty_use_margin(tty) \ |
|
|
c->flags |= (CLIENT_REDRAWWINDOW|CLIENT_REDRAWSTATUS); |
c->flags |= (CLIENT_REDRAWWINDOW|CLIENT_REDRAWSTATUS); |
} |
} |
|
|
/* Get a palette entry. */ |
|
static int |
|
tty_get_palette(int *palette, int c) |
|
{ |
|
int new; |
|
|
|
if (palette == NULL) |
|
return (-1); |
|
|
|
new = -1; |
|
if (c < 8) |
|
new = palette[c]; |
|
else if (c >= 90 && c <= 97) |
|
new = palette[8 + c - 90]; |
|
else if (c & COLOUR_FLAG_256) |
|
new = palette[c & ~COLOUR_FLAG_256]; |
|
if (new == 0) |
|
return (-1); |
|
return (new); |
|
} |
|
|
|
/* |
/* |
* Is the region large enough to be worth redrawing once later rather than |
* Is the region large enough to be worth redrawing once later rather than |
* probably several times now? Currently yes if it is more than 50% of the |
* probably several times now? Currently yes if it is more than 50% of the |
|
|
|
|
void |
void |
tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, |
tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, |
u_int atx, u_int aty, const struct grid_cell *defaults, int *palette) |
u_int atx, u_int aty, const struct grid_cell *defaults, |
|
struct colour_palette *palette) |
{ |
{ |
struct grid *gd = s->grid; |
struct grid *gd = s->grid; |
struct grid_cell gc, last; |
struct grid_cell gc, last; |
|
|
|
|
log_debug("%s: px=%u py=%u nx=%u atx=%u aty=%u", __func__, |
log_debug("%s: px=%u py=%u nx=%u atx=%u aty=%u", __func__, |
px, py, nx, atx, aty); |
px, py, nx, atx, aty); |
|
log_debug("%s: defaults: fg=%d, bg=%d", __func__, defaults->fg, |
|
defaults->bg); |
|
|
/* |
/* |
* py is the line in the screen to draw. |
* py is the line in the screen to draw. |
|
|
|
|
void |
void |
tty_cell(struct tty *tty, const struct grid_cell *gc, |
tty_cell(struct tty *tty, const struct grid_cell *gc, |
const struct grid_cell *defaults, int *palette) |
const struct grid_cell *defaults, struct colour_palette *palette) |
{ |
{ |
const struct grid_cell *gcp; |
const struct grid_cell *gcp; |
|
|
|
|
|
|
void |
void |
tty_attributes(struct tty *tty, const struct grid_cell *gc, |
tty_attributes(struct tty *tty, const struct grid_cell *gc, |
const struct grid_cell *defaults, int *palette) |
const struct grid_cell *defaults, struct colour_palette *palette) |
{ |
{ |
struct grid_cell *tc = &tty->cell, gc2; |
struct grid_cell *tc = &tty->cell, gc2; |
int changed; |
int changed; |
|
|
/* Copy cell and update default colours. */ |
/* Copy cell and update default colours. */ |
memcpy(&gc2, gc, sizeof gc2); |
memcpy(&gc2, gc, sizeof gc2); |
if (gc2.fg == 8) |
if (~gc->flags & GRID_FLAG_NOPALETTE) { |
gc2.fg = defaults->fg; |
if (gc2.fg == 8) |
if (gc2.bg == 8) |
gc2.fg = defaults->fg; |
gc2.bg = defaults->bg; |
if (gc2.bg == 8) |
|
gc2.bg = defaults->bg; |
|
} |
|
|
/* Ignore cell if it is the same as the last one. */ |
/* Ignore cell if it is the same as the last one. */ |
if (gc2.attr == tty->last_cell.attr && |
if (gc2.attr == tty->last_cell.attr && |
|
|
if (!COLOUR_DEFAULT(gc->bg) && gc->bg != tc->bg) |
if (!COLOUR_DEFAULT(gc->bg) && gc->bg != tc->bg) |
tty_colours_bg(tty, gc); |
tty_colours_bg(tty, gc); |
|
|
/* Set the underscore color. */ |
/* Set the underscore colour. */ |
if (gc->us != tc->us) |
if (gc->us != tc->us) |
tty_colours_us(tty, gc); |
tty_colours_us(tty, gc); |
} |
} |
|
|
static void |
static void |
tty_check_fg(struct tty *tty, int *palette, struct grid_cell *gc) |
tty_check_fg(struct tty *tty, struct colour_palette *palette, |
|
struct grid_cell *gc) |
{ |
{ |
u_char r, g, b; |
u_char r, g, b; |
u_int colours; |
u_int colours; |
|
|
c = gc->fg; |
c = gc->fg; |
if (c < 8 && gc->attr & GRID_ATTR_BRIGHT) |
if (c < 8 && gc->attr & GRID_ATTR_BRIGHT) |
c += 90; |
c += 90; |
if ((c = tty_get_palette(palette, c)) != -1) |
if ((c = colour_palette_get(palette, c)) != -1) |
gc->fg = c; |
gc->fg = c; |
} |
} |
|
|
|
|
} |
} |
|
|
static void |
static void |
tty_check_bg(struct tty *tty, int *palette, struct grid_cell *gc) |
tty_check_bg(struct tty *tty, struct colour_palette *palette, |
|
struct grid_cell *gc) |
{ |
{ |
u_char r, g, b; |
u_char r, g, b; |
u_int colours; |
u_int colours; |
|
|
|
|
/* Perform substitution if this pane has a palette. */ |
/* Perform substitution if this pane has a palette. */ |
if (~gc->flags & GRID_FLAG_NOPALETTE) { |
if (~gc->flags & GRID_FLAG_NOPALETTE) { |
if ((c = tty_get_palette(palette, gc->bg)) != -1) |
if ((c = colour_palette_get(palette, gc->bg)) != -1) |
gc->bg = c; |
gc->bg = c; |
} |
} |
|
|
|
|
} |
} |
|
|
static void |
static void |
tty_check_us(__unused struct tty *tty, int *palette, struct grid_cell *gc) |
tty_check_us(__unused struct tty *tty, struct colour_palette *palette, |
|
struct grid_cell *gc) |
{ |
{ |
int c; |
int c; |
|
|
/* Perform substitution if this pane has a palette. */ |
/* Perform substitution if this pane has a palette. */ |
if (~gc->flags & GRID_FLAG_NOPALETTE) { |
if (~gc->flags & GRID_FLAG_NOPALETTE) { |
if ((c = tty_get_palette(palette, gc->us)) != -1) |
if ((c = colour_palette_get(palette, gc->us)) != -1) |
gc->us = c; |
gc->us = c; |
} |
} |
|
|
|
|
tty_window_default_style(struct grid_cell *gc, struct window_pane *wp) |
tty_window_default_style(struct grid_cell *gc, struct window_pane *wp) |
{ |
{ |
memcpy(gc, &grid_default_cell, sizeof *gc); |
memcpy(gc, &grid_default_cell, sizeof *gc); |
gc->fg = wp->fg; |
gc->fg = wp->palette.fg; |
gc->bg = wp->bg; |
gc->bg = wp->palette.bg; |
} |
} |
|
|
void |
void |
|
|
|
|
static void |
static void |
tty_default_attributes(struct tty *tty, const struct grid_cell *defaults, |
tty_default_attributes(struct tty *tty, const struct grid_cell *defaults, |
int *palette, u_int bg) |
struct colour_palette *palette, u_int bg) |
{ |
{ |
struct grid_cell gc; |
struct grid_cell gc; |
|
|