[Linedit-cvs] CVS update: src/backend.lisp src/dumb-terminal.lisp src/editor.lisp src/linedit.asd src/smart-terminal.lisp src/terminal.lisp src/terminal_glue.c src/utility-functions.lisp src/version.txt

Nikodemus Siivola nsiivola at common-lisp.net
Thu Oct 23 15:07:10 UTC 2003


Update of /project/linedit/cvsroot/src
In directory common-lisp.net:/tmp/cvs-serv2978

Modified Files:
	backend.lisp dumb-terminal.lisp editor.lisp linedit.asd 
	smart-terminal.lisp terminal.lisp terminal_glue.c 
	utility-functions.lisp version.txt 
Log Message:
* Smarter dumb-terminal: scroll horizontally.
* Added info-string for development time (makes used version and mode visible)
* Nicer interface for DISPLAY
* Robuster smart terminal.

Date: Thu Oct 23 11:07:09 2003
Author: nsiivola

Index: src/backend.lisp
diff -u src/backend.lisp:1.1 src/backend.lisp:1.2
--- src/backend.lisp:1.1	Sun Oct 19 19:38:23 2003
+++ src/backend.lisp	Thu Oct 23 11:07:08 2003
@@ -47,6 +47,3 @@
 	  (backend-close ,backend)
 	  , at forms)
      (backend-init ,backend)))
-
-(defmethod line-length-limit ((backend backend))
-  nil)


Index: src/dumb-terminal.lisp
diff -u src/dumb-terminal.lisp:1.6 src/dumb-terminal.lisp:1.7
--- src/dumb-terminal.lisp:1.6	Mon Oct 20 11:34:03 2003
+++ src/dumb-terminal.lisp	Thu Oct 23 11:07:08 2003
@@ -26,21 +26,20 @@
 
 (defclass dumb-terminal (terminal) ())
 
-(defmethod line-length-limit ((backend dumb-terminal))
-  (backend-columns backend))
-
-(defmethod display ((backend dumb-terminal) prompt line)
-  (let ((string (get-string line)))
-    (flet ((write-prompt ()
-	     (write-char #\Return)
-	     (write-string prompt)))
-      (write-prompt)
-      (write-string string)
-      (loop repeat (- (backend-columns backend)
-		      (length prompt)
-		      (length string))
-	    do (write-char #\Space))
-      (write-prompt)
-      (write-string (subseq string 0 (get-point line)))
-      (force-output))))
-
+(defmethod display ((backend dumb-terminal) prompt line point)
+  (let* ((string (concat prompt line))
+	 (length (length string))
+	 (point (+ point (length prompt)))
+	 (columns (backend-columns backend)))
+    (write-char #\return)
+    (cond ((< (1+ point) columns) 
+	   (write-string (subseq string 0 (min length columns)))
+	   (when (< length columns)
+	     (write-string (make-whitespace (- columns length))))
+	   (write-char #\return)
+	   (write-string (subseq string 0 point)))
+	  (t
+	   (write-string (subseq string (- (1+ point) columns) point))
+	   (write-char #\return)
+	   (write-string (subseq string (- (1+ point) columns) point)))))
+  (force-output))


Index: src/editor.lisp
diff -u src/editor.lisp:1.6 src/editor.lisp:1.7
--- src/editor.lisp:1.6	Mon Oct 20 11:34:03 2003
+++ src/editor.lisp	Thu Oct 23 11:07:08 2003
@@ -21,6 +21,7 @@
 
 (in-package :linedit)
 
+(defvar *version* "0.14.4")
 (defvar *history* nil)
 (defvar *killring* nil)
 
@@ -56,12 +57,17 @@
 (defclass smart-editor (editor smart-terminal) ())
 (defclass dumb-editor (editor dumb-terminal) ())
 
-(defun make-editor (&rest args)
-  (apply 'make-instance
-	 (if (smart-terminal-p)
-	     'smart-editor
-	     'dumb-editor)
-	 args))
+(let ((ann nil))
+  (defun make-editor (&rest args)
+    (let ((type (if (smart-terminal-p)
+		    'smart-editor
+		    'dumb-editor)))
+      (unless ann
+	(format t "~&Linedit version ~A [~A mode]~%" *version* (if (eq 'smart-editor type)
+								   "smart"
+								   "dumb")))
+      (setf ann t)
+      (apply 'make-instance type args))))
 
 ;;; undo
 
@@ -82,7 +88,7 @@
 (defvar *debug-info* nil)
 
 (defun next-chord (editor)
-  (display editor (editor-prompt editor) editor) ; Hmm... ick?
+  (display editor (editor-prompt editor) (get-string editor) (get-point editor))
   (forget-yank editor)
   (let* ((chord (read-chord editor))
 	 (command (gethash chord (editor-commands editor)
@@ -92,14 +98,6 @@
     (setf *debug-info* (list command chord editor))
     (funcall command chord editor))
   (save-state editor))
-
-(defmethod (setf get-string) (string editor)
-  (let ((limit (line-length-limit editor)))
-    (if (and limit (>= (length string) limit))
-	(progn
-	  (beep editor)
-	  (throw 'linedit-loop t))
-	(call-next-method))))
 
 (defun get-finished-string (editor)
   (buffer-push (get-string editor) (editor-history editor))


Index: src/linedit.asd
diff -u src/linedit.asd:1.20 src/linedit.asd:1.21
--- src/linedit.asd:1.20	Mon Oct 20 11:34:03 2003
+++ src/linedit.asd	Thu Oct 23 11:07:08 2003
@@ -48,7 +48,7 @@
     (error 'operation-error :component c :operation o)))
 
 (defsystem :linedit
-    :version "0.14.2"
+    :version "0.14.4"
     :depends-on (:uffi :terminfo)
     :components
   (;; Common


Index: src/smart-terminal.lisp
diff -u src/smart-terminal.lisp:1.3 src/smart-terminal.lisp:1.4
--- src/smart-terminal.lisp:1.3	Mon Oct 20 11:34:03 2003
+++ src/smart-terminal.lisp	Thu Oct 23 11:07:08 2003
@@ -27,10 +27,14 @@
 
 (defun smart-terminal-p ()
   (every (lambda (key)
-	   (ti:capability key))
-	 '(:cursor-up :cursor-down :clr-eos :column-address)))
+	   (ti:capability key)) '(:cursor-up :cursor-down :clr-eos
+				  :column-address :auto-right-margin)))
 
-(defmethod display ((backend smart-terminal) prompt line)
+(defmethod backend-init ((backend smart-terminal))
+  (call-next-method)
+  (ti:tputs ti:enter-am-mode))
+
+(defmethod display ((backend smart-terminal) prompt line point)
   (let ((*terminal-io* *standard-output*)
 	(columns (backend-columns backend)))
     (flet ((find-row (n)
@@ -38,7 +42,7 @@
 	     (ceiling (1+ n) columns))
 	   (find-col (n)
 	     (rem n columns)))
-      (let* ((new (concat prompt (get-string line)))
+      (let* ((new (concat prompt line))
 	     (old (active-string backend))
 	     (end (length new))
 	     (rows (find-row end))
@@ -55,7 +59,7 @@
       (when (and (< start end) (zerop (find-col end)))
 	(ti:tputs ti:cursor-down))
       ;; Place point
-      (let* ((point (+ (length prompt) (get-point line)))
+      (let* ((point (+ (length prompt) point))
 	     (point-row (find-row point))
 	     (point-col (find-col point)))
       (loop repeat (- rows point-row)


Index: src/terminal.lisp
diff -u src/terminal.lisp:1.4 src/terminal.lisp:1.5
--- src/terminal.lisp:1.4	Mon Oct 20 13:49:05 2003
+++ src/terminal.lisp	Thu Oct 23 11:07:08 2003
@@ -56,6 +56,8 @@
   (invariant (zerop (c-terminal-close)))
   (setf (backend-ready-p backend) nil))
 
+;;; FIXME: Use read-char-no-hang to detect pastes, and set an
+;;; apropriate flag, or something.
 (defmethod read-chord ((backend terminal))
   (invariant (backend-ready-p backend))
   (flet ((read-open-chord ()
@@ -96,6 +98,7 @@
     (write-char #\Return)
     (not (equal #\q q))))
 
+;;; FIXME: Explicit line-wrap needed
 (defmethod print-in-columns ((backend terminal) list &key width)
   (let ((max-col (truncate (backend-columns backend) width))
 	(col 0)


Index: src/terminal_glue.c
diff -u src/terminal_glue.c:1.2 src/terminal_glue.c:1.3
--- src/terminal_glue.c:1.2	Mon Oct 20 08:28:56 2003
+++ src/terminal_glue.c	Thu Oct 23 11:07:08 2003
@@ -68,7 +68,7 @@
 
   return linedit_OK;
 }
-  
+
 int
 linedit_terminal_close (void)
 {


Index: src/utility-functions.lisp
diff -u src/utility-functions.lisp:1.2 src/utility-functions.lisp:1.3
--- src/utility-functions.lisp:1.2	Sun Sep 28 07:37:43 2003
+++ src/utility-functions.lisp	Thu Oct 23 11:07:08 2003
@@ -34,3 +34,7 @@
   (declare (string *word-delimiters*)
 	   (character char))
   (find char *word-delimiters*))
+
+(defun make-whitespace (n)
+  (make-string n :initial-element #\space))
+


Index: src/version.txt
diff -u src/version.txt:1.7 src/version.txt:1.8
--- src/version.txt:1.7	Mon Oct 20 11:34:03 2003
+++ src/version.txt	Thu Oct 23 11:07:08 2003
@@ -1 +1 @@
-0.14.2
+0.14.4





More information about the linedit-cvs mailing list