Skip to content

Commit 12f36c3

Browse files
authored
Fix querying device attributes on Windows (#31)
1 parent 0602d28 commit 12f36c3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Sixel.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ Check if given terminal `tty` supports sixel format.
4646
(Experiment) The return value is not fully tested on all terminals and all platforms.
4747
"""
4848
function is_sixel_supported(tty::Base.TTY=stdout)
49-
'4' in TerminalTools.query_terminal("\033[0c", tty)
49+
device_attributes = TerminalTools.query_terminal("\033[0c", tty)
50+
"4" in split(chop(device_attributes), ';')
5051
end
5152
is_sixel_supported(io::IO) = false
5253

src/terminaltools.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ function query_terminal(msg, tty::TTY; timeout=1)
5454
timeout_call(timeout; pollint=timeout/100) do
5555
with_raw(term) do
5656
write(tty, msg)
57-
return transcode(String, readavailable(tty))
57+
return @static if Sys.iswindows()
58+
response = ""
59+
while !endswith(response, 'c')
60+
response *= read(stdin, Char)
61+
end
62+
response
63+
else
64+
transcode(String, readavailable(tty))
65+
end
5866
end
5967
end
6068
catch e

0 commit comments

Comments
 (0)