Commit 4f8663ce authored by Robert Strandh's avatar Robert Strandh

First attempt at a display function (for html syntax) that uses the

output of an incremental lexer and parser.  This code is not complete

  * 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.
parent fc4dbace
......@@ -55,12 +55,12 @@
;;---- optional ----
......@@ -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)))
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)))
;; 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))
:stream pane))
(setf prev-offset (end-offset token)))
(incf start-token-index))))))))
\ No newline at end of file
......@@ -122,7 +122,8 @@
#:climacs-pane #:point #:mark
#:redisplay-pane #:full-redisplay
#:page-down #:page-up
#:top #:bot
#:tab-space-count #:space-width #:tab-width
#:auto-fill-mode #:auto-fill-column
#:isearch-state #:search-string #:search-mark
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment