Skip to content

Commit

Permalink
update CI for julia LTS 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Dec 19, 2021
1 parent 8ae3ae3 commit df995db
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ['1.0', '1', 'nightly']
os: [ubuntu-latest]
arch: [x64]
version:
- '1.6' # LTS
- '1' # latest stable
- 'nightly'
os:
- ubuntu-latest
arch:
- x64
include: # spare windows/macos CI credits
- os: windows-latest
version: '1'
arch: x64
- os: macOS-latest
version: '1'
arch: x64

steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand Down
55 changes: 28 additions & 27 deletions src/canvas/imgcanvas.jl
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
struct ImgCanvas <: Canvas
img::AbstractArray{<:Colorant}
ren::Vector{String}
encoded_size::Vector{Int}
sixel::Ref
img::AbstractArray{<:Colorant}
ren::Vector{String}
encoded_size::Vector{Int}
sixel::Ref
end

function ImgCanvas(img::AbstractArray{<:Colorant})
render(ImgCanvas(img, String[], [0, 0], Ref(false)))
end
ImgCanvas(img::AbstractArray{<:Colorant}) =
render(ImgCanvas(img, String[], [0, 0], Ref(false)))

@inline nrows(c::ImgCanvas) = c.encoded_size[1]
@inline ncols(c::ImgCanvas) = c.encoded_size[2]

function render(c::ImgCanvas)
if ImageInTerminal.use_sixel(c.img)
c.sixel[] = true
lines = String[]
h, w = size(c.img)
char_pixels = ImageInTerminal.Sixel.TerminalTools.query_terminal("\e[16t", r"\e\[6;(\d+);(\d+)t", stdout)
char_h, char_w = length(char_pixels) > 1 ? parse.(Int, char_pixels) : (15, 7)
for r 1:char_h:h
io = IOBuffer()
ImageInTerminal.sixel_encode(io, c.img[r:min(r + char_h - 1, h), :])
push!(lines, String(take!(io)))
if ImageInTerminal.use_sixel(c.img)
c.sixel[] = true
h, w = size(c.img)
# determine the terminal carret size, in pixels
char_pixels = ImageInTerminal.Sixel.TerminalTools.query_terminal("\e[16t", r"\e\[6;(\d+);(\d+)t", stdout)
char_h, char_w = length(char_pixels) > 1 ? parse.(Int, char_pixels) : (15, 7)
lines = String[]
io = IOBuffer()
for r 1:char_h:h
ImageInTerminal.sixel_encode(io, c.img[r:min(r + char_h - 1, h), :])
push!(lines, String(take!(io)))
end
enc_size = length(lines), ceil(Int, w / char_w)
else
io = PipeBuffer()
ImageInTerminal.imshow(io, c.img)
lines = readlines(io)
enc_size = length(lines), length(replace(first(lines), r"\x1B\[[0-9;]*[a-zA-Z]" => ""))
end
copyto!(c.encoded_size, [length(lines), ceil(Int, w / char_w)])
else
io = PipeBuffer()
ImageInTerminal.imshow(io, c.img, ImageInTerminal.colormode[1])
lines = readlines(io)
copyto!(c.encoded_size, [length(lines), length(replace(first(lines), r"\x1B\[[0-9;]*[a-zA-Z]" => ""))])
end
resize!(c.ren, nrows(c))
copyto!(c.ren, lines)
c
copyto!(c.encoded_size, enc_size)
resize!(c.ren, nrows(c))
copyto!(c.ren, lines)
c
end

function printrow(io::IO, c::ImgCanvas, row::Int)
Expand Down

0 comments on commit df995db

Please sign in to comment.