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

DietPi-Globals | Tuning processing messages #1365

Merged
merged 4 commits into from
Jan 2, 2018

Conversation

MichaIng
Copy link
Owner

@MichaIng MichaIng commented Jan 1, 2018

Just copying the method of other installation scripts lead to a complicated solution. "\r" is the command to move "cursor" position to beginning of line, thus just adding "\r" at the end of every processing message (leading -n also necessary) does the job.

Now every processing message will be overwritten by any other kind of output. In best cases it should be some ok or error from error handler, but if there are some other command outputs in between this is also okay and shows user what is going on/that something is going on.

If there is information we want users to keep/review, then use G_DIETPI-NOTIFY 2 ... for [Info].

Btw: Don't we want preparation script to use G_DIETPI-NOTIFY 3 ... for the installation step info? At the moment it uses info messages, thus leading [Info] string appears at the beginning of header+separation lines 😆.

+ Simplify/Fix processing messages
@MichaIng MichaIng changed the title DietPi-Globals | Simplify/Fix processing messages [WIP] DietPi-Globals | Simplify/Fix processing messages Jan 1, 2018
@MichaIng
Copy link
Owner Author

MichaIng commented Jan 1, 2018

Okay, I am beginning to understand.

  • \r moved the cursor to the left, but if the new echo string is shorter than the old one, then you have junk left.

  • Thus \033[K (or \e[K works as well in bash) was there to clear the line until the end (from current cursor position).

  • \033[2K clears the whole line, regardless of cursor position, \033[1K from cursor position to beginning of line.

  • So sadly there is no obvious way to tell the next echo, that it should clear possible remains.

  • It also makes sense now, that if a process message breaks over several lines (due to long message or short terminal window), just the last line was cleared.

  • If we could find out the amount of lines, a message takes, we could use \033[1A to move up and clear all of them.

  • So after all we have to think about how to use process messages. I would prefer to just use them inside our G_commands where we have control over the output and can take care, that they get totally overwritten by ok, fail or info messages in between. That is not yet the case everywhere, e.g. G_AGUP, also the question if it is wanted.

+ Assue, that Ok, Error and Info messages clean the whole line of in case prior process messages.
@MichaIng MichaIng changed the title [WIP] DietPi-Globals | Simplify/Fix processing messages DietPi-Globals | Tuning processing messages Jan 1, 2018
+ Also process messages should overwrite prior ones.
@MichaIng MichaIng requested a review from Fourdee January 1, 2018 22:07
@MichaIng MichaIng self-assigned this Jan 1, 2018
@MichaIng MichaIng added this to the v6.0 milestone Jan 1, 2018
@Fourdee
Copy link
Collaborator

Fourdee commented Jan 2, 2018

@MichaIng

Many thanks, looks good 👍

Merged for testing.

Copy link
Collaborator

@Fourdee Fourdee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Fourdee Fourdee merged commit 9e4fa9b into testing Jan 2, 2018
@MichaIng MichaIng deleted the simplify_processing_messages branch January 2, 2018 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants