Giter Club home page Giter Club logo

Comments (12)

remy-luisant avatar remy-luisant commented on May 26, 2024 1

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.

kdheepak avatar kdheepak commented on May 26, 2024

The progress bar widget hard codes the background to be black:

crayon = Crayon(foreground = (255, 255, 255), background = (0, 0, 0))

I think that’s what is going on here.

from terminaluserinterfaces.jl.

remy-luisant avatar remy-luisant commented on May 26, 2024

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.

kdheepak avatar kdheepak commented on May 26, 2024

Can you try the most recent commit?

crayon = Crayon(foreground = :white, background = :black)

from terminaluserinterfaces.jl.

kdheepak avatar kdheepak commented on May 26, 2024

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.

remy-luisant avatar remy-luisant commented on May 26, 2024

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.

kdheepak avatar kdheepak commented on May 26, 2024

Can you run using Crayons; Crayons.test_system_colors()?

Screen Shot 2021-06-01 at 1 13 51 PM

from terminaluserinterfaces.jl.

kdheepak avatar kdheepak commented on May 26, 2024

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.

remy-luisant avatar remy-luisant commented on May 26, 2024

Here you go.

crayons

from terminaluserinterfaces.jl.

remy-luisant avatar remy-luisant commented on May 26, 2024

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.

kdheepak avatar kdheepak commented on May 26, 2024

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.

kdheepak avatar kdheepak commented on May 26, 2024

I've added a new ProgressBar that allows for more customization. That should help with this issue.

from terminaluserinterfaces.jl.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.