This fixes some weird issues in WSL and some Linux terminals.
This also works around a Windows 1809 Console bug for the Ctrl+l binding
to clear the screen by using the same escape sequence that bash uses.
Fix#724
Rewrote the custom key binding code to be more portable.
Some runtime checks are necessary because of impossible to reconcile
differences.
Some Win32 P/Invoke calls are still needed due to lack of information in
the ConsoleKeyInfo.
Some keys are currently not available on Linux due to a CLR bug, others
aren't available ever because terminals don't unique character sequences
for a given key press that might differ in just the Shift or Ctrl state.
To get the unit tests passing in VS2015, and to help w/ possible future hosts,
I've moved most of the console api usage to a class, which is then mocked
in the unit tests.
These changes provide a more seemless editing experience when
the command input has multiple lines.
The history recall functions now avoid recalling history if the
input has multiple lines _and_ we aren't in the middle of
recalling history. If you do want to edit a recalled multi-line
line (ugh) then you can first use something like LeftArrow then
UpArrow will work like you would want.
BeginningOfLine/EndOfLine have been changed as well. If you're
already at the start/end of a line, you'll go to the start/end
of the input, otherwise you'll go to the start/end of the line.
Two new functions have been added for moving up/down lines in case
somebody wants to bind those independently of history, but I don't
see those being used much.
Fixes#47
Cmd and bash place the cursor at the end of the last word
instead of one past the end of the word when moving by word.
PSReadline emulated that behavior, but it's inconsistent with
word movement on the rest of the line and it's inconvenient
because you typically need to use the right arrow or end
to edit at the end of the line.
I've removed the emulated behavior, the cursor will now move
to the end of the line.
ShellForwardWord was behaving like *NextWord or *ForwardWord
depending on the edit mode.
Instead, we should have 2 functions so people can bind as they choose
regardless of the edit mode.