Skip to content

Commit

Permalink
対応する括弧を強調表示
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Nov 1, 2015
1 parent ad47680 commit ef6346e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions window.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,37 @@
(decf curx (str-width (fat-string str))))))
(cl-charms/low-level:wmove (window-win window) cury curx))))

(defvar *brackets-overlays* nil)

(defun window-brackets-highlight ()
(mapc #'delete-overlay *brackets-overlays*)
(setq *brackets-overlays* nil)
(let ((highlight-points))
(when (eql #\( (following-char))
(save-excursion
(let ((orig-point (point)))
(when (forward-sexp 1 t)
;(push orig-point highlight-points)
(push (progn (prev-char 1) (point))
highlight-points)))))
(when (eql #\) (preceding-char))
(save-excursion
(let ((orig-point (save-excursion
(prev-char 1)
(point))))
(when (backward-sexp 1 t)
;(push orig-point highlight-points)
(push (point) highlight-points)))))
(let ((attr (make-attr :color :cyan :reverse-p t)))
(dolist (point highlight-points)
(push (make-overlay point
(make-point (point-linum point)
(1+ (point-column point)))
:attr attr)
*brackets-overlays*)))))

(defun window-maybe-update ()
(window-brackets-highlight)
(case (window-redraw-flag *current-window*)
((:one-line)
(window-refresh-modeline *current-window*)
Expand Down

0 comments on commit ef6346e

Please sign in to comment.