Skip to content

Commit bef1ad1

Browse files
authored
fix for 1.0 (#23)
* fix for 1.0 * fix AV
1 parent 507ef21 commit bef1ad1

8 files changed

+35
-52
lines changed

Project.toml

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name = "Crayons"
22
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
3-
version = "0.5.0"
3+
version = "1.0.0"
44

55
[compat]
6-
julia = "0.7"
6+
julia = "0.7, 1.0"
7+
8+
[extras]
9+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
10+
11+
[targets]
12+
test = ["Test"]

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ print(GREEN_FG(
161161

162162
## Misc
163163

164-
The Base function `print_with_color` is extended so that the first argument can also be a `Crayon`.
165-
166164
The function `inv` on a `Crayon` returns a `Crayon` that undos what the `Crayon` in the argument to `inv` does.
167165
As an example, `inv(Crayon(bold = true))` returns a `Crayon` that disables bold.
168166

REQUIRE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
julia 0.7-
1+
julia 0.7 2.0

appveyor.yml

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1.0
5+
- julia_version: latest
6+
7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
## uncomment the following lines to allow failures on nightly julia
12+
## (tests will run but not make your overall status red)
13+
#matrix:
14+
# allow_failures:
15+
# - julia_version: latest
16+
717
branches:
818
only:
919
- master
@@ -16,18 +26,12 @@ notifications:
1626
on_build_status_changed: false
1727

1828
install:
19-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
20-
# Download most recent Julia Windows binary
21-
- ps: (new-object net.webclient).DownloadFile(
22-
$env:JULIA_URL,
23-
"C:\projects\julia-binary.exe")
24-
# Run installer silently, output to C:\projects\julia
25-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
29+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
2630

2731
build_script:
28-
- C:\projects\julia\bin\julia -e "
29-
import InteractiveUtils; versioninfo();
30-
import Pkg; Pkg.build()"
32+
- echo "%JL_BUILD_SCRIPT%"
33+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3134

3235
test_script:
33-
- C:\projects\julia\bin\julia -e "Pkg.test()"
36+
- echo "%JL_TEST_SCRIPT%"
37+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

src/crayon.jl

+4-18
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ struct Crayon
9393
strikethrough::ANSIStyle
9494
end
9595

96-
anyactive(x::Crayon) = ((x.reset.active && x.reset.on) || x.fg.active || x.bg.active || x.bold.active || x.faint.active ||
97-
x.italics.active || x.underline.active || x.blink.active || x.negative.active || x.conceal.active || x.strikethrough.active)
96+
anyactive(x::Crayon) = ((x.reset.active && x.reset.on) ||
97+
x.fg.active || x.bg.active || x.bold.active ||
98+
x.faint.active || x.italics.active || x.underline.active ||
99+
x.blink.active || x.negative.active || x.conceal.active || x.strikethrough.active)
98100

99101
Base.inv(c::Crayon) = Crayon(inv(c.fg), inv(c.bg), ANSIStyle(), # no point taking inverse of reset,
100102
inv(c.bold), inv(c.faint), inv(c.italics), inv(c.underline),
@@ -270,22 +272,6 @@ function Base.merge(toks::Crayon...)
270272
return tok
271273
end
272274

273-
function Base.with_output_color(f::Function, crayon::Crayon, io::IO, args...)
274-
buf = IOBuffer()
275-
print(buf, crayon)
276-
try f(buf, args...)
277-
finally
278-
print(buf, inv(crayon))
279-
print(io, String(take!(buf)))
280-
end
281-
end
282-
283-
Base.print_with_color(crayon::Crayon, io::IO, msg::AbstractString...) =
284-
Base.with_output_color(print, crayon, io, msg...)
285-
Base.print_with_color(crayon::Crayon, msg::AbstractString...) =
286-
print_with_color(crayon, stdout, msg...)
287-
288-
289275
# 24bit -> 256 colors
290276
function _to256(crayon::Crayon)
291277
fg = crayon.fg

src/crayon_wrapper.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ end
66
function (c::Crayon)(args::Union{CrayonWrapper,AbstractString}...)
77
typefix(cw::CrayonWrapper) = cw
88
typefix(str) = String(str)
9-
9+
1010
CrayonWrapper(c, typefix.(collect(args)))
1111
end
1212

src/macro.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ function _parse_color_string(token::AbstractString)
115115
end
116116

117117
throw(ArgumentError("could not parse $token as a color"))
118-
end
118+
end

test/runtests.jl

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using Crayons
22
using Crayons.Box
3-
4-
if VERSION < v"0.7.0-DEV.2005"
5-
using Base.Test
6-
else
7-
using Test
8-
end
3+
using Test
94

105
withenv("FORCE_COLOR" => true) do
116

@@ -73,7 +68,6 @@ withenv("FORCE_256_COLORS" => true) do
7368
@test string(crayon"(0,0,255)") == string(Crayon(foreground = 21))
7469
@test string(crayon"fg:(0,0,255) bg:(255,0,255)") == string(Crayon(foreground = 21, background = 201))
7570
end
76-
7771

7872
# CrayonStack
7973
cs = CrayonStack()
@@ -126,11 +120,6 @@ pop!(cs) # State change: fg = default
126120

127121
string(BLACK_BG * WHITE_FG * BOLD) == string(Crayon(foreground = :white, background = :black, bold = true))
128122

129-
# print_with_color
130-
io = IOBuffer()
131-
print_with_color(Crayon(foreground = :red), io, "haho")
132-
@test String(take!(io)) == string(Crayon(foreground = :red), "haho", inv(Crayon(foreground = :red)))
133-
134123
# Call overloading
135124
@test string(Crayon()("hello")) == "hello"
136125
@test string(Crayon()(split("hello world")[1])) == "hello" # test substrings

0 commit comments

Comments
 (0)