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
1 change: 0 additions & 1 deletion src/PrettyPrompt/Cancellation/CancellationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Threading;
using PrettyPrompt.Consoles;

Expand Down
1 change: 0 additions & 1 deletion src/PrettyPrompt/Completion/CompletionItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading;
Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Completion/OverloadItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using PrettyPrompt.Highlighting;

Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Completion/SlidingArrayWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using PrettyPrompt.Documents;
Expand Down
1 change: 0 additions & 1 deletion src/PrettyPrompt/Console/AnsiEscapeCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System.Text;
using PrettyPrompt.Highlighting;

namespace PrettyPrompt.Consoles;
Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Console/ConsoleCoordinate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace PrettyPrompt.Consoles;

Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Console/IConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Text;
using PrettyPrompt.Highlighting;
using TextCopy;

Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Console/KeyPress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace PrettyPrompt.Consoles;

Expand Down
1 change: 0 additions & 1 deletion src/PrettyPrompt/Console/KeyPressPattern.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Diagnostics;

namespace PrettyPrompt.Consoles;
Expand Down
1 change: 0 additions & 1 deletion src/PrettyPrompt/Console/KeyPressPatterns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Immutable;

namespace PrettyPrompt.Consoles;
Expand Down
1 change: 0 additions & 1 deletion src/PrettyPrompt/Console/SystemConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Runtime.InteropServices;

namespace PrettyPrompt.Consoles;
Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Documents/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using PrettyPrompt.Panes;
Expand Down
1 change: 0 additions & 1 deletion src/PrettyPrompt/Documents/Grapheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Globalization;

namespace PrettyPrompt.Documents;
Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Documents/ReadOnlyStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System.Text;

namespace PrettyPrompt.Documents;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Documents/StringBuilderWithCaret.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Diagnostics;
using System.Text;

namespace PrettyPrompt.Documents;

Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Documents/TextSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;

namespace PrettyPrompt.Documents;

//Microsoft.CodeAnalysis.Text.TextSpan equivalent.
Expand Down
1 change: 0 additions & 1 deletion src/PrettyPrompt/Documents/UndoRedoHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System.Collections.Generic;
using System.Diagnostics;
using PrettyPrompt.TextSelection;

Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Documents/WordWrapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using PrettyPrompt.Consoles;
using PrettyPrompt.Highlighting;
Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Diagnostics;
using System.Text;
using PrettyPrompt.Documents;
using PrettyPrompt.Highlighting;

Expand Down
33 changes: 22 additions & 11 deletions src/PrettyPrompt/Highlighting/AnsiColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Collections.Frozen;
using System.Globalization;
using System.Linq;
using System.Reflection;
using PrettyPrompt.Consoles;
using static PrettyPrompt.Highlighting.FormattedString.TextElementsEnumerator;

namespace PrettyPrompt.Highlighting;

Expand Down Expand Up @@ -42,11 +38,26 @@ namespace PrettyPrompt.Highlighting;
public static readonly AnsiColor BrightCyan = new("96", "106", nameof(BrightCyan));
public static readonly AnsiColor BrightWhite = new("97", "107", nameof(BrightWhite));

private static readonly Dictionary<string, AnsiColor> ansiColorNames =
typeof(AnsiColor)
.GetFields(BindingFlags.Static | BindingFlags.Public)
.Where(f => f.FieldType == typeof(AnsiColor))
.ToDictionary(f => f.Name, f => (AnsiColor)f.GetValue(null)!, StringComparer.OrdinalIgnoreCase);
private static readonly FrozenDictionary<string, AnsiColor> ansiColorNames =
new Dictionary<string, AnsiColor>(StringComparer.OrdinalIgnoreCase)
{
[nameof(Black)] = Black,
[nameof(Red)] = Red,
[nameof(Green)] = Green,
[nameof(Yellow)] = Yellow,
[nameof(Blue)] = Blue,
[nameof(Magenta)] = Magenta,
[nameof(Cyan)] = Cyan,
[nameof(White)] = White,
[nameof(BrightBlack)] = BrightBlack,
[nameof(BrightRed)] = BrightRed,
[nameof(BrightGreen)] = BrightGreen,
[nameof(BrightYellow)] = BrightYellow,
[nameof(BrightBlue)] = BrightBlue,
[nameof(BrightMagenta)] = BrightMagenta,
[nameof(BrightCyan)] = BrightCyan,
[nameof(BrightWhite)] = BrightWhite,
}.ToFrozenDictionary(StringComparer.OrdinalIgnoreCase);

public static AnsiColor Rgb(byte r, byte g, byte b)
=> new($"38;2;{r};{g};{b}", $"48;2;{r};{g};{b}", $"#{r:X2}{g:X2}{b:X2}");
Expand Down Expand Up @@ -79,7 +90,7 @@ public static bool TryParse(string input, out AnsiColor result)
}

var span = input.AsSpan();
if (input.StartsWith('#') && span.Length == 7 &&
if (span.Length == 7 && span[0] == '#' &&
byte.TryParse(span.Slice(1, 2), NumberStyles.AllowHexSpecifier, null, out byte r) &&
byte.TryParse(span.Slice(3, 2), NumberStyles.AllowHexSpecifier, null, out byte g) &&
byte.TryParse(span.Slice(5, 2), NumberStyles.AllowHexSpecifier, null, out byte b))
Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Highlighting/CellRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using PrettyPrompt.Consoles;
using PrettyPrompt.Documents;
using PrettyPrompt.TextSelection;
Expand Down
1 change: 0 additions & 1 deletion src/PrettyPrompt/Highlighting/FormatSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using PrettyPrompt.Documents;

namespace PrettyPrompt.Highlighting;
Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Highlighting/FormattedString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using PrettyPrompt.Rendering;

Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Highlighting/FormattedStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using PrettyPrompt.Documents;

namespace PrettyPrompt.Highlighting;
Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Highlighting/SyntaxHighlighter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

Expand Down
4 changes: 0 additions & 4 deletions src/PrettyPrompt/History/HistoryLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using PrettyPrompt.Consoles;
Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Panes/CompletionPane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using PrettyPrompt.Completion;
Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Panes/OverloadPane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using PrettyPrompt.Completion;
Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Pools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace PrettyPrompt;
Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Prompt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/PromptCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using PrettyPrompt.Completion;
Expand Down
1 change: 0 additions & 1 deletion src/PrettyPrompt/PromptConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using PrettyPrompt.Highlighting;

namespace PrettyPrompt;
Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Rendering/BoxDrawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using PrettyPrompt.Highlighting;

namespace PrettyPrompt.Rendering;
Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Rendering/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using PrettyPrompt.Highlighting;

namespace PrettyPrompt;
Expand Down
2 changes: 0 additions & 2 deletions src/PrettyPrompt/Rendering/IncrementalRendering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Text;
using PrettyPrompt.Consoles;
using PrettyPrompt.Highlighting;
using static PrettyPrompt.Consoles.AnsiEscapeCodes;
Expand Down
3 changes: 0 additions & 3 deletions src/PrettyPrompt/Rendering/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using PrettyPrompt.Consoles;
using PrettyPrompt.Highlighting;
using PrettyPrompt.Panes;
Expand Down
Loading
Loading