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

Properly handle move up zero lines in TerminalMenus. #38630

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

GunnarFarneback
Copy link
Contributor

Cc @timholy

Unfortunately #38489 wasn't quite correct in the case of a one element menu and at least one header line, as can be seen by running

using REPL.TerminalMenus
request(MultiSelectMenu(["1"]))

This was quite mysterious until I realized that the current implementation relies on the corner case that "\x1b[0A" ("move up zero lines") actually moves up one line. In fact the 0 parameter means to use the default value, which for cursor up is one, see https://vt100.net/docs/vt510-rm/chapter4.html, section 4.3.3.

This PR fixes moving up zero lines by conditionally doing nothing and removes a workaround related to this corner case. As an effect a one element menu is now drawn without a dummy empty line below it. This is not a regression from Julia 1.5, where a one element menu was an error.

Additionally I replaced the "\x1b[999D" control code ("move left 999 spaces") with a mundane carriage return. As far as I can tell that's the desired result.

@timholy
Copy link
Sponsor Member

timholy commented Nov 30, 2020

"\x1b[0A" ("move up zero lines") actually moves up one line. In fact the 0 parameter means to use the default value, which for cursor up is one, see https://vt100.net/docs/vt510-rm/chapter4.html, section 4.3.3.

Wow, talk about a non-generic API. Julia has spoiled me.

I replaced the "\x1b[999D" control code ("move left 999 spaces") with a mundane carriage return

That seems safe since now we know that there is at least one line to clear. I imagine the former interface was intending to clear the current line.

@timholy timholy merged commit bc0b9a7 into JuliaLang:master Nov 30, 2020
@GunnarFarneback GunnarFarneback deleted the bugfix_terminalmenus branch December 1, 2020 06:39
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.

None yet

2 participants