Comments (12)
I do believe inv() fails on Crayons, or at least isn't the intended behavior:
julia> a = Crayon(; foreground=:white, background=:black)
\e[97;40m
julia> inv(a).bg
Crayons.ANSIColor(0x09, 0x00, 0x00, Crayons.COLORS_16, true)
julia> inv(a).fg
Crayons.ANSIColor(0x09, 0x00, 0x00, Crayons.COLORS_16, true)
julia> a.fg
Crayons.ANSIColor(0x43, 0x00, 0x00, Crayons.COLORS_16, true)
julia> a.bg
Crayons.ANSIColor(0x00, 0x00, 0x00, Crayons.COLORS_16, true)
from terminaluserinterfaces.jl.
The progress bar widget hard codes the background to be black:
I think that’s what is going on here.
from terminaluserinterfaces.jl.
I can confirm that changing my terminal background made a bar appear.
A proposed fix: The bar could have a black color, being replaced by a white as the progress goes on, with the text being bright white if the bar is not behind it and becoming black if the bar starts overlapping it. This should be visible as progress on any combination of terminal settings.
from terminaluserinterfaces.jl.
Can you try the most recent commit?
from terminaluserinterfaces.jl.
I seem to have changed it from using :white
and :black
to hardcoded values a while ago, but I can't remember why:
3e095ff#diff-d4c1b4784a623b4120fc107f6e6e18d0d7fe3149ed1494add012bce57463fa67
Anyway, let me know whether it works. I think this will use whatever :white
and :black
have been defined as by your terminal theme.
from terminaluserinterfaces.jl.
No change. My temporary purple background gets replaced by black as progress is made. I don't believe this was the intent behind the code. I would have expected the entire bar to be drawn, in white and black, not partially in my background purple.
Recording here
from terminaluserinterfaces.jl.
Can you run using Crayons; Crayons.test_system_colors()
?
from terminaluserinterfaces.jl.
I've made a new change (see 72c64dd) where you can pass in the colors as a crayon to the ProgressBar struct. You can change the colors now from the user example code directly.
from terminaluserinterfaces.jl.
Here you go.
from terminaluserinterfaces.jl.
I used a red and green crayon for the bar. This is sufficient to let me make progress, but it was not an expected result.
I was expecting a red bar, slowly filling up with green as progress is being made. Instead, I got a black bar filling up with green. The text started as white, and turned red when the green bar made progress through it. I would suspect inv() not doing the proper job on the crayon and picking the default colors instead.
Would you like a video of what I currently have?
Either way, this solves my problem sufficiently. Thank you.
from terminaluserinterfaces.jl.
You are right, Crayons inverse isn't doing what we expected.
You can create your own progress bar widget btw:
struct ProgressBar
block::Block
ratio::Float64
crayon::Crayon
function ProgressBar(block, ratio, crayon = Crayon(foreground = :white, background = :black))
( ratio < 0 || ratio > 1 ) && error("Got $ratio. ProgressBar ratio must be in [0, 1].")
new(block, ratio, crayon)
end
end
function draw(pg::ProgressBar, rect::Rect, buf::Buffer)
draw(pg.block, rect, buf)
inner_area = inner(pg.block, rect)
center = height(inner_area) ÷ 2 + top(inner_area)
for y in top(inner_area):bottom(inner_area)
for x in left(inner_area):right(inner_area)
if x <= pg.ratio * (right(inner_area) - left(inner_area) + 1)
set(buf, x, y, Crayon(foreground = :red, background = :green))
else
set(buf, x, y, Crayon(foreground = :green, background = :red))
end
end
end
label = "$(round(pg.ratio * 100))%"
middle = Int(round( (width(inner_area) - length(label)) / 2 + left(inner_area) ))
set(buf, middle, center, label, Crayon(foreground = :black, background = :default))
end
And use that instead of the built in one.
from terminaluserinterfaces.jl.
I've added a new ProgressBar that allows for more customization. That should help with this issue.
from terminaluserinterfaces.jl.
Related Issues (15)
- Documentation: how to generate a set of slides HOT 2
- Error in examples HOT 10
- Wrong value for TIOCGWINSZ? HOT 6
- Use ansi block characters to make smoother progressbars HOT 3
- Missing convenience functions HOT 1
- ioctl failed: Inappropriate ioctl for device HOT 8
- TagBot trigger issue HOT 50
- undefined reference in disable_raw_mode() HOT 7
- Extra line in Paragraph HOT 3
- terminal "goes dead" after quitting a TUI application HOT 11
- Initialization fails on windows machine HOT 3
- How do you interpret key values? HOT 2
- Version 0.8.0 incompatible with Julia 1.8 and version 0.3.0 lacks documentation
- FocusLost, ERROR: ArgumentError: invalid JSON HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terminaluserinterfaces.jl.