109 Commits
Author SHA1 Message Date
Justin Chung e563a2fc15 Migrate PSReadLine to target .NET 8.0 (#5055) 2026-01-20 11:05:10 -08:00
Andy Jordan 7b6f602405 Add accessible screen reader mode
This adds the `EnableScreenReaderMode` command-line switch which
defaults to true if an active screen reader is detected.

In screen reader mode, the existing `ForceRender()` function is replaced
by `RenderForScreenReader()` which uses a differential rendering
approach to minimize extraneous output to the terminal, allowing the use
of screen readers better than ever before.

The differential rendering relies on calculating the common prefix of
the `buffer` and `previousRender` strings. Nearly all necessary changes
are consolidated in the new rendering function.

Features known not to be supported:

* Colors: as this necessitates redrawing to insert color sequences after
  the input is received and the AST parsed.
* Inline predictions: as this by definition changes the suffix and thus
  requires endless redrawing.
* List view predictions: since the render implementation never calls
  into the prediction engine, this is not available either.
* Menu completion: well, it "works" since it's not disabled and does its
  own rendering, but no effort has been made to improve `DrawMenu()`, so
  it's not accessible (and I'm not sure it could be given our current
  constraints).

Features known to be partially supported:

* Text selection: mark and select commands work as intended, but provide
  no visual indication.
* Multiple lines: as in newlines work fine, but there is no continuation
  prompt.
* Visually wrapped lines: editing above a wrapped line redraws all
  subsequent lines and hence is noisy.
* Status prompt based commands: what-is-key, digit-argument, and most
  notably, forward/backward incremental history search all render a
  "status prompt" on the line below the user's input buffer. This _is_
  supported; however, it can be noisy since it necessarily has to render
  the whole buffer when the input buffer changes, including the status
  prompt (and search text). But what it's reading is almost always going
  to be relevant.

Everything else should generally work, even Vi mode, and the tests pass.
That said, this isn't perfect, and moreover the approach specifically
doesn't attempt to enable things from the ground up. There may be
features that are available but turn out not to be accessible (like
`MenuComplete`) and I believe they should be left as-is.

Specifically tested with NVDA on Windows and VoiceOver on macOS within
VS Code's integrated terminal, with shell integration loaded, and Code's
screen reader optimizations enabled.
2025-08-27 17:46:47 -07:00
Dongbo Wang d045b508f4 Choose the inline prediction color based on the environment (#3808) 2023-09-26 15:51:45 -07:00
Maxime Labelle d7b9f82ba0 [vi-mode] Supports the text-object command diw (#2059) 2023-08-14 15:56:46 -07:00
Dan Thompson 4d78ce153d Add the TerminateOrphanedConsoleApps option on Windows to kill orphaned console-attached process that may mess up reading from Console input (#3764) 2023-08-09 10:51:26 -07:00
Dongbo Wang ae08ca6caf Support tooltip rendering in the prediction list view (#3667) 2023-05-02 16:52:19 -07:00
spaette 486388c59f Fix some typos in this repository (#3547) 2023-01-23 14:22:59 -08:00
Steve Lee 6c7ccc933f Change default color for inline prediction to dim (#3493) 2022-11-23 14:54:01 -08:00
Steven Bucher 3bc6561270 Fix to use the default member color for members (#3450) 2022-10-18 16:44:22 -07:00
Dongbo Wang 2ef36fb77c Enable IntelliSense prediction by default (#3351) 2022-06-22 12:15:17 -07:00
Dongbo Wang fd1265e385 Add the prediction ListView and also hook up with the CommandPrediction APIs introduced in PS 7.1 (#1909) 2020-11-03 14:17:37 -08:00
Dongbo Wang 219ffa17c2 Allow MaximumHistoryCount to be set from user's profile (#1869) 2020-10-09 10:42:26 -07:00
Dongbo Wang b33e222642 Rename 'PredictionColor' to 'InlinePredictionColor' (#1860) 2020-10-08 10:16:28 -07:00
Dongbo Wang a6b0e762b6 Use const strings for some often used ANSI control sequences (#1809) 2020-09-14 12:40:25 -07:00
Dongbo Wang b1736f67d9 Update build to use .NET 3.1 for compliance (#1702) 2020-07-26 10:19:36 -07:00
Dongbo Wang 65d332e277 Reset all VT attributes for PromptText if it contains VT sequences (#1544) 2020-05-21 22:48:15 -07:00
Dongbo Wang 9e6c6b9481 Add basic support for inline predictive suggestion (#1496) 2020-05-09 15:44:04 -07:00
theaquamarine fcb2c9dd48 Add a -Chord parameter to Get-PSReadLineKeyHandler (#1298) 2020-03-31 10:11:54 -07:00
Dongbo Wang 8b778c6119 Correct the default foreground/background colors (#1435) 2020-03-30 15:43:22 -07:00
Jason Shirk 599e1784a9 Improve handling of color in prompts (#1180) 2019-11-25 12:59:09 -08:00
Steve Lee 09300c0990 Return error if color property or value is invalid with Set-PSReadLineOption -Colors (#1124) 2019-11-07 22:57:25 -08:00
Dongbo Wang 394bacc1b5 Make the history file mutext name unique across sessions (#1061) 2019-09-23 16:16:35 -07:00
Dongbo Wang 239955c035 Filter sensitive history items and avoid writing them to the history file (#1058) 2019-09-23 13:20:15 -07:00
Jason Shirk d781e3922e Avoid LanguagePrimitives.TryConvertTo (#784)
LanguagePrimitives.TryConvertTo raises (and catches) exceptions on
failed convertions to an enum type like ConsoleColor.

These exceptions were affecting debugging performance of the menu and we
never want exceptions if it's easy to avoid, which in this case it is.
2018-10-23 12:28:56 -07:00
Parker Snell c6dabcf9f9 Add script block vi mode indicator option 2018-09-12 10:23:59 -07:00
Jason Shirk 4be9473e90 Change selection coloring to not use inverse
Adds Selection as a configuration option for colors.

Fix #597
2017-12-01 13:41:21 -08:00
Jason Shirk e33dabb46c Replace -*Color parameters with single parameter
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.
2017-11-26 10:51:41 -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
Jason Shirk 577d1444a0 Use escape for color in Get-PSReadLineOption output 2017-11-16 22:54:59 -08:00
Parker Snell 5b283a947e Implement VT input on Windows (#564)
Fix #158.
2017-11-16 22:22:51 -08:00
Jason Shirk 46eb22fb68 Don't save history if HOME not set 2017-11-12 10:12:25 -08:00
Jason Shirk 3412b1a91b ShowKeyBindings and Get-PSReadlineKeyBinding improvements
Fix #114
2017-11-11 22:55:59 -08:00
Jason Shirk d3e05af42d Make HistoryNoDuplicates true by default
Fix #208
2017-11-07 18:20:11 -08:00
Jason Shirk b303c1dc67 Normalize history save path
Fix #512
2017-11-04 08:30:47 -07:00
Jason Shirk 69d8074f71 Escape escapes in Get-PSReadLineOption output 2017-10-16 15:07:49 -07:00
Jason Shirk fb10c6d9c3 Show tooltips by default in MenuComplete 2017-09-09 15:00:24 -07:00
Jason Shirk a1552f8994 Don't change background on unknown default background 2017-09-04 23:20:52 -07:00
Jason Shirk bff16f4beb Correct resources namespace 2017-09-04 23:20:37 -07:00
Jason Shirk 29951e1b5c Fix for unknown fore/background color on Linux 2017-09-03 19:44:01 -07:00
Oisin Grehan fe5b918883 Ignore case when binding PSReadline keyhandler functions 2017-09-02 22:42:13 -07:00
v-alexjo 1cba31e101 Portable history file settings with XDG support 2017-09-02 22:13:52 -07:00
Andrew Schwartzmeyer c994e145b4 Set DefaultEditMode to Emacs on Linux / OS X 2017-09-02 21:24:07 -07:00
Jason Shirk 245000c3b7 Remove #region 2017-09-02 21:09:40 -07:00
xiaoyinl 6f46b23efe Use HTTPS links for go.microsoft.com
I replace all occurrences of http://go.microsoft.com with https://go.microsoft.com in text files.
2017-09-02 21:03:19 -07:00
Josh Soref ff80a13550 Spelling comments
* spelling: comments in src/Microsoft.PowerShell.PSReadLine
2017-09-02 21:03:11 -07:00
Jason Shirk de5d7bd701 Merge Foreground/Background options
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.
2017-08-14 08:56:22 -07:00
Jason Shirk 138b226ea8 Add basic support for custom colors
Colors can now be customized using RGB (like #RRGGBB) or with escape
sequences.
2017-08-14 08:56:21 -07:00
Jason Shirk ef1bb9be17 Get red prompt working again
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.
2017-08-14 08:56:21 -07:00
Jason Shirk a02554d25d Use expression body property/method 2017-07-31 16:51:25 -07:00
Charu Bassi 166ec54013 User should not be able to set MaxHistoryCount to unsupported value
Validate that MaxHistoryCount lies within the range of 1-int.maxValue.
2016-11-28 17:04:07 -08:00