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 20, 2021
1 parent 8ae3ae3 commit b928463
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
ColorTypes = "0.11"
ColorTypes = "0.9 - 0.11"
Crayons = "4.0"
Requires = "1"
StatsBase = "0.32, 0.33"
Expand Down
2 changes: 1 addition & 1 deletion src/UnicodePlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ include("interface/boxplot.jl")
image(args...; kwargs...) = @warn "not implemented, did you forget 'using ImageInTerminal' ?"

function __init__()
@require ImageInTerminal="d8c32880-2388-543b-8c61-d9f865259254" begin
@require ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" begin
image(img::AbstractArray{<:Colorant}; kwargs...) = Plot(ImgCanvas(img); kwargs...)
end
end
Expand Down
54 changes: 27 additions & 27 deletions src/canvas/imgcanvas.jl
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
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 (c.sixel[] = ImageInTerminal.use_sixel(c.img))
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 b928463

Please sign in to comment.