forked from 3rd/image.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.lua
200 lines (183 loc) · 7.23 KB
/
types.lua
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---@meta
---@class API
---@field setup fun(options?: Options)
---@field from_file fun(path: string, options?: ImageOptions): Image|nil
---@field from_url fun(url: string, options?: ImageOptions, callback: fun(image: Image|nil))
---@field clear fun(id?: string)
---@field get_images fun(opts?: { window?: number, buffer?: number, namespace?: string }): Image[]
---@field hijack_buffer fun(path: string, window?: number, buffer?: number, options?: ImageOptions): Image|nil
---@class State
---@field backend Backend
---@field options Options
---@field images { [string]: Image }
---@field extmarks_namespace any
---@field remote_cache { [string]: string }
---@field tmp_dir string
---@field disable_decorator_handling boolean
---@field hijacked_win_buf_images { [string]: Image }
---@field processor ImageProcessor
---@class DocumentIntegrationOptions
---@field enabled? boolean
---@field download_remote_images? boolean
---@field clear_in_insert_mode? boolean
---@field only_render_image_at_cursor? boolean
---@field filetypes? string[]
---@field resolve_image_path? function
---@field floating_windows? boolean
---@alias IntegrationOptions DocumentIntegrationOptions
---@class Options
---@field backend "kitty"|"ueberzug"
---@field integrations table<string, IntegrationOptions>
---@field max_width? number
---@field max_height? number
---@field max_width_window_percentage? number
---@field max_height_window_percentage? number
---@field scale_factor? number
---@field kitty_method "normal"|"unicode-placeholders"
---@field window_overlap_clear_enabled? boolean
---@field window_overlap_clear_ft_ignore? string[]
---@field editor_only_render_when_focused? boolean
---@field tmux_show_only_in_active_window? boolean
---@field hijack_file_patterns? string[]
---@field processor? string
---@class BackendFeatures
---@field crop boolean
---@class Backend
---@field state State
---@field features BackendFeatures
---@field setup fun(state: State)
---@field render fun(image: Image, x: number, y: number, width?: number, height?: number)
---@field clear fun(id?: string, shallow?: boolean)
---@class ImageGeometry
---@field x? number
---@field y? number
---@field width? number
---@field height? number
---@class ImageOptions: ImageGeometry
---@field id? string
---@field window? number
---@field buffer? number
---@field with_virtual_padding? boolean
---@field inline? boolean
---@field namespace? string
---@field max_width_window_percentage? number
---@field max_height_window_percentage? number
---@class ImageBounds
---@field top number
---@field right number
---@field bottom number
---@field left number
---@class MagickRockImage
---@field adaptive_resize fun(self: MagickRockImage, width: number, height: number)
---@field clone fun(self: MagickRockImage): MagickRockImage
---@field composite fun(self: MagickRockImage, source: MagickRockImage, x: number, y: number, operator?: string)
---@field crop fun(self: MagickRockImage, width: number, height: number, x?: number, y?: number)
---@field destroy fun(self: MagickRockImage)
---@field get_format fun(self: MagickRockImage): string
---@field get_height fun(self: MagickRockImage): number
---@field get_width fun(self: MagickRockImage): number
---@field modulate fun(self: MagickRockImage, brightness?: number, saturation?: number, hue?: number)
---@field resize fun(self: MagickRockImage, width: number, height: number)
---@field resize_and_crop fun(self: MagickRockImage, width: number, height: number)
---@field scale fun(self: MagickRockImage, width: number, height: number)
---@field set_format fun(self: MagickRockImage, format: string)
---@field write fun(self: MagickRockImage, path: string)
---@class Image
---@field id string
---@field internal_id number
---@field path string
---@field resized_path string
---@field cropped_path string
---@field original_path string
---@field image_width number
---@field image_height number
---@field max_width_window_percentage? number
---@field max_height_window_percentage? number
---@field window? number
---@field buffer? number
---@field with_virtual_padding? boolean
---@field inline? boolean
---@field geometry ImageGeometry
---@field rendered_geometry ImageGeometry
---@field bounds ImageBounds
---@field is_rendered boolean
---@field resize_hash? string
---@field crop_hash? string
---@field global_state State
---@field render fun(self: Image, geometry?: ImageGeometry)
---@field clear fun(self: Image, shallow?: boolean)
---@field move fun(self: Image, x: number, y: number)
---@field brightness fun(self: Image, brightness: number)
---@field saturation fun(self: Image, saturation: number)
---@field hue fun(self: Image, hue: number)
---@field namespace? string
---@field extmark? { id: number, row: number, col: number }
---@field last_modified? number
---@field has_extmark_moved fun (self:Image): (boolean, number?, number?)
---@class ImageProcessor
--- We need to:
--- - get image format
--- - convert non-png images to png
--- - get dimensions
--- - resize
--- - crop
--- - adjust brightness, saturation, hue
---@field get_format fun(path: string): string
---@field convert_to_png fun(path: string, output_path?: string): string
---@field get_dimensions fun(path: string): { width: number, height: number }
---@field resize fun(path: string, width: number, height: number, output_path?: string): string
---@field crop fun(path: string, x: number, y: number, width: number, height: number, output_path?: string): string
---@field brightness fun(path: string, brightness: number, output_path?: string): string
---@field saturation fun(path: string, saturation: number, output_path?: string): string
---@field hue fun(path: string, hue: number, output_path?: string): string
-- wish proper generics were a thing here
---@class IntegrationContext
---@field api API
---@field options IntegrationOptions
---@field state State
---@class Integration
---@field setup? fun(api: API, options: IntegrationOptions, state: State)
---@class Window
---@field id number
---@field buffer number
---@field buffer_filetype string
---@field buffer_is_listed boolean
---@field x number
---@field y number
---@field width number
---@field height number
---@field scroll_x number
---@field scroll_y number
---@field is_visible boolean
---@field is_normal boolean
---@field is_floating boolean
---@field zindex number
---@field rect { top: number, right: number, bottom: number, left: number }
---@field masks { x: number, y: number, width: number, height: number }[]
---@class KittyControlConfig
---@field action "t"|"T"|"p"|"d"|"f"|"c"|"a"|"q"
---@field image_id? string|number
---@field image_number? number
---@field placement_id? string|number
---@field quiet? 0|1|2
---@field transmit_format? 32|24|100
---@field transmit_medium? "d"|"f"|"t"|"s"
---@field transmit_more? 0|1
---@field transmit_width? number
---@field transmit_height? number
---@field transmit_file_size? number
---@field transmit_file_offset? number
---@field transmit_compression? 0|1
---@field display_x? number
---@field display_y? number
---@field display_width? number
---@field display_height? number
---@field display_x_offset? number
---@field display_y_offset? number
---@field display_columns? number
---@field display_rows? number
---@field display_cursor_policy? 0|1
---@field display_virtual_placeholder? 0|1
---@field display_zindex? number
---@field display_delete? "a"|"A"|"i"|"I"|"p"
---@field tty? string