There are likely issues introduced by this PR,
but I'm merging for a new Beta so this code gets more testing.
* Introduce PSKeyInfo type alias
* Explicit conversions b/w ConsoleKeyInfo and PSKeyInfo
* Change tests to use actual ConsoleKeyInfo data
* Add fr-FR keyboard layout tests
* Add KeyInfo-ru-RU-windows.json (#839)
All impossible without Shift shortcuts labeled as "Investigate: true"
Alt+Spacebar tracked by windows itself
* Add KeyInfo for Polish (Programmers) layout on Windows and Linux (#870)
On Windows *Alt+Spacebar* is hijacked by Windows
On Linux any *Alt+F1-12* combination was not detected
To make it a bit easier to create themes, the various parameters to
Set-PSReadLineOption to set colors has been replaced with a single
parameter accepting a Hashtable.
The valid keys are:
-- ContinuationPrompt: The color of the continuation prompt.
-- Emphasis: The emphasis color, e.g. the matching text when searching history.
-- Error: The error color, e.g. in the prompt.
-- Default: The default token color.
-- Comment: The comment token color.
-- Keyword: The keyword token color.
-- String: The string token color.
-- Operator: The operator token color.
-- Variable: The variable token color.
-- Command: The command token color.
-- Parameter: The parameter token color.
-- Type: The type token color.
-- Number: The number token color.
-- Member: The member name token color.
I was terribly inconsistent.
This is a breaking change, though unlikely to cause troubles.
The apis are mostly used in PowerShell scripts which is not
case sensitive.
The cmdlet name change is also mostly safe.
At any rate, this is version 2.0 and breaking changes should be OK.
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.
Fix selection to use escape sequence for invert - it doesn't look that
great when there are too many colors, but it will work with any
customization.
Also fix tests to work after previous commit.
With no portable way to scrape, displaying red in the prompt is harder.
To start, there is a new option to specify the end of the prompt text so
you can specify exactly what should turn red.
Many folks won't use this, so there are some smarts added at startup to
analyze the prompt function - if it's "pure", as in, doesn't call any
methods or commands, we call it and infer the invariant part of the
prompt, basically the last non-whitespace character plus the trailing
whitespace.
Script block arguments are now only validated as arguments to specific
cmdlets (which are in a user modifiable whitelist.)
A custom validation handler must now throw an exception to report an error,
returning an object is now ignored.
A sample custom validation handler was added to demonstrate typo correction.
Fixes#162
Sometimes you just don't want a key binding for whatever reason, so now you can remove a binding.
Note that unbound keys won't fall back to what happens in "cooked" editing mode.
In raw editing mode (which is what PSReadline uses), conhost only handles a very small
set of key bindings and those bindings weren't available to PSReadline anyway.
Fixes#154
To support custom validation, for e.g. to allow someone
to reject command lines where arguments are not valid,
you can now specify a custom validation handler script block.
For an unknown reason - SetConsoleMode calls fail when setting certain
modes. One such case is when PowerShell calls SetConsoleMode in it's
implementation of PSHostRawUserInterface.ReadKey.
PowerTab calls this method - and it's possible that other custom
key handlers might want to use that api, so I will reset the console
mode to what it was before calling PSReadline for the duration of
the external code (tab completion or custom handlers) and reset it
when the external code completes.
Fixes#125.
Added options to save history automatically - either at exit or incrementally so that history can be shared across sessions.
Default is current to save incrementally.
Also added an option to not save history - useful for those importing history in their profile.