Skip to content

Commit 964b513

Browse files
committed
Add Get-PSReadlineOption cmdlet
1 parent 66bbd55 commit 964b513

File tree

2 files changed

+43
-20
lines changed

2 files changed

+43
-20
lines changed

PSReadLine/Cmdlets.cs

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,28 @@ public PSConsoleReadlineOptions()
132132

133133
internal void ResetColors()
134134
{
135-
CommentForegroundColor = DefaultCommandForegroundColor;
136-
KeywordForegroundColor = DefaultKeywordForegroundColor;
137-
StringForegroundColor = DefaultStringForegroundColor;
138-
OperatorForegroundColor = DefaultOperatorForegroundColor;
139-
VariableForegroundColor = DefaultVariableForegroundColor;
140-
CommandForegroundColor = DefaultCommandForegroundColor;
141-
ParameterForegroundColor = DefaultParameterForegroundColor;
142-
TypeForegroundColor = DefaultTypeForegroundColor;
143-
NumberForegroundColor = DefaultNumberForegroundColor;
144-
MemberForegroundColor = DefaultNumberForegroundColor;
145-
CommentBackgroundColor = Console.BackgroundColor;
146-
KeywordBackgroundColor = Console.BackgroundColor;
147-
StringBackgroundColor = Console.BackgroundColor;
148-
OperatorBackgroundColor = Console.BackgroundColor;
149-
VariableBackgroundColor = Console.BackgroundColor;
150-
CommandBackgroundColor = Console.BackgroundColor;
151-
ParameterBackgroundColor = Console.BackgroundColor;
152-
TypeBackgroundColor = Console.BackgroundColor;
153-
NumberBackgroundColor = Console.BackgroundColor;
154-
MemberBackgroundColor = Console.BackgroundColor;
135+
DefaultTokenForegroundColor = Console.ForegroundColor;
136+
CommentForegroundColor = DefaultCommentForegroundColor;
137+
KeywordForegroundColor = DefaultKeywordForegroundColor;
138+
StringForegroundColor = DefaultStringForegroundColor;
139+
OperatorForegroundColor = DefaultOperatorForegroundColor;
140+
VariableForegroundColor = DefaultVariableForegroundColor;
141+
CommandForegroundColor = DefaultCommandForegroundColor;
142+
ParameterForegroundColor = DefaultParameterForegroundColor;
143+
TypeForegroundColor = DefaultTypeForegroundColor;
144+
NumberForegroundColor = DefaultNumberForegroundColor;
145+
MemberForegroundColor = DefaultNumberForegroundColor;
146+
DefaultTokenBackgroundColor = Console.BackgroundColor;
147+
CommentBackgroundColor = Console.BackgroundColor;
148+
KeywordBackgroundColor = Console.BackgroundColor;
149+
StringBackgroundColor = Console.BackgroundColor;
150+
OperatorBackgroundColor = Console.BackgroundColor;
151+
VariableBackgroundColor = Console.BackgroundColor;
152+
CommandBackgroundColor = Console.BackgroundColor;
153+
ParameterBackgroundColor = Console.BackgroundColor;
154+
TypeBackgroundColor = Console.BackgroundColor;
155+
NumberBackgroundColor = Console.BackgroundColor;
156+
MemberBackgroundColor = Console.BackgroundColor;
155157
}
156158

157159
internal void SetForegroundColor(TokenClassification tokenKind, ConsoleColor color)
@@ -191,6 +193,17 @@ internal void SetBackgroundColor(TokenClassification tokenKind, ConsoleColor col
191193
}
192194
}
193195

196+
[Cmdlet("Get", "PSReadlineOption")]
197+
[OutputType(typeof(PSConsoleReadlineOptions))]
198+
public class GetPSReadlineOption : PSCmdlet
199+
{
200+
[ExcludeFromCodeCoverage]
201+
protected override void EndProcessing()
202+
{
203+
WriteObject(PSConsoleReadLine.GetOptions());
204+
}
205+
}
206+
194207
[Cmdlet("Set", "PSReadlineOption")]
195208
public class SetPSReadlineOption : PSCmdlet
196209
{

PSReadLine/ReadLine.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,16 @@ public static void SetOptions(SetPSReadlineOption options)
23392339
_singleton.SetOptionsInternal(options);
23402340
}
23412341

2342+
/// <summary>
2343+
/// Helper function for the Get-PSReadlineOption cmdlet.
2344+
/// </summary>
2345+
public static PSConsoleReadlineOptions GetOptions()
2346+
{
2347+
// Should we copy? It doesn't matter much, everything can be tweaked from
2348+
// the cmdlet anyway.
2349+
return _singleton._options;
2350+
}
2351+
23422352
/// <summary>
23432353
/// Helper function for the Set-PSReadlineKeyHandler cmdlet.
23442354
/// </summary>

0 commit comments

Comments
 (0)