Skip to content

Commit df0633e

Browse files
committed
Move eachregion implementation to Base
This is part of the effort to adjust the Base/stdlib split to resolve the type piracy and invalidation headaches. The Base counterpart to this commit is JuliaLang/julia@a5e0eabfdbec.
1 parent cde6dd3 commit df0633e

File tree

4 files changed

+2
-160
lines changed

4 files changed

+2
-160
lines changed

docs/src/internals.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ StyledStrings.Legacy.RENAMED_COLORS
1515
StyledStrings.Legacy.legacy_color
1616
StyledStrings.Legacy.load_env_colors!
1717
StyledStrings.ansi_4bit_color_code
18-
StyledStrings.eachregion
19-
StyledStrings.annotation_events
2018
StyledStrings.face!
2119
StyledStrings.getface
2220
StyledStrings.loadface!

src/StyledStrings.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module StyledStrings
44

5-
using Base: AnnotatedString, AnnotatedChar, AnnotatedIOBuffer, annotations, annotate!, annotatedstring
5+
using Base: AnnotatedString, AnnotatedChar, AnnotatedIOBuffer, annotations, annotate!, annotatedstring, eachregion
66
using Base.ScopedValues: ScopedValue, with, @with
77

88
# While these are imported from Base, we claim them as part of the `StyledStrings` API.
@@ -12,7 +12,6 @@ export @styled_str
1212
public Face, addface!, withfaces, styled, SimpleColor
1313

1414
include("faces.jl")
15-
include("regioniterator.jl")
1615
include("io.jl")
1716
include("styledmarkup.jl")
1817
include("legacy.jl")

src/regioniterator.jl

Lines changed: 0 additions & 107 deletions
This file was deleted.

test/runtests.jl

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using Test
44

55
using StyledStrings: StyledStrings, Legacy, SimpleColor, FACES, Face,
6-
@styled_str, styled, StyledMarkup, eachregion, getface, addface!, loadface!, resetfaces!,
6+
@styled_str, styled, StyledMarkup, getface, addface!, loadface!, resetfaces!,
77
AnnotatedString, AnnotatedChar, AnnotatedIOBuffer, annotations
88
using .StyledMarkup: MalformedStylingMacro
99

@@ -35,54 +35,6 @@ end
3535
# When tested as part of the stdlib, the package prefix can start appearing in show methods.
3636
choppkg(s::String) = chopprefix(s, "StyledStrings.")
3737

38-
@testset "Eachregion" begin
39-
annregions(str::String, annots::Vector{<:Tuple{UnitRange{Int}, Symbol, <:Any}}) =
40-
[(s, Tuple.(a)) for (s, a) in eachregion(AnnotatedString(str, annots))]
41-
# Regions that do/don't extend to the left/right edges
42-
@test annregions(" abc ", [(2:4, :face, :bold)]) ==
43-
[(" ", []),
44-
("abc", [(:face, :bold)]),
45-
(" ", [])]
46-
@test annregions(" x ", [(2:2, :face, :bold)]) ==
47-
[(" ", []),
48-
("x", [(:face, :bold)]),
49-
(" ", [])]
50-
@test annregions(" x", [(2:2, :face, :bold)]) ==
51-
[(" ", []),
52-
("x", [(:face, :bold)])]
53-
@test annregions("x ", [(1:1, :face, :bold)]) ==
54-
[("x", [(:face, :bold)]),
55-
(" ", [])]
56-
@test annregions("x", [(1:1, :face, :bold)]) ==
57-
[("x", [(:face, :bold)])]
58-
# Overlapping/nested regions
59-
@test annregions(" abc ", [(2:4, :face, :bold), (3:3, :face, :italic)]) ==
60-
[(" ", []),
61-
("a", [(:face, :bold)]),
62-
("b", [(:face, :bold), (:face, :italic)]),
63-
("c", [(:face, :bold)]),
64-
(" ", [])]
65-
@test annregions("abc-xyz", [(1:7, :face, :bold), (1:3, :face, :green), (4:4, :face, :yellow), (4:7, :face, :italic)]) ==
66-
[("abc", [(:face, :bold), (:face, :green)]),
67-
("-", [(:face, :bold), (:face, :yellow), (:face, :italic)]),
68-
("xyz", [(:face, :bold), (:face, :italic)])]
69-
# Preserving annotation order
70-
@test annregions("abcd", [(1:3, :face, :red), (2:2, :face, :yellow), (2:3, :face, :green), (2:4, :face, :blue)]) ==
71-
[("a", [(:face, :red)]),
72-
("b", [(:face, :red), (:face, :yellow), (:face, :green), (:face, :blue)]),
73-
("c", [(:face, :red), (:face, :green), (:face, :blue)]),
74-
("d", [(:face, :blue)])]
75-
@test annregions("abcd", [(2:4, :face, :blue), (1:3, :face, :red), (2:3, :face, :green), (2:2, :face, :yellow)]) ==
76-
[("a", [(:face, :red)]),
77-
("b", [(:face, :blue), (:face, :red), (:face, :green), (:face, :yellow)]),
78-
("c", [(:face, :blue), (:face, :red), (:face, :green)]),
79-
("d", [(:face, :blue)])]
80-
# Region starting after a character spanning multiple codepoints.
81-
@test annregions("𝟏x", [(1:4, :face, :red)]) ==
82-
[("𝟏", [(:face, :red)]),
83-
("x", [])]
84-
end
85-
8638
@testset "SimpleColor" begin
8739
@test SimpleColor(:hey).value == :hey # no error
8840
@test SimpleColor(0x01, 0x02, 0x03).value == (r=0x01, g=0x02, b=0x03)

0 commit comments

Comments
 (0)