Skip to content

Commit

Permalink
Slightly less broken paren matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikodemus committed Nov 9, 2003
1 parent c109144 commit 264e05e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion backend.lisp
Expand Up @@ -48,4 +48,4 @@
,@forms)
(backend-init ,backend)))

(defgeneric display (backend prompt line point))
(defgeneric display (backend &key prompt line point &allow-other-keys))
2 changes: 1 addition & 1 deletion dumb-terminal.lisp
Expand Up @@ -26,7 +26,7 @@

(defclass dumb-terminal (terminal) ())

(defmethod display ((backend dumb-terminal) prompt line point)
(defmethod display ((backend dumb-terminal) &key prompt line point &allow-other-keys)
(let* ((string (concat prompt line))
(length (length string))
(point (+ point (length prompt)))
Expand Down
9 changes: 8 additions & 1 deletion editor.lisp
Expand Up @@ -92,8 +92,15 @@

(defvar *debug-info* nil)

(defun redraw-line (editor &key markup)
(display editor
:prompt (editor-prompt editor)
:line (get-string editor)
:point (get-point editor)
:markup markup))

(defun next-chord (editor)
(display editor (editor-prompt editor) (get-string editor) (get-point editor))
(redraw-line editor :markup t)
(forget-yank editor)
(let* ((chord (read-chord editor))
(command (gethash chord (editor-commands editor)
Expand Down
1 change: 1 addition & 0 deletions main.lisp
Expand Up @@ -29,6 +29,7 @@
(loop
(catch 'linedit-loop
(next-chord editor))))
(redraw-line editor)
(get-finished-string editor))))

(defun formedit (&rest args &key (prompt1 "") (prompt2 "")
Expand Down
2 changes: 1 addition & 1 deletion matcher.lisp
Expand Up @@ -43,7 +43,7 @@

(defun find-close-paren (string index)
(loop with count = -1
for n from (1+ index) upto (length string)
for n from (1+ index) below (length string)
do (incf count (paren-count-delta (schar string n)))
when (zerop count) return n))

Expand Down
20 changes: 11 additions & 9 deletions smart-terminal.lisp
Expand Up @@ -37,23 +37,25 @@
(when ti:enter-am-mode
(ti:tputs ti:enter-am-mode)))

(defmethod display ((backend smart-terminal) prompt line point)
(let ((*terminal-io* *standard-output*)
(columns (backend-columns backend))
(line (dwim-mark-parens line point
:pre-mark ti:enter-bold-mode
:post-mark ti:exit-attribute-mode)))
(defmethod display ((backend smart-terminal) &key prompt line point markup)
(let* ((*terminal-io* *standard-output*)
(columns (backend-columns backend))
(marked-line (if markup
(dwim-mark-parens line point
:pre-mark ti:enter-bold-mode
:post-mark ti:exit-attribute-mode)
line)))
(flet ((find-row (n)
;; 1+ includes point in row calculations
(ceiling (1+ n) columns))
(find-col (n)
(rem n columns)))
(let* ((new (concat prompt line))
(let* ((new (concat prompt marked-line))
(old (active-string backend))
(end (length new))
(end (+ (length prompt) (length line))) ;; based on unmarked
(rows (find-row end))
(start (or (mismatch new old) 0))
(start-row (find-row start))
(start-row (find-row start)) ;; markup?
(start-col (find-col start)))
;; Move to start of update and clear to eos
(ti:tputs ti:column-address start-col)
Expand Down

0 comments on commit 264e05e

Please sign in to comment.