Code Monkey home page Code Monkey logo

Comments (7)

shmuelie avatar shmuelie commented on June 4, 2024 1

Works beautifully! Thanks!

from konsole.

goblinfactory avatar goblinfactory commented on June 4, 2024

very good point. I actually have a fix coming for this, since I had the same requirement in one of my own dogfood projects, and have an updated progressBar that can be rendered as either a 1 line progress bar (itemless), or a two line progress bar. I'll update this comment when I've checked in the updates to a new progress-bar branch. That branch has significant breaking backward compatible changes so will be a new package and new version number. I won't close this until it's been implemented.

from konsole.

goblinfactory avatar goblinfactory commented on June 4, 2024

This is a quick peek of the new progress bar, copy of a draft of one of the unit tests (unfinished) from the branch I'm working on. This should work for your scenario. Let me know if it doesn't and I'll see if I can accommodate before I create the package.

Please note that when you use ProgressBar you don't need to pass in an IConsole, that's only for testing. Your usage would simple be var pb = new ProgressBar(max) default is slim, textWidth is optional. IConsole (or Window) is only required if you're rendering the progressBar to a window.

        [Test]
        [TestCase(100,0,   "1234567890 (0  %)          ", "                           ", PbStyle.SingleLine)]
        [TestCase(101,50,  "1234567890 (50 %) ####     ", "                           ", PbStyle.SingleLine)]
        [TestCase(102,100, "1234567890 (100%) #########", "                           ", PbStyle.SingleLine)]
        //[TestCase(103, 0,  "Item     0 of   100. (  0%)", "                           ", PbStyle.DoubeLine)]
        //[TestCase(104, 50, "Item    50 of   100. ( 50%)", "                           ", PbStyle.DoubeLine)]
        //[TestCase(105, 100,"Item   100 of   100. (100%)", "                           ", PbStyle.DoubeLine)]
        public void at_xx_pc_the_progress_bar_should_fill_the_balance_of_the_console_width_pro_ratio(int seq, int i, string line1, string line2, PbStyle style)
        {
            var console = new MockConsole(27,2);
            var pb = new ProgressBar(console, 100, 10);
            // var pb = new ProgressBar(console, 100, 10, style);
            pb.Refresh(i,"1234567890");
            var expected = new string[]
            {
                line1,
                line2
            };
            Console.WriteLine(console.BufferWrittenString);
            CollectionAssert.AreEqual(expected,console.Buffer);
        }

from konsole.

shmuelie avatar shmuelie commented on June 4, 2024

So by setting PbStyle.SingleLine I'll get what I'm looking for?

from konsole.

goblinfactory avatar goblinfactory commented on June 4, 2024

When I publish the updated package ProgressBar will not be backward compatible, i.e. it will be a breaking change. The new PB will default to itemless, and you'll need to pass in PbStyle.DoubeLine to get the old behavior. The new PB will work exactly as you requested.
:)

from konsole.

goblinfactory avatar goblinfactory commented on June 4, 2024

I've published package 3.0.1 which contains the new ProgressBar, it's beta, only because the old two line behaviour is still being finished, tests and a few last minute changes. The new itemless default behaviour won't change, so that's stable. To get the new itemless PB simply run

update-package Konsole

I'll be working on and off Konsole for the next few days as I'm using it quite heavily myself on another project so drop me a line if you have any problems, I can get fixes out quite quickly.

cheers,

Alan

from konsole.

goblinfactory avatar goblinfactory commented on June 4, 2024

(I'll leave this issue open for a while to give you a chance to review, let me know when you're happy and I'll close it. If I don't hear from you in a few days I'll close it, you can always DM me if you have any issues.)

from konsole.

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.