Comments (7)
Works beautifully! Thanks!
from konsole.
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.
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.
So by setting PbStyle.SingleLine
I'll get what I'm looking for?
from konsole.
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.
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.
(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)
- Prevent console window resize HOT 16
- ProgressBar does not expose current HOT 8
- IWrite allow StringBuilder type of parameter HOT 9
- SplitRows and SplitColumns without border HOT 1
- Embedded CrLf cause window isolation to break.
- HighSpeed writer to support resize on window size change
- Fix spelling, Boxstyle.Thickness to Thickness.
- Menu not explained in the README. HOT 2
- when splitRows with 3 splits, with even number of parent rows, the last split is not expanding by 1 row
- Konsole.Writer.MoveBufferArea throws System.PlatformNotSupportedException on Nix Platforms HOT 4
- ProgressBar not working on Linux HOT 2
- Does window support chinese character text auto wrap? HOT 4
- Trying to use Konsole for First Time HOT 3
- Ability to close boxes. HOT 9
- Support non "lined" borders (line numbers, blue statusbar, and text header) HOT 1
- Seemingly impossible divide by zero exception thrown HOT 4
- System.ArgumentOutOfRangeException in ProgressBar.Refresh() HOT 16
- How to prevent console from being moved by user? Snap windows feature is changing size of Console. HOT 1
- The simple initialization of ProgressBar is throwing "The handle is invalid." exception in VSCode while debugging. HOT 7
- Add image support HOT 4
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 konsole.