Skip to content

Commit 144dc45

Browse files
committed
Ctrl-R support
1 parent 27cfc75 commit 144dc45

File tree

7 files changed

+363
-25
lines changed

7 files changed

+363
-25
lines changed

GenerateBuiltinList.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ function GenerateStrings
2424
process
2525
{
2626
$null = $buffer.Append($comma)
27-
$count++
28-
if (($count % 5) -eq 0)
27+
if ($count -gt 0 -and ($count % 5) -eq 0)
2928
{
3029
# Remove the trailing space
3130
$null = $buffer.Remove($buffer.Length - 1, 1)
3231
$null = $buffer.Append("`n$indent$(' ' * $prefix.Length)")
3332
}
33+
$count++
3434
$null = $buffer.Append('"')
3535
$null = $buffer.Append($Item)
3636
$null = $buffer.Append('"')

PSReadLine/Cmdlets.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class PSConsoleReadlineOptions
1616
public const ConsoleColor DefaultTypeForegroundColor = ConsoleColor.Gray;
1717
public const ConsoleColor DefaultNumberForegroundColor = ConsoleColor.White;
1818
public const ConsoleColor DefaultMemberForegroundColor = ConsoleColor.Gray;
19+
public const ConsoleColor DefaultEmphasisForegroundColor = ConsoleColor.Cyan;
1920

2021
public const string DefaultContinuationPrompt = ">>> ";
2122

@@ -133,6 +134,8 @@ public PSConsoleReadlineOptions()
133134
public ConsoleColor TypeBackgroundColor { get; set; }
134135
public ConsoleColor NumberBackgroundColor { get; set; }
135136
public ConsoleColor MemberBackgroundColor { get; set; }
137+
public ConsoleColor EmphasisForegroundColor { get; set; }
138+
public ConsoleColor EmphasisBackgroundColor { get; set; }
136139

137140
internal void ResetColors()
138141
{
@@ -147,6 +150,7 @@ internal void ResetColors()
147150
TypeForegroundColor = DefaultTypeForegroundColor;
148151
NumberForegroundColor = DefaultNumberForegroundColor;
149152
MemberForegroundColor = DefaultNumberForegroundColor;
153+
EmphasisForegroundColor = DefaultEmphasisForegroundColor;
150154
DefaultTokenBackgroundColor = Console.BackgroundColor;
151155
CommentBackgroundColor = Console.BackgroundColor;
152156
KeywordBackgroundColor = Console.BackgroundColor;
@@ -158,6 +162,7 @@ internal void ResetColors()
158162
TypeBackgroundColor = Console.BackgroundColor;
159163
NumberBackgroundColor = Console.BackgroundColor;
160164
MemberBackgroundColor = Console.BackgroundColor;
165+
EmphasisBackgroundColor = Console.BackgroundColor;
161166
}
162167

163168
internal void SetForegroundColor(TokenClassification tokenKind, ConsoleColor color)
@@ -239,6 +244,22 @@ public ConsoleColor ContinuationPromptBackgroundColor
239244
}
240245
internal ConsoleColor? _continuationPromptBackgroundColor;
241246

247+
[Parameter(ParameterSetName = "OptionsSet")]
248+
public ConsoleColor EmphasisForegroundColor
249+
{
250+
get { return _emphasisForegroundColor.GetValueOrDefault(); }
251+
set { _emphasisForegroundColor = value; }
252+
}
253+
internal ConsoleColor? _emphasisForegroundColor;
254+
255+
[Parameter(ParameterSetName = "OptionsSet")]
256+
public ConsoleColor EmphasisBackgroundColor
257+
{
258+
get { return _emphasisBackgroundColor.GetValueOrDefault(); }
259+
set { _emphasisBackgroundColor = value; }
260+
}
261+
internal ConsoleColor? _emphasisBackgroundColor;
262+
242263
[Parameter(ParameterSetName = "OptionsSet")]
243264
public SwitchParameter HistoryNoDuplicates
244265
{
@@ -391,15 +412,15 @@ public class SetKeyHandlerCommand : PSCmdlet
391412
public string LongDescription { get; set; }
392413

393414
// ValidateSet attribute is generated by the script GenerateBuiltinList
394-
[ValidateSet("AcceptLine", "AddLine", "BackwardChar", "BackwardDeleteChar",
415+
[ValidateSet("Abort", "AcceptLine", "AddLine", "BackwardChar", "BackwardDeleteChar",
395416
"BackwardDeleteLine", "BackwardKillLine", "BackwardWord", "BeginningOfHistory", "BeginningOfLine",
396-
"CancelLine", "Complete", "DeleteChar", "DisableDemoMode", "EmacsBackwardWord",
397-
"EmacsForwardWord", "EnableDemoMode", "EndOfHistory", "EndOfLine", "ExchangePointAndMark",
398-
"ForwardChar", "ForwardDeleteLine", "ForwardWord", "GotoBrace", "HistorySearchBackward",
399-
"HistorySearchForward", "KillBackwardWord", "KillLine", "KillWord", "NextHistory",
400-
"Paste", "PossibleCompletions", "PreviousHistory", "Redo", "RevertLine",
401-
"SetKeyHandler", "SetMark", "TabCompleteNext", "TabCompletePrevious", "Undo",
402-
"Yank", "YankPop")]
417+
"CancelLine", "ClearScreen", "Complete", "DeleteChar", "DisableDemoMode",
418+
"EmacsBackwardWord", "EmacsForwardWord", "EnableDemoMode", "EndOfHistory", "EndOfLine",
419+
"ExchangePointAndMark", "ForwardChar", "ForwardDeleteLine", "ForwardSearchHistory", "ForwardWord",
420+
"GotoBrace", "HistorySearchBackward", "HistorySearchForward", "KillBackwardWord", "KillLine",
421+
"KillWord", "NextHistory", "Paste", "PossibleCompletions", "PreviousHistory",
422+
"Redo", "ReverseSearchHistory", "RevertLine", "SetKeyHandler", "SetMark",
423+
"TabCompleteNext", "TabCompletePrevious", "Undo", "Yank", "YankPop")]
403424
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "Function")]
404425
public string Function { get; set; }
405426

PSReadLine/ConsoleLib.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static class NativeMethods
1919
public const uint MENU_IS_INACTIVE = 0x00; // windows key
2020

2121
public const uint ENABLE_PROCESSED_INPUT = 0x0001;
22+
public const uint ENABLE_LINE_INPUT = 0x0002;
2223

2324
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
2425
public static extern IntPtr GetStdHandle(uint handleId);

PSReadLine/PSReadLineResources.Designer.cs

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PSReadLine/PSReadLineResources.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,13 @@
258258
<data name="GotoBraceDescription" xml:space="preserve">
259259
<value>Go to matching brace</value>
260260
</data>
261+
<data name="AbortDescription" xml:space="preserve">
262+
<value>Abort the current operation, e.g. incremental history search</value>
263+
</data>
264+
<data name="ForwardSearchHistoryDescription" xml:space="preserve">
265+
<value>Search history forward interactively</value>
266+
</data>
267+
<data name="ReverseSearchHistoryDescription" xml:space="preserve">
268+
<value>Search history backwards interactively</value>
269+
</data>
261270
</root>

0 commit comments

Comments
 (0)