[Linedit-cvs] CVS update: src/backend.lisp src/terminal-translations.lisp src/terminal.lisp src/terminal_glue.c src/dumb-terminal.lisp src/linedit.asd src/utility-macros.lisp src/dumb-terminal-translations.lisp src/dumb_terminal.c src/generic-backend.lisp
Nikodemus Siivola
nsiivola at common-lisp.net
Sun Oct 19 23:38:24 UTC 2003
Update of /project/linedit/cvsroot/src
In directory common-lisp.net:/tmp/cvs-serv19455
Modified Files:
dumb-terminal.lisp linedit.asd utility-macros.lisp
Added Files:
backend.lisp terminal-translations.lisp terminal.lisp
terminal_glue.c
Removed Files:
dumb-terminal-translations.lisp dumb_terminal.c
generic-backend.lisp
Log Message:
Added more infra for terminfo support. terminfo.lisp still needed
Date: Sun Oct 19 19:38:23 2003
Author: nsiivola
Index: src/dumb-terminal.lisp
diff -u src/dumb-terminal.lisp:1.4 src/dumb-terminal.lisp:1.5
--- src/dumb-terminal.lisp:1.4 Mon Sep 29 10:19:01 2003
+++ src/dumb-terminal.lisp Sun Oct 19 19:38:23 2003
@@ -24,44 +24,11 @@
;;; The simplest Linedit backend, that copes only with single lines
;;; of limited length.
-(defclass dumb-terminal (backend)
- ((translations :initform *dumb-terminal-translations*)))
-
-(uffi:def-function ("linedit_dumb_terminal_columns" c-dumb-terminal-columns)
- ((default :int))
- :returning :int)
-
-(defmethod backend-columns ((backend dumb-terminal))
- (c-dumb-terminal-columns *default-columns*))
+(defclass dumb-terminal (terminal) ())
(defmethod line-length-limit ((backend dumb-terminal))
(backend-columns backend))
-(uffi:def-function ("linedit_dumb_terminal_lines" c-dumb-terminal-lines)
- ((default :int))
- :returning :int)
-
-(defmethod backend-lines ((backend dumb-terminal))
- (c-dumb-terminal-lines *default-lines*))
-
-(uffi:def-function ("linedit_dumb_terminal_init" c-dumb-terminal-init)
- ()
- :returning :int)
-
-(defmethod backend-init ((backend dumb-terminal))
- (assert (not (backend-ready-p backend)))
- (assert (zerop (c-dumb-terminal-init)))
- (setf (backend-ready-p backend) t))
-
-(uffi:def-function ("linedit_dumb_terminal_close" c-dumb-terminal-close)
- ()
- :returning :int)
-
-(defmethod backend-close ((backend dumb-terminal))
- (assert (backend-ready-p backend))
- (assert (zerop (c-dumb-terminal-close)))
- (setf (backend-ready-p backend) nil))
-
(defmethod display ((backend dumb-terminal) prompt line)
(let ((string (line-string line)))
(flet ((write-prompt ()
@@ -76,80 +43,3 @@
(write-prompt)
(write-string (subseq string 0 (line-point line)))
(force-output))))
-
-(defmethod read-chord ((backend dumb-terminal))
- (assert (backend-ready-p backend))
- (flet ((read-open-chord ()
- (do ((chars nil)
- (c #1=(read-char) #1#))
- ((member c '(#\- #\~ #\$)) (nconc (nreverse chars) (list c)))
- (push c chars))))
- (let ((chord
- (acase (read-char)
- (#\Esc
- (cons it (acase (read-char)
- (#\[ (cons
- it
- (let ((char (read-char)))
- (if (digit-char-p char)
- (cons char
- (read-open-chord))
- (list char)))))
- (t (list it)))))
- (t (if (graphic-char-p it)
- it
- (char-code it))))))
- (gethash chord
- (backend-translations backend)
- (if (characterp chord)
- chord
- (list 'untranslated chord))))))
-
-(defmethod beep ((b dumb-terminal))
- (declare (ignore b))
- (and (write-char #\Bell *error-output*)
- (force-output *error-output*)))
-
-(defmethod page ((backend dumb-terminal))
- (write-string "--more--")
- (force-output)
- (let ((q (read-chord backend)))
- (write-char #\Return)
- (not (equal #\q q))))
-
-(defmethod print-in-columns ((backend dumb-terminal) list &key width)
- (terpri)
- (let ((cols (truncate (backend-columns backend) width)))
- (do ((item #1=(pop list) #1#)
- (i 0 (1+ i))
- (line 0))
- ((null item))
- (when (= i cols)
- (terpri)
- (setf i 0)
- (when (= (1+ (incf line)) (backend-lines backend))
- (setf line 0)
- (unless (page backend)
- (return-from print-in-columns nil))))
- (write-string item)
- (loop repeat (- width (length item))
- do (write-char #\Space))))
- (terpri))
-
-(defmethod print-in-lines ((backend dumb-terminal) string)
- (terpri)
- (do ((i 0 (1+ i))
- (lines 0))
- ((= i (length string)))
- (let ((c (schar string i)))
- (when (= lines (backend-lines backend))
- (setf lines 0)
- (unless (page backend)
- (return-from print-in-lines nil)))
- (when (eql #\newline c)
- (incf lines))
- (write-char c)))
- (terpri))
-
-(defmethod newline ((backend dumb-terminal))
- (terpri))
Index: src/linedit.asd
diff -u src/linedit.asd:1.17 src/linedit.asd:1.18
--- src/linedit.asd:1.17 Sun Oct 19 18:49:58 2003
+++ src/linedit.asd Sun Oct 19 19:38:23 2003
@@ -56,25 +56,22 @@
(:file "utility-functions" :depends-on ("packages"))
;; Backend
- (:file "generic-backend" :depends-on ("utility-macros"))
- (:c-source-file "dumb_terminal")
- (:file "dumb-terminal-translations")
+ (:file "backend" :depends-on ("utility-macros"))
+ (:c-source-file "terminal_glue")
+ (:file "terminal-translations")
+ (:file "terminal" :depends-on ("terminal-translations" "backend" "terminal_glue"))
+ (:file "dumb-terminal" :depends-on ("terminal"))
(:file "terminfo")
- (:file "dumb-terminal" :depends-on ("generic-backend" "terminfo"
- "dumb-terminal-translations"
- "dumb_terminal"))
+ (:file "smart-terminal" :depends-on ("terminal" "terminfo"))
+ (:file "dumb-terminal" :depends-on ("terminal"))
+
;; Editor
(:file "pool" :depends-on ("utility-macros"))
(:file "line" :depends-on ("utility-macros"))
(:file "buffer" :depends-on ("utility-macros"))
(:file "command-keys" :depends-on ("packages"))
(:c-source-file "signals")
- (:file "editor" :depends-on ("generic-backend"
- "pool"
- "signals"
- "line"
- "buffer"
- "command-keys"))
+ (:file "editor" :depends-on ("backend" "pool" "signals" "line" "buffer" "command-keys"))
(:file "main" :depends-on ("editor"))
(:file "complete" :depends-on ("utility-macros"))
(:file "command-functions" :depends-on ("editor"))
Index: src/utility-macros.lisp
diff -u src/utility-macros.lisp:1.2 src/utility-macros.lisp:1.3
--- src/utility-macros.lisp:1.2 Sun Sep 28 07:37:43 2003
+++ src/utility-macros.lisp Sun Oct 19 19:38:23 2003
@@ -51,3 +51,12 @@
(find-symbol (symbol-name ,var) ,package)
(when (eq ,state :internal)
, at forms)))))
+
+(defmacro invariant (condition)
+ (with-unique-names (value)
+ `(let ((,value ,condition))
+ (unless ,value
+ (error "BUG: You seem to have found a bug in Linedit. Please report this incident ~
+ along with directions to reproduce and the following message to ~
+ linedit-devel at common-lisp.net: `Invariant ~S violated.'"
+ ',condition)))))
More information about the linedit-cvs
mailing list