Coder Social home page Coder Social logo

Comments (11)

schollz avatar schollz commented on May 20, 2024

Yeah, a fractional percentage is a great idea. I'll happily take a PR for this

from progressbar.

schollz avatar schollz commented on May 20, 2024

Started it ce5fc5d

from progressbar.

ikonkere avatar ikonkere commented on May 20, 2024

Well, if you don't mind my whole 3 days' familiarity with golang ;) i can surely patch

updateBar := p.state.currentPercent != p.state.lastPercent && p.state.currentPercent > 0
to introduce a forceRender flag that will invalidate the bar every time an Add is performed.

Besides, there's also a related bug: config.maxBytes isn't used anywhere, but checked for during invalidation:

if updateBar || p.config.showIterationsPerSecond || p.config.maxBytes > 0 {

from progressbar.

ikonkere avatar ikonkere commented on May 20, 2024

Oops, you started the PR while i've been typing my comment on how to do it :). After looking into the code, my previous comment is still relevant, updating percent variable type to float won't help in my particular case.

from progressbar.

schollz avatar schollz commented on May 20, 2024

Okay cool! If you'd like, I would love if you submit a patch as a PR. The decimals can come later (it will require fixing a lot of tests). Don't worry that you only have 3 days familiarity with Go :) I will be available to assist or answer any questions or anything else! Please don't hesitate to ask. Welcome to Go!

from progressbar.

ikonkere avatar ikonkere commented on May 20, 2024

Cool, it's quarantine anyway and i've got nothing better to do :). But i mean are you okay with what i'm proposing: forceRender flag exposed through an Option and added to quoted lines 317 or 325?

from progressbar.

schollz avatar schollz commented on May 20, 2024

@ikonkere That seems fine to me! If you want to, you can also make a test that shows your problem so that I don't accidentally introduce something in the future that causes it again :) No worries if you don't want to.

from progressbar.

ikonkere avatar ikonkere commented on May 20, 2024

Ok, made a PR: #55. I actually wanted to totally rework how rendering is done (you can see here if you want https://github.com/ikonkere/progressbar/tree/invalidate), but making async CLI UI components in Go turned out way harder than i expected ;).

from progressbar.

schollz avatar schollz commented on May 20, 2024

Your PR looks good. I'll check it out soon for merge (I think its just fine!).

As for async rendering, I was actually trying to avoid it here. There are reasons you might want to do it, so please fork away (I would add a ticker to yours if I were you to avoid high CPU)! But for this project I'm trying to keep a progressbar that is essentially a state machine, where it only updates once it has some update.

from progressbar.

ikonkere avatar ikonkere commented on May 20, 2024

Yeah, asynch rendering kinda contradicts "simple", so i stashed the change within my fork for now, to think it over, but it's a good, although harsh way to get into a programming language :).

from progressbar.

CompeyDev avatar CompeyDev commented on May 20, 2024

Hey @schollz, it was mentioned that fractional percentages may be a solution:

It is possible to introduce fractional percentage...

Has this been implemented? If yes, how exactly do I utilize this? I am confused because as of now Add() does not accept floats of any kind.

from progressbar.

Related Issues (20)

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.