Skip to content

Conversation

@sholderbach
Copy link
Member

Addresses #28

Succeeds in providing a clear new screen for both the line editing and
reverse search mode.
Solution is conservative and prints more newlines than strictly
necessary as solutions with scrolling didn't seem to work as expected and exactly computing the length of the current written space is not trivial as multiline support is not fully settled yet.

Addresses nushell#28

Succeeds in providing a clear new screen for both the line editing and
reverse search mode.
Solution is conservative and prints more newlines than strictly
necessary as solutions with scrolling didn't seem to work as expected.
stdout.queue(Print("\n"))?;
}
stdout.queue(MoveTo(0, 0))?;
stdout.flush()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

You might be able to run this crossterm command for a clear in one step: https://docs.rs/crossterm/0.19.0/crossterm/terminal/enum.ClearType.html

Copy link
Member Author

Choose a reason for hiding this comment

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

ClearType::All only blanks the currently visible screen, so you cannot scroll back up to the previous output as with bash et al.

Copy link
Contributor

Choose a reason for hiding this comment

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

Today I learned :)

@sholderbach
Copy link
Member Author

With bash or zsh under gnome-terminal the amount of whitespace used by Ctrl-L to separate seems to be inversely proportional to how many lines were already used on the terminal.
image
(zoomed out after the fact)

The clear command at least for me completely annihilates the scrollback buffer.

With my current draft you would have to scroll over one complete page of whitespace to get back to the old stuff.

@sophiajt
Copy link
Contributor

@sholderbach - sounds good. Once we fix the conflict fixed we can land.

@sholderbach
Copy link
Member Author

Merging with the fancy prompt currently has some weird interaction with my requirement to repaint the line_buffer content at the beginning of Engine::read_line to match the Ctrl+L behavior. Will have to take a look into this.

jasonrhansen and others added 2 commits March 18, 2021 16:56
The prompt indicator gets drawn over when searching the history so we
need to restore it when done searching.
Resolves the issues of redrawing the prompt in combination with screen
clearing commands 'clear' and Ctrl+L
@sholderbach
Copy link
Member Author

Combined with the fix from @jasonrhansen pulled from #31 and a slight reordering of my redraw, the prompt remains correct in all known single-line circumstances.
The redraw logic right now seems somewhat convoluted with different functions and might warrant a refactor later.

@sophiajt
Copy link
Contributor

Sounds good. Let's land, then see if we can refactor the prompt parts

@sophiajt sophiajt merged commit 4309299 into nushell:main Mar 19, 2021
@sholderbach sholderbach deleted the clear-screen branch June 10, 2021 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants