mirror of
https://github.com/tmux/tmux.git
synced 2026-08-28 17:41:35 +00:00
Move image cell drawing into image.c
This commit is contained in:
17
image.c
17
image.c
@@ -556,6 +556,23 @@ image_get_fallback_cell(__unused struct tty *tty, struct image *im, u_int x,
|
||||
out->flags &= ~GRID_FLAG_IMAGE;
|
||||
}
|
||||
|
||||
/* Get the terminal cell used to draw an image marker. */
|
||||
int
|
||||
image_get_draw_cell(struct tty *tty, const struct grid_cell *gc,
|
||||
struct grid_cell *out, const struct tty_style_ctx *style_ctx)
|
||||
{
|
||||
struct image *im = image_find(gc->image_id);
|
||||
|
||||
if (image_backend_flags(tty) & IMAGE_BACKEND_GRAPHICAL) {
|
||||
memcpy(out, gc, sizeof *out);
|
||||
out->flags &= ~(GRID_FLAG_IMAGE|GRID_FLAG_SELECTED);
|
||||
return (1);
|
||||
}
|
||||
image_get_fallback_cell(tty, im, gc->image_x, gc->image_y, gc, out,
|
||||
style_ctx);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Store an image marker in a grid cell. */
|
||||
void
|
||||
image_set_cell(struct grid_cell *gc, struct image *im, u_int x, u_int y)
|
||||
|
||||
2
tmux.h
2
tmux.h
@@ -4271,6 +4271,8 @@ void image_redraw_all(struct screen_write_ctx *);
|
||||
void image_redraw_scroll(struct screen_write_ctx *, u_int);
|
||||
void image_redraw_start(struct tty *, u_int, u_int, u_int, u_int);
|
||||
int image_backend_flags(struct tty *);
|
||||
int image_get_draw_cell(struct tty *, const struct grid_cell *,
|
||||
struct grid_cell *, const struct tty_style_ctx *);
|
||||
void image_tty_update(struct tty *);
|
||||
void image_tty_geometry_changed(struct tty *);
|
||||
void image_tty_free(struct tty *, int);
|
||||
|
||||
19
tty-draw.c
19
tty-draw.c
@@ -125,7 +125,6 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
|
||||
struct grid_cell gc, ngc, last;
|
||||
#ifdef ENABLE_IMAGES
|
||||
struct grid_cell image_gc;
|
||||
struct image *im;
|
||||
#endif
|
||||
struct grid_line *gl;
|
||||
u_int i, j, last_i, cx, ex, width;
|
||||
@@ -258,23 +257,9 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
|
||||
grid_view_get_cell(gd, px + i, py, &gc);
|
||||
|
||||
#ifdef ENABLE_IMAGES
|
||||
/*
|
||||
* Graphical terminals draw the saved cell underlay
|
||||
* before the image; text terminals use ASCII.
|
||||
*/
|
||||
if (gc.flags & GRID_FLAG_IMAGE) {
|
||||
im = image_find(gc.image_id);
|
||||
if (image_backend_flags(tty) &
|
||||
IMAGE_BACKEND_GRAPHICAL) {
|
||||
memcpy(&image_gc, &gc,
|
||||
sizeof image_gc);
|
||||
image_gc.flags &= ~(GRID_FLAG_IMAGE|
|
||||
GRID_FLAG_SELECTED);
|
||||
} else {
|
||||
image_get_fallback_cell(tty, im,
|
||||
gc.image_x, gc.image_y, &gc,
|
||||
&image_gc, style_ctx);
|
||||
}
|
||||
(void)image_get_draw_cell(tty, &gc, &image_gc,
|
||||
style_ctx);
|
||||
gcp = &image_gc;
|
||||
} else
|
||||
gcp = &gc;
|
||||
|
||||
11
tty.c
11
tty.c
@@ -2134,7 +2134,6 @@ tty_cell(struct tty *tty, const struct grid_cell *gc,
|
||||
const struct grid_cell *gcp;
|
||||
#ifdef ENABLE_IMAGES
|
||||
struct grid_cell image_gc;
|
||||
struct image *im;
|
||||
#endif
|
||||
|
||||
/* Skip last character if terminal is stupid. */
|
||||
@@ -2152,17 +2151,9 @@ tty_cell(struct tty *tty, const struct grid_cell *gc,
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_IMAGES
|
||||
/*
|
||||
* Graphical image cells are drawn by the redraw scene. In particular,
|
||||
* do not erase one with a selected space while copy mode is moving the
|
||||
* selection; the unchanged image would then need to be drawn again.
|
||||
*/
|
||||
if (gc->flags & GRID_FLAG_IMAGE) {
|
||||
if (image_backend_flags(tty) & IMAGE_BACKEND_GRAPHICAL)
|
||||
if (image_get_draw_cell(tty, gc, &image_gc, style_ctx))
|
||||
return;
|
||||
im = image_find(gc->image_id);
|
||||
image_get_fallback_cell(tty, im, gc->image_x, gc->image_y, gc,
|
||||
&image_gc, style_ctx);
|
||||
gc = &image_gc;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user