Closed johnsonjh closed 2 years ago
Not that this isn't a fix for #104 but a workaround for this and other potential issues. I've not fully looked into #104 to see what a proper fix is yet, maybe you'll beat me to it.
Doesn't sound too useful? A quicker workaround for #104 might be Ctrl-C.
That works only if you are still inputting the command, on the command input line. If you have exited without interrupting, such as backspacing out of the command input, the screen remains corrupted then cannot be recovered with ^C
/^L
/^R
.
This patch is more a "fix" that is compatible with my muscle memory, and I think it is closer to the POSIX standard.
The short description from the POSIX-derived man page states that ^L
should behave as follows:
"If in open mode, clear the screen and redisplay the current line. Otherwise, clear and redisplay the screen. Current line is unchanged. Current column is unchanged."
Nvi has no full open mode. Also, Nvi has never actually "cleared the screen" directly, leaving the decision up to curses, however, the standard also doesn't directly specify if the screen should actually be fully repainted (which I think it should, as that is what the clear implies) or just redrawn (as is, even if it was wrong).
Using ^C
in the situation above just prints Interrupted
but doesn't change the screen contents as you can see below:
If that's your muscle memory, then you can simply
map ^R z^M
(See also z
command in man nvi)
z
still doesn't actually fix the screen. I'll attach a video with keystrokes visible.
NOTE: The ^R
at the end does work only because this PR is applied to this build.
Hopefully this is helpful.
z<carriage-return>
is the full form, that's why there is an extra ^M
at the end of the mapping. So when typing, it's z<enter>
rather than z<esc>
.
https://user-images.githubusercontent.com/433009/155870636-c8afb72c-2516-4fa7-b7e1-2f21d7bcdf1b.mp4
I think the only problem is that it will move the current line to the top...
Ah, yes, right you are. But moving the screen is still a problem.
This is something I'd most likely never have noticed outside of the context of #104 ... I'll take a look into that tomorrow, unless you beat me to it, as it's getting late here on the east coast.
But, I see you merged, so thanks very much for the quick response on these. Nvi2 is the most awesome nvi yet.
See issue #104 - adding a new step of "inputting four or five backspaces" to exit the command input leaves the screen in a state where
^L
or^R
will not correct corruption until a reformat (:set nonum|set num
, etc).This is possible in other situations as well.
This ensures the screen is always reformatted and redrawn on
^L
or^R
.