2424@inline nrows (c:: ImageGraphics ) = first (c. encoded_size)
2525@inline ncols (c:: ImageGraphics ) = last (c. encoded_size)
2626
27+ # `ImageInTerminalExt` placeholders
28+ function terminal_specs end
29+ function sixel_encode end
30+ function imshow end
31+
2732function preprocess! (io:: IO , c:: ImageGraphics )
2833 ctx = IOContext (PipeBuffer (), :displaysize => displaysize (io))
29- c. sixel[] = false
30- char_h = char_w = nothing # determine the terminal caret size, in pixels
31- # COV_EXCL_START
32- if ImageInTerminal. choose_sixel (c. img)
33- ans = ImageInTerminal. Sixel. TerminalTools. query_terminal (" \e [16t" , stdout )
34- if ans isa String && (m = match (r" \e\[ 6;(\d +);(\d +)t" , ans)) ≢ nothing
35- char_h, char_w = tryparse .(Int, m. captures)
36- c. sixel[] = char_h ≢ nothing && char_w ≢ nothing
37- end
38- end
39- # COV_EXCL_STOP
34+ c. sixel[], char_h, char_w = terminal_specs (c. img)
4035 postprocess = c -> begin
4136 c. encoded_size .= (0 , 0 )
4237 empty! (c. chars)
@@ -49,7 +44,7 @@ function preprocess!(io::IO, c::ImageGraphics)
4944 # COV_EXCL_START
5045 # it is better to encode the whole image in a single pass
5146 # otherwise, issues with the last line (see previous implementation)
52- ImageInTerminal . sixel_encode (ctx, c. img)
47+ sixel_encode (ctx, c. img)
5348 push! (c. chars, read (ctx, String) |> collect)
5449 length (1 : char_h: img_h), ceil (Int, img_w / char_w)
5550 # COV_EXCL_STOP
@@ -69,7 +64,7 @@ function preprocess!(io::IO, c::ImageGraphics)
6964 end
7065 nothing
7166 end
72- ImageInTerminal . imshow (ctx, c. img; callback)
67+ imshow (ctx, c. img; callback)
7368 length (c. chars), length (c. chars |> first)
7469 end
7570 postprocess
0 commit comments