Skip to content

Commit 7658aa1

Browse files
authored
refactor package structure (#58)
* refactor package structure * lena -> monarch * indent * remove duplicate test files * revert adding TerminalGraphicDisplay * rework * IOBuffer -> PipeBuffer * fix regression * revert format change * change readme name * move imshow to AsciiPixel * 256 -> 8bit, rework test, rework imgshow * rename ascii_encode -> ascii_display when using io, rework downscale * checkpoint downscale * rework ImageEncoder structure * allow direct encoding to io * update docstrings * add tests for ascii_display * improve docs, reduce dependencies * properly deprecate imsho256 and imshow24bit - unify trail_nl * drop docstring for downscale_XXX, moved to comment * use custom print function for Crayons * simplify test ascii * fix broken ensurecolor macro * fix reg - maxsize unused in imshow * checkpoint * fix typo * monarch.png -> mandril.tif, drop ImageIO * restore ImageIO * rebase: fix import - fix tests * update workflows * reorganize tests - hard `Sixel` dependency - format check
1 parent ec6ab9a commit 7658aa1

File tree

68 files changed

+1367
-1159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1367
-1159
lines changed

.JuliaFormatter.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
style = "blue"
2+
short_to_long_function_def = false
3+
always_use_return = false
4+
import_to_using = false
5+
align_struct_field = true
6+
align_conditional = true
7+
align_assignment = true
8+
align_pair_arrow = true
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
name: Unit test
2-
on:
3-
create:
4-
tags:
5-
push:
6-
branches:
7-
- master
8-
pull_request:
1+
name: CI
2+
on: [push, pull_request]
93
defaults:
104
run:
115
shell: bash
12-
136
jobs:
147
test:
158
if: "!contains(github.event.head_commit.message, '[skip ci]')"
@@ -31,20 +24,14 @@ jobs:
3124
version: '1'
3225

3326
steps:
34-
- uses: actions/checkout@v2
35-
- uses: julia-actions/setup-julia@v1
27+
- uses: actions/checkout@v3
28+
- uses: julia-actions/setup-julia@latest
3629
with:
3730
version: ${{ matrix.version }}
38-
- name: Cache artifacts
39-
uses: actions/cache@v1
40-
env:
41-
cache-name: cache-artifacts
42-
with:
43-
path: ~/.julia/artifacts
44-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
45-
restore-keys: |
46-
${{ runner.os }}-test-${{ env.cache-name }}-
47-
${{ runner.os }}-test-
48-
${{ runner.os }}-
49-
- uses: julia-actions/julia-buildpkg@v1
50-
- uses: julia-actions/julia-runtest@v1
31+
- uses: julia-actions/cache@v1
32+
- name: Test AsciiPixel
33+
run: |
34+
julia --project -e 'using Pkg; Pkg.develop(path="AsciiPixel")'
35+
julia --project -e 'using Pkg; Pkg.test("AsciiPixel")'
36+
- uses: julia-actions/julia-buildpkg@latest
37+
- uses: julia-actions/julia-runtest@latest

.github/workflows/TagBot.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
types:
55
- created
66
workflow_dispatch:
7+
inputs:
8+
lookback:
9+
default: 3
10+
permissions:
11+
contents: write
712
jobs:
813
TagBot:
914
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
@@ -12,4 +17,4 @@ jobs:
1217
- uses: JuliaRegistries/TagBot@v1
1318
with:
1419
token: ${{ secrets.GITHUB_TOKEN }}
15-
ssh: ${{ secrets.TAGBOT }}
20+
ssh: ${{ secrets.DOCUMENTER_KEY }}

.github/workflows/format-check.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: format-check
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'release-'
8+
tags: '*'
9+
pull_request:
10+
11+
jobs:
12+
check:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
julia-version: ['1']
17+
julia-arch: [x64]
18+
os: [ubuntu-latest]
19+
steps:
20+
- uses: julia-actions/setup-julia@latest
21+
with:
22+
version: ${{ matrix.julia-version }}
23+
24+
- uses: actions/checkout@v3
25+
- name: Install JuliaFormatter and format
26+
run: |
27+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
28+
julia -e 'using JuliaFormatter; format(["src", "test"], verbose=true)'
29+
- name: Format check
30+
run: |
31+
julia -e '
32+
out = Cmd(`git diff --name-only`) |> read |> String
33+
if out == ""
34+
exit(0)
35+
else
36+
@error "Some files have not been formatted !!!"
37+
write(stdout, out)
38+
exit(1)
39+
end'

AsciiPixel/Project.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name = "AsciiPixel"
2+
uuid = "d64ea8f1-9d40-4cda-bb88-5de2505cd5c8"
3+
version = "0.1.0"
4+
5+
[deps]
6+
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
7+
ImageBase = "c817782e-172a-44cc-b673-b171935fbb9e"
8+
9+
[compat]
10+
Crayons = "1 - 4"
11+
ImageBase = "0.1"
12+
julia = "1.6"
13+
14+
[extras]
15+
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
16+
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
17+
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
18+
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
19+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
20+
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990"
21+
22+
[targets]
23+
test = ["ImageIO", "ImageTransformations", "OffsetArrays", "ReferenceTests", "Test", "TestImages"]

AsciiPixel/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# AsciiPixel
2+
3+
AsciiPixel is a backend for [ImageInTerminal](https://github.com/JuliaImages/ImageInTerminal.jl).

AsciiPixel/src/AsciiPixel.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module AsciiPixel
2+
3+
using ImageBase
4+
using Crayons
5+
6+
export ascii_display
7+
8+
include("colorant2ansi.jl")
9+
include("ascii.jl")
10+
11+
const colormode = Ref{TermColorDepth}(TermColor8bit())
12+
13+
"""
14+
set_colormode(bit::Int)
15+
16+
Sets the terminal color depth to the given argument.
17+
"""
18+
function set_colormode(bit::Int)
19+
if bit == 8
20+
colormode[] = TermColor8bit()
21+
elseif bit == 24
22+
colormode[] = TermColor24bit()
23+
else
24+
error("Setting color depth to $bit-bit is not supported, valid modes are:
25+
- 8bit (256 colors)
26+
- 24bit")
27+
end
28+
colormode[]
29+
end
30+
31+
is_24bit_supported() = lowercase(get(ENV, "COLORTERM", "")) in ("24bit", "truecolor")
32+
33+
function __init__()
34+
# use 24bit if the terminal supports it
35+
is_24bit_supported() && set_colormode(24)
36+
end
37+
38+
end # module

0 commit comments

Comments
 (0)