saikyun / freja

Self-modifiable editor for coding graphical things
68 stars 3 forks source link

Rainbow highlighting for mutable structures #47

Closed greenfork closed 3 years ago

greenfork commented 3 years ago

I think this highlighting should be different for @{}

image

Either everything is colored or the @ sign is not colored

sogaiu commented 3 years ago

I see the same sort of thing.

I don't know how the coloring works, but agree that one of the two ideas you suggested make more sense than the current arrangement.

sogaiu commented 3 years ago

Ok, here's a patch for not coloring the @, but rather just the delimiters:

diff --git a/freja/rainbow.janet b/freja/rainbow.janet
index 2fb1ab3..4a90769 100644
--- a/freja/rainbow.janet
+++ b/freja/rainbow.janet
@@ -184,7 +184,7 @@
     #          (any :input)
     #          (choice ")"
     #                  (error (constant "missing )"))))
-    (* (cmt (* ($) "@(") ,inc-depth) (any :input) (opt (cmt (* ($) ")") ,dec-depth)))
+    (* (cmt (* "@" ($) "(") ,inc-depth) (any :input) (opt (cmt (* ($) ")") ,dec-depth)))

     #
     :tuple #(sequence "("
@@ -197,7 +197,7 @@
     #                         (any :input)
     #                         (choice "]"
     #                                 (error (constant "missing ]"))))
-    (* (cmt (* ($) "@[") ,inc-depth) (any :input) (opt (cmt (* ($) "]") ,dec-depth)))
+    (* (cmt (* "@" ($) "[") ,inc-depth) (any :input) (opt (cmt (* ($) "]") ,dec-depth)))
     #
     :bracket-tuple #(sequence "["
     #                         (any :input)
@@ -209,7 +209,7 @@
     #          (any :input)
     #          (choice "}"
     #                  (error (constant "missing }"))))
-    (* (cmt (* ($) "@{") ,inc-depth) (any :input) (opt (cmt (* ($) "}") ,dec-depth)))
+    (* (cmt (* "@" ($) "{") ,inc-depth) (any :input) (opt (cmt (* ($) "}") ,dec-depth)))
     #
     :struct #(sequence "{"
     #                  (any :input)

@saikyun How does this look?

saikyun commented 3 years ago

Merged PRs, thanks!