From 06f63b78702578bdee6655837c7f473e39957582 Mon Sep 17 00:00:00 2001 From: devoreofox <232652342+devoreofox@users.noreply.github.com> Date: Sat, 11 Jul 2026 23:53:18 -0300 Subject: [PATCH] Add comments --- CHANGELOG.md | 5 +++++ Silkstring/Models/ThemeColors.cs | 1 + Silkstring/Services/ChatInterceptor.cs | 2 +- Silkstring/Services/Conditions/BlockInterpreter.cs | 4 +++- Silkstring/UI/Palette.cs | 2 ++ Silkstring/UI/SilkstringHighlighter.cs | 5 +++++ Silkstring/Windows/HelpWindow.cs | 1 + 7 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index daba532..443ba39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v1.6.3.0 - 2026-07-11 +### Added +- Comments: any line that starts with `#` is now a note to yourself. It is left out when the alias runs and shown in its own color (which you can change in the settings), so you can label your aliases or jot down reminders. +- `# meow ♥` + ## v1.6.2.0 - 2026-07-11 ### Added - Blank lines and indentation in the multiline editor are now kept when you save, so you can space out and indent longer aliases to make them easier to read diff --git a/Silkstring/Models/ThemeColors.cs b/Silkstring/Models/ThemeColors.cs index ccd6ae6..031c99a 100644 --- a/Silkstring/Models/ThemeColors.cs +++ b/Silkstring/Models/ThemeColors.cs @@ -17,4 +17,5 @@ public class ThemeColors public Vector4 Flag = new(0.85f, 0.55f, 0.85f, 1.0f); public Vector4 String = new(0.6f, 0.8f, 0.5f, 1.0f); public Vector4 Text = new(0.9f, 0.9f, 0.9f, 1.0f); + public Vector4 Comment = new(0.45f, 0.55f, 0.45f, 1.0f); } diff --git a/Silkstring/Services/ChatInterceptor.cs b/Silkstring/Services/ChatInterceptor.cs index b3a8346..9287a34 100644 --- a/Silkstring/Services/ChatInterceptor.cs +++ b/Silkstring/Services/ChatInterceptor.cs @@ -67,7 +67,7 @@ private void ProcessChatInputDetour(ShellCommandModule* shellCommandModule, Utf8 { var args = ArgumentParser.Parse(inputString[splitString[0].Length..].TrimStart()); var commands = alias.Output - .Where(c => !string.IsNullOrWhiteSpace(c.Command)) + .Where(c => !string.IsNullOrWhiteSpace(c.Command) && !c.Command.TrimStart().StartsWith('#')) .Select(c => c.Command.Trim()) .ToList(); var names = alias.Name.Split('|', StringSplitOptions.RemoveEmptyEntries | diff --git a/Silkstring/Services/Conditions/BlockInterpreter.cs b/Silkstring/Services/Conditions/BlockInterpreter.cs index 74945da..785d70b 100644 --- a/Silkstring/Services/Conditions/BlockInterpreter.cs +++ b/Silkstring/Services/Conditions/BlockInterpreter.cs @@ -12,7 +12,8 @@ internal enum BlockKind EndIf, Set, Wait, - Until + Until, + Comment } internal sealed class BlockInterpreter @@ -22,6 +23,7 @@ internal sealed class BlockInterpreter public static (BlockKind Kind, string Expression) Classify(string line) { + if (line.StartsWith("#")) return (BlockKind.Comment, line); if (line.StartsWith(":if ", StringComparison.OrdinalIgnoreCase)) return (BlockKind.If, line[4..]); if (line.Equals(":else", StringComparison.OrdinalIgnoreCase)) return (BlockKind.Else, ""); if (line.Equals(":endif", StringComparison.OrdinalIgnoreCase)) return (BlockKind.EndIf, ""); diff --git a/Silkstring/UI/Palette.cs b/Silkstring/UI/Palette.cs index 967967d..b3caa4c 100644 --- a/Silkstring/UI/Palette.cs +++ b/Silkstring/UI/Palette.cs @@ -18,6 +18,7 @@ public static class Palette public static Vector4 Success; public static Vector4 LineNumber; public static Vector4 Flag; + public static Vector4 Comment; public static void Apply(ThemeColors t) { @@ -34,5 +35,6 @@ public static void Apply(ThemeColors t) Success = t.Success; LineNumber = t.LineNumber; Flag = t.Flag; + Comment = t.Comment; } } diff --git a/Silkstring/UI/SilkstringHighlighter.cs b/Silkstring/UI/SilkstringHighlighter.cs index 1893626..cfcaf31 100644 --- a/Silkstring/UI/SilkstringHighlighter.cs +++ b/Silkstring/UI/SilkstringHighlighter.cs @@ -77,6 +77,10 @@ public object Colorize(Span line, object? state) else Paint(line, exprStart, text.Length, Error); break; + case BlockKind.Comment: + Paint(line, indent, text.Length, PaletteIndex.Comment); + break; + default: if (body.Length > 1 && body[0] == ':' && char.IsLetter(body[1])) { @@ -162,6 +166,7 @@ public static void ApplyPalette(TextEditor editor) r.SetColor(PaletteIndex.CharLiteral, U32(Palette.Error)); r.SetColor(PaletteIndex.LineNumber, U32(Palette.LineNumber)); r.SetColor(PaletteIndex.Preprocessor, U32(Palette.Flag)); + r.SetColor(PaletteIndex.Comment, U32(Palette.Comment)); } private static uint U32(Vector4 c) => ImGui.ColorConvertFloat4ToU32(c); diff --git a/Silkstring/Windows/HelpWindow.cs b/Silkstring/Windows/HelpWindow.cs index 53081c3..605266f 100644 --- a/Silkstring/Windows/HelpWindow.cs +++ b/Silkstring/Windows/HelpWindow.cs @@ -412,6 +412,7 @@ private void DrawEditorHelp() DrawColorRow(Palette.String, "Quoted text", "\"Jane Doe\"", "A quoted value kept as one piece"); DrawColorRow(Palette.Flag, "Flag", "-unsafe", "An option that changes how a line behaves"); DrawColorRow(Palette.Error, "Problem", ":wait abc", "Something malformed that will not work as written"); + DrawColorRow(Palette.Comment, "Comment", "# my note", "A note to yourself, ignored when the alias runs"); ImGui.EndTable(); } ImGui.Spacing();