Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions PSReadLine/Cmdlets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public class PSConsoleReadLineOptions
public const string DefaultInlinePredictionColor = "\x1b[97;2;3m";
public const string DefaultListPredictionColor = "\x1b[33m";
public const string DefaultListPredictionSelectedColor = "\x1b[48;5;238m";
public const string DefaultListPredictionTooltipColor = "\x1b[97;2;3m";

public static EditMode DefaultEditMode = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? EditMode.Windows
Expand Down Expand Up @@ -495,6 +496,12 @@ public object ListPredictionSelectedColor
set => _listPredictionSelectedColor = VTColorUtils.AsEscapeSequence(value);
}

public object ListPredictionTooltipColor
{
get => _listPredictionTooltipColor;
set => _listPredictionTooltipColor = VTColorUtils.AsEscapeSequence(value);
}

internal string _defaultTokenColor;
internal string _commentColor;
internal string _keywordColor;
Expand All @@ -512,6 +519,7 @@ public object ListPredictionSelectedColor
internal string _inlinePredictionColor;
internal string _listPredictionColor;
internal string _listPredictionSelectedColor;
internal string _listPredictionTooltipColor;

internal void ResetColors()
{
Expand All @@ -532,6 +540,7 @@ internal void ResetColors()
InlinePredictionColor = DefaultInlinePredictionColor;
ListPredictionColor = DefaultListPredictionColor;
ListPredictionSelectedColor = DefaultListPredictionSelectedColor;
ListPredictionTooltipColor = DefaultListPredictionTooltipColor;

var bg = Console.BackgroundColor;
if (fg == VTColorUtils.UnknownColor || bg == VTColorUtils.UnknownColor)
Expand Down Expand Up @@ -571,6 +580,7 @@ internal void SetColor(string property, object value)
{"InlinePrediction", (o, v) => o.InlinePredictionColor = v},
{"ListPrediction", (o, v) => o.ListPredictionColor = v},
{"ListPredictionSelected", (o, v) => o.ListPredictionSelectedColor = v},
{"ListPredictionTooltip", (o, v) => o.ListPredictionTooltipColor = v},
};

Interlocked.CompareExchange(ref ColorSetters, setters, null);
Expand Down
6 changes: 1 addition & 5 deletions PSReadLine/DynamicHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public partial class PSConsoleReadLine
[ExcludeFromCodeCoverage]
void IPSConsoleReadLineMockableMethods.RenderFullHelp(string content, string regexPatternToScrollTo)
{
_pager ??= new Pager();
_pager.Write(content, regexPatternToScrollTo);
}

Expand Down Expand Up @@ -142,11 +143,6 @@ private void WriteDynamicHelpContent(string commandName, string parameterName, b

private void DynamicHelpImpl(bool isFullHelp)
{
if (isFullHelp)
{
_pager ??= new Pager();
}

int cursor = _singleton._current;
string commandName = null;
string parameterName = null;
Expand Down
3 changes: 3 additions & 0 deletions PSReadLine/KeyBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ void SetDefaultWindowsBindings()
{ Keys.F2, MakeKeyHandler(SwitchPredictionView, "SwitchPredictionView") },
{ Keys.F3, MakeKeyHandler(CharacterSearch, "CharacterSearch") },
{ Keys.ShiftF3, MakeKeyHandler(CharacterSearchBackward, "CharacterSearchBackward") },
{ Keys.F4, MakeKeyHandler(ShowFullPredictionTooltip, "ShowFullPredictionTooltip") },
{ Keys.F8, MakeKeyHandler(HistorySearchBackward, "HistorySearchBackward") },
{ Keys.ShiftF8, MakeKeyHandler(HistorySearchForward, "HistorySearchForward") },
// Added for xtermjs-based terminals that send different key combinations.
Expand Down Expand Up @@ -339,6 +340,7 @@ void SetDefaultEmacsBindings()
{ Keys.AltH, MakeKeyHandler(ShowParameterHelp, "ShowParameterHelp") },
{ Keys.F1, MakeKeyHandler(ShowCommandHelp, "ShowCommandHelp") },
{ Keys.F2, MakeKeyHandler(SwitchPredictionView, "SwitchPredictionView") },
{ Keys.F4, MakeKeyHandler(ShowFullPredictionTooltip, "ShowFullPredictionTooltip") },
{ Keys.AltU, MakeKeyHandler(UpcaseWord, "UpcaseWord") },
{ Keys.AltL, MakeKeyHandler(DowncaseWord, "DowncaseWord") },
{ Keys.AltC, MakeKeyHandler(CapitalizeWord, "CapitalizeWord") },
Expand Down Expand Up @@ -566,6 +568,7 @@ public static KeyHandlerGroup GetDisplayGrouping(string function)
case nameof(NextSuggestion):
case nameof(PreviousSuggestion):
case nameof(SwitchPredictionView):
case nameof(ShowFullPredictionTooltip):
return KeyHandlerGroup.Prediction;

case nameof(CaptureScreen):
Expand Down
2 changes: 2 additions & 0 deletions PSReadLine/KeyBindings.vi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ private void SetDefaultViBindings()
{ Keys.CtrlG, MakeKeyHandler(Abort, "Abort") },
{ Keys.AltH, MakeKeyHandler(ShowParameterHelp, "ShowParameterHelp") },
{ Keys.F1, MakeKeyHandler(ShowCommandHelp, "ShowCommandHelp") },
{ Keys.F2, MakeKeyHandler(SwitchPredictionView, "SwitchPredictionView") },
{ Keys.F4, MakeKeyHandler(ShowFullPredictionTooltip, "ShowFullPredictionTooltip") },
};

// Some bindings are not available on certain platforms
Expand Down
4 changes: 4 additions & 0 deletions PSReadLine/PSReadLine.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ $d = [Microsoft.PowerShell.KeyHandler]::GetGroupingDescription($_.Group)
<Label>ListPredictionSelectedColor</Label>
<ScriptBlock>[Microsoft.PowerShell.VTColorUtils]::FormatColor($_.ListPredictionSelectedColor)</ScriptBlock>
</ListItem>
<ListItem>
<Label>ListPredictionTooltipColor</Label>
<ScriptBlock>[Microsoft.PowerShell.VTColorUtils]::FormatColor($_.ListPredictionTooltipColor)</ScriptBlock>
</ListItem>
<ListItem>
<Label>MemberColor</Label>
<ScriptBlock>[Microsoft.PowerShell.VTColorUtils]::FormatColor($_.MemberColor)</ScriptBlock>
Expand Down
11 changes: 11 additions & 0 deletions PSReadLine/PSReadLineResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions PSReadLine/PSReadLineResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ Or not saving history with:
<data name="SwitchPredictionViewDescription" xml:space="preserve">
<value>Switch between the inline and list prediction views.</value>
</data>
<data name="ShowFullPredictionTooltipDescription" xml:space="preserve">
<value>Show the full tooltip of the selected list-view item in the terminal's alternate screen buffer.</value>
</data>
<data name="WindowSizeTooSmallForListView" xml:space="preserve">
<value>The prediction 'ListView' is temporarily disabled because the current window size of the console is too small. To use the 'ListView', please make sure the 'WindowWidth' is not less than '{0}' and the 'WindowHeight' is not less than '{1}'.</value>
</data>
Expand Down
6 changes: 4 additions & 2 deletions PSReadLine/Prediction.Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,25 @@ private struct SuggestionEntry
internal readonly Guid PredictorId;
internal readonly uint? PredictorSession;
internal readonly string Source;
internal readonly string ToolTip;
internal readonly string SuggestionText;
internal readonly int InputMatchIndex;

private string _listItemTextRegular;
private string _listItemTextSelected;

internal SuggestionEntry(string suggestion, int matchIndex)
: this(source: HistorySource, predictorId: Guid.Empty, predictorSession: null, suggestion, matchIndex)
: this(source: HistorySource, predictorId: Guid.Empty, predictorSession: null, suggestion, tooltip: null, matchIndex)
{
}

internal SuggestionEntry(string source, Guid predictorId, uint? predictorSession, string suggestion, int matchIndex)
internal SuggestionEntry(string source, Guid predictorId, uint? predictorSession, string suggestion, string tooltip, int matchIndex)
{
Source = source;
PredictorId = predictorId;
PredictorSession = predictorSession;
SuggestionText = suggestion;
ToolTip = tooltip;
InputMatchIndex = matchIndex;

_listItemTextRegular = _listItemTextSelected = null;
Expand Down
Loading