-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathterminals.h
More file actions
94 lines (76 loc) · 3.01 KB
/
Copy pathterminals.h
File metadata and controls
94 lines (76 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* terminals.h - Terminal graphics protocol support
*
* Supports Kitty graphics protocol (Kitty, Ghostty) and iTerm2 inline images (iTerm2, WezTerm).
*/
#ifndef TERMINALS_H
#define TERMINALS_H
#include "iris.h"
/* ======================================================================
* Terminal Protocol Types
* ====================================================================== */
typedef enum {
TERM_PROTO_NONE = 0, /* No terminal graphics support detected */
TERM_PROTO_KITTY, /* Kitty graphics protocol (also used by Ghostty) */
TERM_PROTO_ITERM2 /* iTerm2 inline image protocol */
} term_graphics_proto;
/* ======================================================================
* Terminal Detection
* ====================================================================== */
/*
* Detect terminal graphics capability from environment variables.
* Returns the appropriate protocol, or TERM_PROTO_NONE if not detected.
*/
term_graphics_proto detect_terminal_graphics(void);
/* ======================================================================
* Kitty Graphics Protocol
* ====================================================================== */
/*
* Display PNG file using Kitty graphics protocol.
* Returns 0 on success, -1 on error.
*/
int kitty_display_png(const char *path);
/*
* Display raw image data using Kitty graphics protocol.
* Sends raw RGB/RGBA pixels directly (no encoding needed).
* Returns 0 on success, -1 on error.
*/
int kitty_display_image(const iris_image *img);
/* ======================================================================
* iTerm2 Inline Image Protocol
* ====================================================================== */
/*
* Display PNG file using iTerm2 inline image protocol.
* Returns 0 on success, -1 on error.
*/
int iterm2_display_png(const char *path);
/*
* Display raw image data using iTerm2 inline image protocol.
* Internally encodes to PNG (iTerm2 requires an image format).
* Returns 0 on success, -1 on error.
*/
int iterm2_display_image(const iris_image *img);
/* ======================================================================
* Zoom Setting
* ====================================================================== */
/*
* Set the zoom factor for terminal image display (default: 2 for Retina).
* Values: 1 = native pixels, 2 = 2x (Retina), 3 = 3x, etc.
*/
void terminal_set_zoom(int zoom);
/* ======================================================================
* Unified Terminal API
* ====================================================================== */
/*
* Display PNG file using the specified protocol.
* Returns 0 on success, -1 on error.
*/
int terminal_display_png(const char *path, term_graphics_proto proto);
/*
* Display raw image data using the specified protocol.
* For Kitty: sends raw pixels directly.
* For iTerm2: internally encodes to PNG first.
* Returns 0 on success, -1 on error.
*/
int terminal_display_image(const iris_image *img, term_graphics_proto proto);
#endif /* TERMINALS_H */