mirror of
https://github.com/tmux/tmux.git
synced 2026-08-28 17:41:35 +00:00
Expose image backend flags
This commit is contained in:
17
image.c
17
image.c
@@ -87,9 +87,6 @@ static u_int image_next_id;
|
||||
static u_short image_next_grid_id;
|
||||
static struct image *image_grid_ids[USHRT_MAX + 1];
|
||||
|
||||
#define IMAGE_BACKEND_GRAPHICAL 0x1
|
||||
#define IMAGE_BACKEND_SCROLLS 0x2
|
||||
|
||||
struct image_backend {
|
||||
const char *name;
|
||||
int flags;
|
||||
@@ -151,20 +148,12 @@ image_redraw_start(struct tty *tty, u_int x, u_int y, u_int width,
|
||||
kitty_redraw_start(tty, x, y, width, height);
|
||||
}
|
||||
|
||||
/* Return if a terminal can draw graphical images. */
|
||||
/* Return the flags for a terminal's image backend. */
|
||||
int
|
||||
image_tty_is_graphical(struct tty *tty)
|
||||
image_backend_flags(struct tty *tty)
|
||||
{
|
||||
image_tty_update(tty);
|
||||
return (!!(tty->image_backend->flags & IMAGE_BACKEND_GRAPHICAL));
|
||||
}
|
||||
|
||||
/* Return if image output advances the terminal screen. */
|
||||
int
|
||||
image_tty_scrolls(struct tty *tty)
|
||||
{
|
||||
image_tty_update(tty);
|
||||
return (!!(tty->image_backend->flags & IMAGE_BACKEND_SCROLLS));
|
||||
return (tty->image_backend->flags);
|
||||
}
|
||||
|
||||
/* Discard image backend state after a terminal geometry change. */
|
||||
|
||||
6
tmux.h
6
tmux.h
@@ -4235,6 +4235,9 @@ char *regsub(const char *, const char *, const char *, int);
|
||||
|
||||
#ifdef ENABLE_IMAGES
|
||||
/* image.c */
|
||||
#define IMAGE_BACKEND_GRAPHICAL 0x1
|
||||
#define IMAGE_BACKEND_SCROLLS 0x2
|
||||
|
||||
struct image *image_create(u_int, u_int, u_int, u_int, u_int, u_int,
|
||||
u_char *);
|
||||
struct image *image_create_view(struct image *, u_int, u_int, u_int,
|
||||
@@ -4267,8 +4270,7 @@ void image_redraw_area(struct screen_write_ctx *, u_int, u_int,
|
||||
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_tty_is_graphical(struct tty *);
|
||||
int image_tty_scrolls(struct tty *);
|
||||
int image_backend_flags(struct tty *);
|
||||
void image_tty_update(struct tty *);
|
||||
void image_tty_geometry_changed(struct tty *);
|
||||
void image_tty_free(struct tty *, int);
|
||||
|
||||
@@ -264,7 +264,8 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
|
||||
*/
|
||||
if (gc.flags & GRID_FLAG_IMAGE) {
|
||||
im = image_find(gc.image_id);
|
||||
if (image_tty_is_graphical(tty)) {
|
||||
if (image_backend_flags(tty) &
|
||||
IMAGE_BACKEND_GRAPHICAL) {
|
||||
memcpy(&image_gc, &gc,
|
||||
sizeof image_gc);
|
||||
image_gc.flags &= ~(GRID_FLAG_IMAGE|
|
||||
|
||||
2
tty.c
2
tty.c
@@ -2158,7 +2158,7 @@ tty_cell(struct tty *tty, const struct grid_cell *gc,
|
||||
* selection; the unchanged image would then need to be drawn again.
|
||||
*/
|
||||
if (gc->flags & GRID_FLAG_IMAGE) {
|
||||
if (image_tty_is_graphical(tty))
|
||||
if (image_backend_flags(tty) & IMAGE_BACKEND_GRAPHICAL)
|
||||
return;
|
||||
im = image_find(gc->image_id);
|
||||
image_get_fallback_cell(tty, im, gc->image_x, gc->image_y, gc,
|
||||
|
||||
Reference in New Issue
Block a user