Last active
November 28, 2021 20:38
-
-
Save erdg/9b9499dc53e8dbbf1ef0a7a574318d02 to your computer and use it in GitHub Desktop.
Rainbow Parens for 'VIP' editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Possibly the most concise implementation ever! | |
# | |
# Parens change color everytime the screen is redrawn, | |
# which happens on almost every key stroke! Totally not | |
# distracting! | |
# | |
# INSTALL - add to '~/.pil/viprc' | |
(de RAINBOW . (31 32 33 34 35 36 91 92 93 94 95 96)) | |
(de random (L) | |
(car (nth L (rand 1 (length L)))) ) | |
(de addLine (Y L N) | |
(cup (+ (: top) Y) 1) | |
(clreol) | |
(for C (nth L (: winX)) | |
(T (lt0 (dec 'N))) | |
(cond | |
((: buffer flat)) | |
((=T (val C)) | |
(ifn (>= "^_" C "^A") | |
(attr NIL T) | |
(setq C (char (+ 64 (char C)))) | |
(attr RED T) ) ) | |
((>= "^_" C "^A") | |
(setq C (char (+ 64 (char C)))) | |
(attr RED) ) | |
((gt0 (val C)) | |
(attr CYAN) ) | |
### CHANGES | |
((member C '("(" ")" "[" "]")) # RAINBOW PARENS!!! | |
(attr (random RAINBOW)) ) | |
### END CHANGES | |
((= C "\"") | |
(attr ULINE) ) | |
(T (attr)) ) | |
(prin C) ) | |
(attr) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment