0.17.4: allow setting highlight color
authorNikodemus Siivola <nikodemus@random-state.net>
Tue, 3 May 2011 12:52:10 +0000 (15:52 +0300)
committerNikodemus Siivola <nikodemus@random-state.net>
Tue, 3 May 2011 12:52:10 +0000 (15:52 +0300)
backend.lisp
linedit.asd
packages.lisp
smart-terminal.lisp

index aa07f6f..198289a 100644 (file)
 
 (defparameter *default-columns* 80)
 (defparameter *default-lines* 24)
+(defparameter *highlight-color* :green
+  "Color to use for highlighting parentheses. NIL is the current foreground
+color bolded, other options are :BLACK, :RED, :GREEN, :YELLOW, :BLUE,
+:MAGENTA, :CYAN, and :WHITE.")
 
 (defclass backend ()
   ((ready-p :accessor backend-ready-p :initform nil)
index 8589584..c1f4e6e 100644 (file)
@@ -59,7 +59,7 @@
     (error 'operation-error :component c :operation o)))
 
 (defsystem :linedit
-    :version "0.17.3"
+    :version "0.17.4"
     :description "Readline-style library."
     :licence "MIT"
     :author "Nikodemus Siivola <nikodemus@sb-studio.net>"
index 91764e6..7d782e0 100644 (file)
@@ -28,6 +28,7 @@
    #:formedit
    #:*default-columns*
    #:*default-lines*
+   #:*highlight-color*
    #:install-repl
    #:uninstall-repl
    #:start-debug
index e219626..f30d937 100644 (file)
   (loop repeat up do (ti:tputs ti:cursor-up))
   (ti:tputs ti:column-address col))
 
+(defun paren-style ()
+  (concat
+   (when *highlight-color*
+     (ti:tparm
+      ti:set-a-foreground
+      (or (position *highlight-color* '(:black :red :green :yellow :blue :magenta :cyan :white))
+          (error "Unknown color: ~S" *highlight-color*))))
+   ti:enter-bold-mode))
+
 (defmethod display ((backend smart-terminal) &key prompt line point markup)
   (let* (;; SBCL and CMUCL traditionally point *terminal-io* to /dev/tty,
          ;; and we do output on it assuming it goes to STDOUT. Binding
            old-row 1))
     (multiple-value-bind (marked-line markup)
        (if markup
-           (dwim-mark-parens line point 
-                             :pre-mark ti:enter-bold-mode
+           (dwim-mark-parens line point
+                             :pre-mark (paren-style)
                              :post-mark ti:exit-attribute-mode)
            (values line point))
        (let* ((full (concat prompt marked-line))