[climacs-cvs] CVS update: climacs/climacs.asd climacs/html-syntax.lisp climacs/packages.lisp

Robert Strandh rstrandh at common-lisp.net
Mon Mar 7 06:51:06 UTC 2005


Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv4561

Modified Files:
	climacs.asd html-syntax.lisp packages.lisp 
Log Message:
First attempt at a display function (for html syntax) that uses the
output of an incremental lexer and parser.  This code is not complete
yet:

  * right now, it uses only the lexer output, and not the parser

  * the cursor is not displayed yet

  * it is too slow, most likely because the output records are all in
    one big bag, as opposed to being tree structured, such as the
    lines of basic syntax.  

The slowness is not a serious problem, because one day, McCLIM will
have tree-structured output records itself, and because most syntax
modules (including this one, very soon) will have some tree structure
itself.  It might be worthwhile to display the part of the buffer
beyond a parse error in some artificially structured way, such as by
lines as in the current basic syntax.


Date: Mon Mar  7 07:51:03 2005
Author: rstrandh

Index: climacs/climacs.asd
diff -u climacs/climacs.asd:1.21 climacs/climacs.asd:1.22
--- climacs/climacs.asd:1.21	Tue Mar  1 05:56:06 2005
+++ climacs/climacs.asd	Mon Mar  7 07:51:02 2005
@@ -55,12 +55,12 @@
    "abbrev"
    "syntax"
    "text-syntax"
-   "html-syntax"
    "cl-syntax"
    "kill-ring"
    "undo"
    "delegating-buffer"
    "pane"
+   "html-syntax"
    "gui"
    ;;---- optional ----
    "testing/rt"


Index: climacs/html-syntax.lisp
diff -u climacs/html-syntax.lisp:1.6 climacs/html-syntax.lisp:1.7
--- climacs/html-syntax.lisp:1.6	Sat Mar  5 08:03:53 2005
+++ climacs/html-syntax.lisp	Mon Mar  7 07:51:02 2005
@@ -287,5 +287,52 @@
 ;;;
 ;;; display
 
+(defun handle-whitespace (pane buffer start end)
+  (let ((space-width (space-width pane))
+	(tab-width (tab-width pane)))
+    (loop while (< start end)
+	  do (ecase (buffer-object buffer start)
+	       (#\Newline (terpri pane))
+	       (#\Space (stream-increment-cursor-position
+			 pane space-width 0))
+	       (#\Tab (let ((x (stream-cursor-position pane)))
+			(stream-increment-cursor-position
+			 pane (- tab-width (mod x tab-width)) 0))))
+	     (incf start))))		    
 
-
+(defmethod redisplay-pane-with-syntax ((pane climacs-pane) (syntax html-syntax) current-p)
+  (with-slots (top bot) pane
+     (with-slots (tokens) syntax
+	(let ((average-token-size (max (float (/ (size (buffer pane)) (nb-elements tokens)))
+				       1.0)))
+	  ;; find the last token before bot
+	  (let ((end-token-index (max (floor (/ (offset bot) average-token-size)) 1)))
+	    ;; go back to a token before bot
+	    (loop until (mark<= (end-offset (element* tokens (1- end-token-index))) bot)
+		  do (decf end-token-index))
+	    ;; for forward to the last token before bot
+	    (loop until (or (= end-token-index (nb-elements tokens))
+			    (mark> (start-offset (element* tokens end-token-index)) bot))
+		  do (incf end-token-index))
+	    (let ((start-token-index end-token-index))
+	      ;; go back to the first token after top
+	      (loop until (mark<= (end-offset (element* tokens (1- start-token-index))) top)
+		    do (decf start-token-index))
+	      ;; display the tokens
+	      (loop with prev-offset = (offset top)
+		    while (< start-token-index end-token-index)
+		    do (let ((token (element* tokens start-token-index)))
+			 (handle-whitespace pane (buffer pane) prev-offset (start-offset token))
+			 (updating-output (pane :unique-id token 
+						:id-test #'eq
+						:cache-value token
+						:cache-test #'eq)
+			   (present (coerce (region-to-sequence (start-mark token)
+								(end-offset token))
+					    'string)
+				    'string
+				    :stream pane))
+			 (setf prev-offset (end-offset token)))
+		       (incf start-token-index))))))))
+	    
+		
\ No newline at end of file


Index: climacs/packages.lisp
diff -u climacs/packages.lisp:1.53 climacs/packages.lisp:1.54
--- climacs/packages.lisp:1.53	Sat Mar  5 08:03:53 2005
+++ climacs/packages.lisp	Mon Mar  7 07:51:03 2005
@@ -122,7 +122,8 @@
 	   #:climacs-pane #:point #:mark
 	   #:redisplay-pane #:full-redisplay
 	   #:page-down #:page-up
-           #:tab-space-count
+	   #:top #:bot
+           #:tab-space-count #:space-width #:tab-width
            #:indent-tabs-mode
            #:auto-fill-mode #:auto-fill-column
            #:isearch-state #:search-string #:search-mark




More information about the Climacs-cvs mailing list