Skip to content

Instantly share code, notes, and snippets.

@erdg
Last active November 28, 2021 20:38
Show Gist options
  • Save erdg/9b9499dc53e8dbbf1ef0a7a574318d02 to your computer and use it in GitHub Desktop.
Save erdg/9b9499dc53e8dbbf1ef0a7a574318d02 to your computer and use it in GitHub Desktop.
Rainbow Parens for 'VIP' editor
# 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