|
15 | 15 | using System.Runtime.InteropServices;
|
16 | 16 | using System.Threading;
|
17 | 17 | using Microsoft.PowerShell.PSReadLine;
|
| 18 | +using Microsoft.PowerShell.Internal; |
18 | 19 | using AllowNull = System.Management.Automation.AllowNullAttribute;
|
19 | 20 |
|
20 | 21 | namespace Microsoft.PowerShell
|
@@ -163,6 +164,11 @@ public class PSConsoleReadLineOptions
|
163 | 164 | /// </summary>
|
164 | 165 | public const int DefaultAnsiEscapeTimeout = 100;
|
165 | 166 |
|
| 167 | + /// <summary> |
| 168 | + /// If screen reader support is enabled, which enables safe rendering using ANSI control codes. |
| 169 | + /// </summary> |
| 170 | + public static readonly bool DefaultScreenReader = Accessibility.IsScreenReaderActive(); |
| 171 | + |
166 | 172 | static PSConsoleReadLineOptions()
|
167 | 173 | {
|
168 | 174 | // For inline-view suggestion text, we use the new FG color 'dim white italic' when possible, because it provides
|
@@ -224,6 +230,7 @@ public PSConsoleReadLineOptions(string hostName, bool usingLegacyConsole)
|
224 | 230 | : PredictionSource.HistoryAndPlugin;
|
225 | 231 | PredictionViewStyle = DefaultPredictionViewStyle;
|
226 | 232 | MaximumHistoryCount = 0;
|
| 233 | + ScreenReader = DefaultScreenReader; |
227 | 234 |
|
228 | 235 | var historyFileName = hostName + "_history.txt";
|
229 | 236 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
@@ -533,6 +540,8 @@ public object ListPredictionTooltipColor
|
533 | 540 |
|
534 | 541 | public bool TerminateOrphanedConsoleApps { get; set; }
|
535 | 542 |
|
| 543 | + public bool ScreenReader { get; set; } |
| 544 | + |
536 | 545 | internal string _defaultTokenColor;
|
537 | 546 | internal string _commentColor;
|
538 | 547 | internal string _keywordColor;
|
@@ -847,6 +856,14 @@ public SwitchParameter TerminateOrphanedConsoleApps
|
847 | 856 | }
|
848 | 857 | internal SwitchParameter? _terminateOrphanedConsoleApps;
|
849 | 858 |
|
| 859 | + [Parameter] |
| 860 | + public SwitchParameter ScreenReader |
| 861 | + { |
| 862 | + get => _screenReader.GetValueOrDefault(); |
| 863 | + set => _screenReader = value; |
| 864 | + } |
| 865 | + internal SwitchParameter? _screenReader; |
| 866 | + |
850 | 867 | [ExcludeFromCodeCoverage]
|
851 | 868 | protected override void EndProcessing()
|
852 | 869 | {
|
|
0 commit comments