23 Commits
Author SHA1 Message Date
Dongbo Wang 7fb13ea5c8 Add readonly modifier to some private fields (#1984) 2020-11-24 13:40:30 -08:00
Dongbo Wang 9f786b3397 Fix three issues with the menu completion (#1946)
1. Fix menu completion to work with the predictive list view (fix #1935 -- regression introduced in 2.2.0-beta1)
2. Fix menu completion to clear lines properly when the menu top changes on re-drawing (regression introduced in 2.2.0-beta1)
3. Fix how `RightArrow`, `LeftArrow`, `UpArrow`, and `DownArrow` navigate in the menu view (enhancement)
2020-11-13 11:20:51 -08:00
Dustin L. Howett 90422ac2ad Teach PSReadline to not force the background color during render (#1626)
Upcoming versions of the Windows Console will be able to differentiate
a color set by the Win32 API from a color set by VT. This code
transforms a Win32 color into a VT color, and then uses that VT color
during rendering. When an enlightened console host receives this VT, it
may handle it differently (translate it differently, reverse it
differently, store it differently). Use `39;49` for the default foreground/background.

We'll also teach the various console implementations how to
handle it.
2020-07-03 15:59:28 -07:00
Dongbo Wang 7e53c870f8 Update key bindings in sample and doc now that 'Shift' is inferred (#1248) 2019-12-12 13:07:56 -08:00
Jason Shirk 9644382e1c Fix NullReferenceException in OnBreak (#1179)
The Windows event log reports a NullReferenceException in
PlatformWindows.OnBreak.

It's unclear what the repro is (perhaps closing the console before it is
fully initialized) but a fix is simple - adding null checks.
2019-11-14 10:28:38 -08:00
Steve Lee 527fa6abdc Add API to detect if the screen reader is active (#947) 2019-07-19 13:23:35 -07:00
Jason Shirk a7af25aa37 Stop dispatching on ConsoleKeyInfo (#831)
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
2019-03-20 16:14:05 -07:00
Jason Shirk a878b3686c Fix Raster font check (#825)
The original fix in #771 resulted in essentially never setting the UTF8
output encoding because it only tested the fixed width bit on the font
family, but every console font is fixed width.

The proper fix appears to be testing that all 4 lower bits in FontFamily
are not set.

Fix #823
2018-12-03 11:05:07 -08:00
Jason Shirk 52983255fc Disable stdin/stdout check for CI on non-Windows (#804)
Also - only run tests once in AppVeyor.
2018-11-09 10:06:13 -08:00
Jason Shirk bc40ae6f6b Remove uses of CSI # S / ScrollConsoleScreenBuffer (#790)
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
2018-11-04 19:12:52 -08:00
Steve Lee 1d8dd4a21c Fix unintentional font change in Windows console (#771)
conhost (Windows only) could change the font unexpectedly if the current font is a raster font and the code page changes to UTF8.

PSReadLine was switching to UTF8 output encoding to address some display issues with CJK,

This change skips the UTF8 output encoding change if it would cause conhost to change the font.
2018-10-10 09:16:07 -07:00
Jason Shirk f1705e9bb2 Switch from MSTest to xUnit, enable tests in AppVeyor (#600) 2017-12-15 11:59:57 -08:00
Jason Shirk d9e156570a Better handling of VT emulation of ESC [ x ; y m (#611)
Also correctly handle partially invalid sequences by ignoring the whole sequence.

Fix #605
2017-12-15 11:09:42 -08:00
Jason Shirk 8bc665daed Add support for pre-Win10
Introduced a very minimal terminal emulator, enough to support the
colors used by default (ConsoleColor).

There could be some more error checking or just somehow ignoring unknown
escapes, but we'll see if this is sufficient for now.

Fix #596
2017-12-02 12:02:51 -08:00
Jason Shirk 22d8d66951 Ensure ENABLE_VIRTUAL_TERMINAL_PROCESSING is set
Windows PowerShell on Win10 before Fall Creators update would fail to
keep ENABLE_VIRTUAL_TERMINAL_PROCESSING set after running other
executables.

This change ensures that it is always.

The change can be removed when Fall Creators Update or later is
required.

Fix #582
2017-11-26 11:12:33 -08:00
Jason Shirk 46d232c22a s/PSReadline/PSReadLine/g
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.
2017-11-25 21:59:55 -08:00
Parker Snell f9773a09f5 Fix Windows console API detection (#593)
Added an input/output argument like IsHandleRedirected. There are four cases for console APIs:

    Input is not redirected; input APIs are usable.
    Output is not redirected; output APIs are usable.
    At least one of input or output is not redirected; things like SetConsoleTitle are usable.
    Both streams are redirected; we can't use any console APIs.

It's only used for the first scenario right now, but for completeness, the other cases are also handled.
2017-11-25 14:39:42 -08:00
Jason Shirk dc43386f1a No CursorSize api when stdin||stdout is redirected
Maybe not the right fix, but unblocks generating the about topic.

Fix #591
2017-11-24 22:09:31 -08:00
Parker Snell 5b283a947e Implement VT input on Windows (#564)
Fix #158.
2017-11-16 22:22:51 -08:00
Jason Shirk 98cf8fcb23 Allow CaptureScreen to be used w/o a key binding
Fix #419
2017-11-04 11:07:18 -07:00
Jason Shirk 63d2dcf6da Portable custom key bindings
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.
2017-10-15 22:03:56 -07:00
Josh Soref ff80a13550 Spelling comments
* spelling: comments in src/Microsoft.PowerShell.PSReadLine
2017-09-02 21:03:11 -07:00
Jason Shirk 1d009a324e More Windows refactoring
Isolate some odds and ends of Windows specific code so the mainline code
path is not Windows specific.
2017-09-02 16:26:39 -07:00