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

More Clearing Methods #1570

Open
marss72 opened this issue Jun 18, 2024 · 0 comments
Open

More Clearing Methods #1570

marss72 opened this issue Jun 18, 2024 · 0 comments

Comments

@marss72
Copy link

marss72 commented Jun 18, 2024

Is your feature request related to a problem? Please describe.
Currently, no, but I realized this could become an issue while planning future projects.

What I need: More clearing options, such as clearing the entire line, the whole screen, the end of the screen, and the beginning of the screen.

Describe the solution you'd like
There are three possible ways to implement this. I prefer the third one as it seems cleaner and more implementable.

  1. Enum-based solution: Add a specific enum that would be passed when using AnsiConsole.Clear(enum). It could be named ClearingRange and could have values like EntireScreen, CurrentLine, ToEndOfLine.
  2. Static class solution: Replace the Clear method in AnsiConsole with a Clear static class that has static methods like EntireScreen, CurrentLine, ToEndOfLine. However, this syntax doesn't look nice and is too long.
  3. Markup key solution: Add a specific markup key like [clear line] or [clear:line], [clear:to end of line] (or possibly to eol).

Alternatively, a simpler solution would be to implement a method like AnsiSequences() in AnsiConsole that returns a single read-only instance for a specific console with as many ANSI codes as possible, possibly grouped into subclasses or more methods. It could work like this:

AnsiConsole.AnsiSequences().Clear().Line
// would return `ESC[2K` only if the current terminal supports it, otherwise an empty string

I think the markup solution is the best and clearest. However, it might not make sense to use [clear:line] Some very short line as it could be confusing.

Describe alternatives you've considered
Using ANSI codes as they are, but this might break functionality when not supported. Check AnsiConsole.Profile.Capabilities every time or just once and then, if true, printing the code is too messy and long. It works, but there are much cleaner solutions.

Additional context
This feature might not seem useful, but it would be especially helpful when rendering more complex lines that need to be updated often, without flickering.


Please upvote 👍 this issue if you are interested in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo 🕑
Development

No branches or pull requests

1 participant