Skip to content

Commit e2f583d

Browse files
authored
Patch v2.0.1 (#209)
* bump * remved STACKTRACE_PRINTED_ERROR_MSG * fixed logs styling * fixed detailed pbar layout * removed the use of links and added display_text to Link * tests fix and update * docs fix * bump * bump * fmt * removed unused function * CI fix * fixed problem with long file paths in errors * bump * fixed panel text background color issue * fixed tree width * fmt * bump
1 parent be5b125 commit e2f583d

File tree

82 files changed

+338
-306
lines changed

Some content is hidden

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

82 files changed

+338
-306
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Term"
22
uuid = "22787eb5-b846-44ae-b979-8e399b8463ab"
33
authors = ["FedeClaudi <federicoclaudi@protonmail.com> and contributors"]
4-
version = "2.0.1"
4+
version = "2.0.2"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

src/_errors.jl

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ function add_stack_frame!(
220220
source_file = RenderableText(
221221
string(frame.file) * ":$(frame.line)";
222222
style = "underline dim",
223+
width = ctx.func_name_w,
223224
)
224225
_out = func_line / source_file
225226
else

src/link.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import ..Style: apply_style
77
import ..Renderables: RenderableText, AbstractRenderable
88
import ..Renderables
99
import ..Layout: pad
10-
import Term:
11-
get_relative_path, textlen, TERM_THEME, cleantext, excise_link_display_text, remove_ansi
10+
import Term: textlen, TERM_THEME, cleantext, excise_link_display_text, remove_ansi
1211
import Term
1312

1413
export Link

src/logs.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,16 @@ Create string display for a log message value.
182182
function log_value_display end
183183

184184
function log_value_display(x::AbstractArray)
185-
a = highlight(str_trunc(string(x), 100); ignore_ansi = true)
185+
a = highlight(str_trunc(string(x), 1000); ignore_ansi = true)
186186

187187
s = foldl((a, b) -> a * " × " * b, string.(size(x)))
188188
b = highlight("{bold dim}Size: $(s){/bold dim}"; ignore_ansi = true)
189189
return a * "\n" * b
190190
end
191191

192192
log_value_display(x::AbstractDict) =
193-
highlight(str_trunc(string(x), 100); ignore_ansi = true)
194-
log_value_display(x) = highlight(str_trunc(string(x), 100);)
193+
highlight(str_trunc(string(x), 1000); ignore_ansi = true)
194+
log_value_display(x) = highlight(str_trunc(string(x), 1000);)
195195

196196
"""
197197
handle_message(logger::TermLogger, lvl, msg, _mod, group, id, file, line; kwargs...)

src/markdown.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function parse_md(
176176
"{$(theme.md_code)}`{/$(theme.md_code)}"
177177
else
178178
panel = Panel(
179-
syntax;
179+
RenderableText(syntax; style = "on_$(theme.md_codeblock_bg)");
180180
style = "white on_$(theme.md_codeblock_bg)",
181181
box = :SQUARE,
182182
subtitle = length(code.language) > 0 ? code.language : nothing,

src/panels.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ content_as_renderable(
192192
justify::Symbol,
193193
background::Union{String,Nothing},
194194
)::RenderableText =
195-
RenderableText(content, width = width - Δw, background = background, justify = justify)
195+
RenderableText(content; width = width - Δw, background = background, justify = justify)
196196

197197
"""
198198
@@ -225,7 +225,7 @@ function Panel(
225225
Δh = padding.top + padding.bottom
226226

227227
# create content
228-
# @info "panel fit" width height Δw Δh
228+
# @info "panel fit" width height Δw Δh background
229229
content = content_as_renderable(content, width, Δw, justify, background)
230230

231231
# estimate panel size
@@ -282,7 +282,7 @@ function Panel(
282282
content = content_as_renderable(content, width, Δw, justify, background)
283283
height = something(height, content.measure.h + Δh + 2)
284284
panel_measure = Measure(height, width)
285-
# @info "panel nofit" width Δw Δh height panel_measure
285+
# @info "panel nofit" width Δw Δh height panel_measure background content.measure
286286

287287
# if the content is too tall, exclude some lines
288288
if content.measure.h > height - Δh - 2
@@ -292,6 +292,7 @@ function Panel(
292292
style = "dim",
293293
width = content.measure.w,
294294
justify = :center,
295+
background = background,
295296
)
296297

297298
segments = if lines_to_drop < content.measure.h

src/progress.jl

+9-1
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ function foreachprogress(
675675
n = _getn(iter),
676676
transient = true,
677677
parallel = false,
678+
columns_kwargs = Dict(),
678679
kwargs...,
679680
)
680681
task = nothing
@@ -687,9 +688,16 @@ function foreachprogress(
687688
start!(pbar)
688689
task = Threads.@spawn _startrenderloop(pbar)
689690
end
691+
return
690692

691693
# The job tracks the iteration through `iter`
692-
job = addjob!(pbar; N = n, transient, kwargs...)
694+
job = addjob!(
695+
pbar;
696+
N = n,
697+
transient = transient,
698+
columns_kwargs = columns_kwargs,
699+
kwargs...,
700+
)
693701
if parallel
694702
Threads.@threads for elem in iter
695703
f(elem)

src/renderables.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ function RenderableText(
143143
text = apply_style(text)
144144

145145
style = isnothing(style) ? "" : style
146-
background = isnothing(background) ? "" : get_bg_color(background)
147-
style = style * background
146+
# background = isnothing(background) ? "" : get_bg_color(background)
147+
# style = style * background
148148

149149
style_init, style_finish = get_style_codes(MarkupStyle(style))
150150

@@ -168,7 +168,7 @@ function RenderableText(
168168
rt
169169
else
170170
text = join_lines([seg.text for seg in rt.segments])
171-
RenderableText(text; style = style, width = width)
171+
RenderableText(text; style = style, width = width, kwargs...)
172172
end
173173
end
174174

src/trees.jl

+5
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ function Tree(
138138
kwargs...,
139139
)
140140
_TREE_PRINTING_TITLE[] = title
141+
_theme = TERM_THEME[]
142+
TERM_THEME[] = theme
141143

142144
# print tree
143145
guides = guides isa Symbol ? treeguides[guides] : guides
@@ -168,6 +170,9 @@ function Tree(
168170

169171
# turn into a renderable
170172
rt = RenderableText(tree)
173+
174+
# restore theme
175+
TERM_THEME[] = _theme
171176
return Tree(rt.segments, rt.measure)
172177
end
173178

test/08_test_panel.jl

+12-2
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,17 @@ end
321321
end
322322

323323
@testset "\e[34mPanel - background" begin
324+
p = Panel(
325+
RenderableText(
326+
"testste";
327+
style = "white on_red",
328+
background = "on_blue",
329+
width = 25,
330+
);
331+
background = "green",
332+
)
333+
IS_WIN || @compare_to_string p "panel_background_1"
334+
324335
p = Panel(apply_style(
325336
"""
326337
asasd
@@ -331,8 +342,7 @@ ads
331342
"on_blue",
332343
); background = "on_red", fit = true)
333344

334-
@test string(p) ==
335-
"\e[0m\e[22m╭──────────────────────╮\e[22m\e[0m\n\e[22m│\e[22m\e[41m \e[49m\e[41m\e[44m asasd\e[49m\e[41m \e[49m\e[49m\e[41m \e[49m\e[22m│\e[22m\n\e[22m│\e[22m\e[41m \e[49m\e[41m\e[44masdasadas\e[49m\e[41m \e[49m\e[49m\e[41m \e[49m\e[22m│\e[22m\n\e[22m│\e[22m\e[41m \e[49m\e[41m\e[44masdsasdasdsadasdsa\e[49m\e[49m\e[41m \e[49m\e[22m│\e[22m\n\e[22m│\e[22m\e[41m \e[49m\e[41m\e[44mads\e[49m\e[41m \e[49m\e[49m\e[41m \e[49m\e[22m│\e[22m\n\e[22m│\e[22m\e[41m \e[49m\e[41m\e[44m \e[49m\e[41m \e[49m\e[49m\e[41m \e[49m\e[22m│\e[22m\n\e[0m\e[22m╰──────────────────────╯\e[22m\e[0m\e[0m"
345+
IS_WIN || @compare_to_string p "panel_background_2"
336346
end
337347

338348
@testset "\e[34mPANEL - UnicodePlots" begin

test/txtfiles/automatic_repr_showme_1.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
Method definition
1111
┌────────────────────────────────────────────────────────────────────┐
12-
│ function tprint(io::IO, x::AbstractString; highlight = true)  │
13-
│  x = (highlight ? apply_style ∘ highlighter : apply_style)(  │
14-
│ x)  │
15-
│   │
16-
│  x =  │
17-
│  Measure(x).w <= console_width(io) ? x :  │
18-
│  string(RenderableText(string(x), width = console_width  │
19-
│ (io)))  │
20-
│  print(io, x)  │
21-
│ end  │
12+
│ function tprint(io::IO, x::AbstractString; highlight = true)   │
13+
│  x = (highlight ? apply_style ∘ highlighter : apply_style)(  │
14+
│ x)   │
15+
│    │
16+
│  x =   │
17+
│  Measure(x).w <= console_width(io) ? x :   │
18+
│  string(RenderableText(string(x), width = console_width  │
19+
│ (io)))   │
20+
│  print(io, x)   │
21+
│ end   │
2222
└────────────────────────────────────────────────────────────────────┘

test/txtfiles/markdown_3.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ and footnotes {#9aacdb}[1]{/#9aacdb} for your content {#9aacdb}[named]{/#9aacdb}
1515
And, of course, you can show some code too:
1616

1717
┌──────────────────────────────────────────────┐
18-
│ function say_hi(x)  │
19-
│  print("Hellow World")  │
20-
│ end  │
18+
│ function say_hi(x)   │
19+
│  print("Hello World")  │
20+
│ end   │
2121
└──────────────────────────────────── julia ───┘
2222

2323
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2424

2525
You can use "quotes" to highlight a section:
2626

27-
> “Multi-line quotes can be helpful to make a paragram
28-
┃ stand out, so that users
27+
> “Multi-line quotes can be helpful to make a paragraph
28+
┃ stand out, so that users
2929
┃ won't miss it! You can use other inline syntax in
3030
┃ you `quotes` too.”
3131

0 commit comments

Comments
 (0)