Skip to content

Commit ada63b9

Browse files
committed
Add coloring support for Member names
1 parent 99dbbe0 commit ada63b9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

PSReadLine/ReadLine.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public enum TokenClassification
3838
Parameter,
3939
Type,
4040
Number,
41+
Member,
4142
}
4243

4344
public class KeyHandler
@@ -161,6 +162,7 @@ static KeyHandler MakeKeyHandler(Action<ConsoleKeyInfo?, object> action, string
161162
public const ConsoleColor DefaultParameterForegroundColor = ConsoleColor.DarkGray;
162163
public const ConsoleColor DefaultTypeForegroundColor = ConsoleColor.Gray;
163164
public const ConsoleColor DefaultNumberForegroundColor = ConsoleColor.White;
165+
public const ConsoleColor DefaultMemberForegroundColor = ConsoleColor.Gray;
164166

165167
private string _continuationPrompt;
166168
public const string DefaultContinuationPrompt = ">>> ";
@@ -465,7 +467,7 @@ private PSConsoleReadLine()
465467

466468
_buffer = new StringBuilder();
467469

468-
_tokenForegroundColors = new ConsoleColor[(int)TokenClassification.Number + 1];
470+
_tokenForegroundColors = new ConsoleColor[(int)TokenClassification.Member + 1];
469471
_tokenBackgroundColors = new ConsoleColor[_tokenForegroundColors.Length];
470472
ResetColors();
471473

@@ -504,6 +506,7 @@ private void ResetColors()
504506
_tokenForegroundColors[(int)TokenClassification.Parameter] = DefaultParameterForegroundColor;
505507
_tokenForegroundColors[(int)TokenClassification.Type] = DefaultTypeForegroundColor;
506508
_tokenForegroundColors[(int)TokenClassification.Number] = DefaultNumberForegroundColor;
509+
_tokenForegroundColors[(int)TokenClassification.Member] = DefaultMemberForegroundColor;
507510
for (int i = 0; i < _tokenBackgroundColors.Length; i++)
508511
{
509512
_tokenBackgroundColors[i] = DefaultTokenBackgroundColor;
@@ -1668,6 +1671,9 @@ private TokenClassification GetTokenClassification(Token token)
16681671
if ((token.TokenFlags & TokenFlags.TypeName) != 0)
16691672
return TokenClassification.Type;
16701673

1674+
if ((token.TokenFlags & TokenFlags.MemberName) != 0)
1675+
return TokenClassification.Member;
1676+
16711677
return TokenClassification.None;
16721678
}
16731679

0 commit comments

Comments
 (0)