Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are new line characters "\n" allowed in the Dual Line feature? #188

Open
jakemayfield opened this issue Sep 7, 2022 · 4 comments
Open
Labels
feature request No promises...

Comments

@jakemayfield
Copy link

jakemayfield commented Sep 7, 2022

Hi @rsalmei , thank you for this awesome library!

Referring to #135, are new line characters \n allowed in bar.text? Mine do not seem to be taking and keeps everything showing only on a single line. I've also tried using \r\n, with no success.

My use case is that I output performance stats, with each metric being on its own line, that update in real-time as I'm going through the loop. Since I'm looking at 10+ lines, I do not want to print these lines over and over again as they continuously update throughout the loop. It would be much better to have them display below the progress bars.

Thanks!

@jakemayfield jakemayfield changed the title Are new line characters "\n" allowed in the dual-line feature? Are new line characters "\n" allowed in the Dual Line feature? Sep 7, 2022
@rsalmei
Copy link
Owner

rsalmei commented Sep 7, 2022

Hello @jakemayfield, thanks man!

To guarantee the dual line (or even the default single line) mode works, I have to filter new line characters. So, at the end of a refresh, I know how to return the cursor to the bar, either on the same or on the line above...

Perhaps it would be possible to support something like this, but it seems a very niche feature, because bar.text would have to either always have the exact same number of lines, or I would have to count them every time one changes it, so I can make the cursor return to the initial line. The first is cumbersome and prone to errors, and the second is very tricky to implement because of the race condition that will surely occur with recently changed texts, that haven't been printed on the screen yet. This means I would have to count the lines directly on the hot refresh loop, which would adversely affect performance. Multithreading is complicated.

Can't you use the best of both worlds? You could put on the dual line some real-time data that the user doesn't need a history for, and print the ones that the user could benefit from having the history on screen.

@rsalmei
Copy link
Owner

rsalmei commented Nov 19, 2022

Actually, I think I can make this work!
I've just had this great idea, I'll set new bar texts in a "staging area", i.e. they won't go into the hot refresh loop just yet... By keeping the text I can guarantee I'm clearing the same text I last sent to the screen, and just after that change the buffer, before printing it again! That way I should be able to remove any data races, without penalizing the hot loop!
Let's change the Dual Line feature into a Multi-Line feature! 👍

@rsalmei rsalmei added the feature request No promises... label Nov 19, 2022
@deerandsea
Copy link

May I ask if this feature has been implemented? I tried to enter '\r\n' in dual line mode but failed

@rsalmei
Copy link
Owner

rsalmei commented Jul 28, 2023

Hi @deerandsea, sure you can, but I didn't have the time to work on this yet.

Alive-progress project has started as a fun experience for me, but with the scale it has achieved, I can't work on all the feature requests without any sponsorship. So, I do things when I feel like it, for the sheer pleasure of doing them. And at the moment, my pleasure is in Rust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request No promises...
Projects
None yet
Development

No branches or pull requests

3 participants