@@ -66,8 +66,16 @@ public enum AddToHistoryOption
6666
6767 public enum PredictionSource
6868 {
69- None ,
70- History ,
69+ None = 1 ,
70+ History = 2 ,
71+ Plugin = 4 ,
72+ HistoryAndPlugin = History | Plugin ,
73+ }
74+
75+ public enum PredictionViewStyle
76+ {
77+ InlineView ,
78+ ListView ,
7179 }
7280
7381 public class PSConsoleReadLineOptions
@@ -85,9 +93,14 @@ public class PSConsoleReadLineOptions
8593 public const ConsoleColor DefaultEmphasisColor = ConsoleColor . Cyan ;
8694 public const ConsoleColor DefaultErrorColor = ConsoleColor . Red ;
8795
88- // Use dark black by default for the suggestion text.
8996 // Find the most suitable color using https://stackoverflow.com/a/33206814
90- public const string DefaultInlinePredictionColor = "\x1b [38;5;238m" ;
97+ // Default prediction color settings:
98+ // - use FG color 'dark black' for the inline-view suggestion text
99+ // - use FG color 'yellow' for the list-view suggestion text
100+ // - use BG color 'dark black' for the selected list-view suggestion text
101+ public const string DefaultInlinePredictionColor = "\x1b [38;5;238m" ;
102+ public const string DefaultListPredictionColor = "\x1b [33m" ;
103+ public const string DefaultListPredictionSelectedColor = "\x1b [48;5;238m" ;
91104
92105 public static EditMode DefaultEditMode = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows )
93106 ? EditMode . Windows
@@ -144,6 +157,8 @@ public class PSConsoleReadLineOptions
144157 /// </summary>
145158 public const PredictionSource DefaultPredictionSource = PredictionSource . None ;
146159
160+ public const PredictionViewStyle DefaultPredictionViewStyle = PredictionViewStyle . InlineView ;
161+
147162 /// <summary>
148163 /// How long in milliseconds should we wait before concluding
149164 /// the input is not an escape sequence?
@@ -171,6 +186,7 @@ public PSConsoleReadLineOptions(string hostName)
171186 HistorySaveStyle = DefaultHistorySaveStyle ;
172187 AnsiEscapeTimeout = DefaultAnsiEscapeTimeout ;
173188 PredictionSource = DefaultPredictionSource ;
189+ PredictionViewStyle = DefaultPredictionViewStyle ;
174190 MaximumHistoryCount = 0 ;
175191
176192 var historyFileName = hostName + "_history.txt" ;
@@ -309,6 +325,7 @@ public object ContinuationPromptColor
309325
310326 public bool HistorySearchCaseSensitive { get ; set ; }
311327 internal StringComparison HistoryStringComparison => HistorySearchCaseSensitive ? StringComparison . Ordinal : StringComparison . OrdinalIgnoreCase ;
328+ internal StringComparer HistoryStringComparer => HistorySearchCaseSensitive ? StringComparer . Ordinal : StringComparer . OrdinalIgnoreCase ;
312329
313330 /// <summary>
314331 /// How are command and insert modes indicated when in vi edit mode?
@@ -331,6 +348,11 @@ public object ContinuationPromptColor
331348 /// </summary>
332349 public PredictionSource PredictionSource { get ; set ; }
333350
351+ /// <summary>
352+ /// Sets the view style for rendering predictive suggestions.
353+ /// </summary>
354+ public PredictionViewStyle PredictionViewStyle { get ; set ; }
355+
334356 /// <summary>
335357 /// How long in milliseconds should we wait before concluding
336358 /// the input is not an escape sequence?
@@ -457,6 +479,18 @@ public object InlinePredictionColor
457479 set => _inlinePredictionColor = VTColorUtils . AsEscapeSequence ( value ) ;
458480 }
459481
482+ public object ListPredictionColor
483+ {
484+ get => _listPredictionColor ;
485+ set => _listPredictionColor = VTColorUtils . AsEscapeSequence ( value ) ;
486+ }
487+
488+ public object ListPredictionSelectedColor
489+ {
490+ get => _listPredictionSelectedColor ;
491+ set => _listPredictionSelectedColor = VTColorUtils . AsEscapeSequence ( value ) ;
492+ }
493+
460494 internal string _defaultTokenColor ;
461495 internal string _commentColor ;
462496 internal string _keywordColor ;
@@ -472,6 +506,8 @@ public object InlinePredictionColor
472506 internal string _errorColor ;
473507 internal string _selectionColor ;
474508 internal string _inlinePredictionColor ;
509+ internal string _listPredictionColor ;
510+ internal string _listPredictionSelectedColor ;
475511
476512 internal void ResetColors ( )
477513 {
@@ -489,7 +525,9 @@ internal void ResetColors()
489525 MemberColor = DefaultNumberColor ;
490526 EmphasisColor = DefaultEmphasisColor ;
491527 ErrorColor = DefaultErrorColor ;
492- InlinePredictionColor = DefaultInlinePredictionColor ;
528+ InlinePredictionColor = DefaultInlinePredictionColor ;
529+ ListPredictionColor = DefaultListPredictionColor ;
530+ ListPredictionSelectedColor = DefaultListPredictionSelectedColor ;
493531
494532 var bg = Console . BackgroundColor ;
495533 if ( fg == VTColorUtils . UnknownColor || bg == VTColorUtils . UnknownColor )
@@ -527,6 +565,8 @@ internal void SetColor(string property, object value)
527565 { "Member" , ( o , v ) => o . MemberColor = v } ,
528566 { "Selection" , ( o , v ) => o . SelectionColor = v } ,
529567 { "InlinePrediction" , ( o , v ) => o . InlinePredictionColor = v } ,
568+ { "ListPrediction" , ( o , v ) => o . ListPredictionColor = v } ,
569+ { "ListPredictionSelected" , ( o , v ) => o . ListPredictionSelectedColor = v } ,
530570 } ;
531571
532572 Interlocked . CompareExchange ( ref ColorSetters , setters , null ) ;
@@ -550,7 +590,9 @@ public class GetPSReadLineOption : PSCmdlet
550590 [ ExcludeFromCodeCoverage ]
551591 protected override void EndProcessing ( )
552592 {
553- WriteObject ( PSConsoleReadLine . GetOptions ( ) ) ;
593+ var options = PSConsoleReadLine . GetOptions ( ) ;
594+ WriteObject ( options ) ;
595+ PSConsoleReadLine . WarnWhenWindowSizeTooSmallForView ( options . PredictionViewStyle , this ) ;
554596 }
555597 }
556598
@@ -741,6 +783,14 @@ public PredictionSource PredictionSource
741783 }
742784 internal PredictionSource ? _predictionSource ;
743785
786+ [ Parameter ]
787+ public PredictionViewStyle PredictionViewStyle
788+ {
789+ get => _predictionViewStyle . GetValueOrDefault ( ) ;
790+ set => _predictionViewStyle = value ;
791+ }
792+ internal PredictionViewStyle ? _predictionViewStyle ;
793+
744794 [ Parameter ]
745795 public Hashtable Colors { get ; set ; }
746796
0 commit comments