Changeset 6582 for branches


Ignore:
Timestamp:
May 20, 2007, 9:06:35 AM (18 years ago)
Author:
Gary Byers
Message:

Back out of gap-context change, for now.

Location:
branches/ide-1.0/ccl/hemlock/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/ide-1.0/ccl/hemlock/src/line.lisp

    r6571 r6582  
    140140(defmacro line-length* (line)
    141141  "Returns the number of characters on the line, but it's a macro!"
    142   (let* ((buffer (gensym)))
    143     `(let* ((,buffer (line-%buffer ,line)))
    144       (cond ((eq ,line (buffer-open-line ,buffer))
    145              (+ (buffer-left-open-pos ,buffer) (- (buffer-line-cache-length ,buffer) (buffer-right-open-pos ,buffer))))
    146             ((line-buffered-p ,line))
    147             (t
    148              (length (the simple-string (line-%chars ,line))))))))
     142  `(cond ((eq ,line *open-line*)
     143          (+ *left-open-pos* (- *line-cache-length* *right-open-pos*)))
     144         ((line-buffered-p ,line))
     145         (t
     146          (length (the simple-string (line-%chars ,line))))))
  • branches/ide-1.0/ccl/hemlock/src/linimage.lisp

    r6574 r6582  
    339339;;;    Like compute-normal-line-image, only works on the cached line.
    340340;;;
    341 (defun compute-cached-line-image (buffer index dis-line xpos width)
     341(defun compute-cached-line-image (index dis-line xpos width)
    342342  (declare (fixnum index width) (type (or fixnum null) xpos))
    343   (prog ((gap (- (buffer-right-open-pos buffer) (buffer-left-open-pos buffer)))
     343  (prog ((gap (- *right-open-pos* *left-open-pos*))
    344344         (dest (dis-line-chars dis-line))
    345          (done-p (= (buffer-right-open-pos buffer)
    346                     (buffer-line-cache-length buffer)))
     345         (done-p (= *right-open-pos* *line-cache-length*))
    347346         (losing 0)
    348347         string underhang)
     
    355354     ((null xpos)
    356355      (update-and-punt dis-line width nil 0 index))
    357      ((>= index (buffer-left-open-pos buffer))
     356     ((>= index *left-open-pos*)
    358357      (go RIGHT-START)))
    359     (setq losing (%fcwa (buffer-open-chars buffer) index (buffer-left-open-pos buffer) losing-char))
     358    (setq losing (%fcwa *open-chars* index *left-open-pos* losing-char))
    360359    (cond
    361360     (losing
    362       (display-some-chars (buffer-open-chars buffer) index losing dest xpos width nil)
     361      (display-some-chars *open-chars* index losing dest xpos width nil)
    363362      ;; If we we didn't wrap then display some losers...
    364363      (if xpos
    365           (display-losing-chars (buffer-open-chars buffer) index (buffer-left-open-pos buffer) dest xpos
     364          (display-losing-chars *open-chars* index *left-open-pos* dest xpos
    366365                                width string underhang string-get-rep
    367                                 (and done-p (= index (buffer-left-open-pos buffer))))
     366                                (and done-p (= index *left-open-pos*)))
    368367          (update-and-punt dis-line width nil 0 index)))
    369368     (t
    370       (display-some-chars (buffer-open-chars buffer) index (buffer-left-open-pos buffer) dest xpos width done-p)))
     369      (display-some-chars *open-chars* index *left-open-pos* dest xpos width done-p)))
    371370    (go LEFT-LOOP)
    372371
     
    379378     ((null xpos)
    380379      (update-and-punt dis-line width nil 0 (- index gap)))
    381      ((= index (buffer-line-cache-length buffer))
     380     ((= index *line-cache-length*)
    382381      (update-and-punt dis-line xpos nil nil (- index gap))))
    383     (setq losing (%fcwa (buffer-open-chars buffer) index (buffer-line-cache-length buffer) losing-char))
     382    (setq losing (%fcwa *open-chars* index *line-cache-length* losing-char))
    384383    (cond
    385384     (losing
    386       (display-some-chars (buffer-open-chars buffer) index losing dest xpos width nil)
     385      (display-some-chars *open-chars* index losing dest xpos width nil)
    387386      (cond
    388387       ;; Did we wrap?
     
    390389        (update-and-punt dis-line width nil 0 (- index gap)))
    391390       (t
    392         (display-losing-chars (buffer-open-chars buffer) index (buffer-line-cache-length buffer) dest xpos
     391        (display-losing-chars *open-chars* index *line-cache-length* dest xpos
    393392                              width string underhang string-get-rep))))
    394393     (t
    395       (display-some-chars (buffer-open-chars buffer) index (buffer-line-cache-length buffer) dest xpos width t)))
    396     (go RIGHT-LOOP)))
     394      (display-some-chars *open-chars* index *line-cache-length* dest xpos width t)))
     395    (go RIGHT-LOOP))) 
    397396
    398397
     
    443442;;;
    444443(defun compute-line-image (string underhang line offset dis-line width)
    445   (let* ((buffer (line-%buffer line)))
    446     ;;
    447     ;; Release any old font-changes.
    448     (let ((changes (dis-line-font-changes dis-line)))
    449       (when changes
    450         (do ((prev changes current)
    451              (current (font-change-next changes)
    452                       (font-change-next current)))
    453             ((null current)
    454              (setf (dis-line-font-changes dis-line) nil)
    455              (shiftf (font-change-next prev) *free-font-changes* changes))
    456           (setf (font-change-mark current) nil))))
    457     ;;
    458     ;; If the line has any Font-Marks, add Font-Changes for them.
    459     (let ((marks (line-marks line)))
    460       (when (dolist (m marks nil)
    461               (when (fast-font-mark-p m) (return t)))
    462         (let ((prev nil))
    463           ;;
    464           ;; Find the last Font-Mark with charpos less than Offset.  If there is
    465           ;; such a Font-Mark, then there is a font-change to this font at X = 0.
    466           (let ((max -1)
    467                 (max-mark nil))
    468             (dolist (m marks)
    469               (when (fast-font-mark-p m)
    470                 (let ((charpos (mark-charpos m)))
    471                   (when (and (< charpos offset) (> charpos max))
    472                     (setq max charpos  max-mark m)))))
    473             (when max-mark
    474               (setq prev (alloc-font-change 0 (font-mark-font max-mark) max-mark))
    475               (setf (dis-line-font-changes dis-line) prev)))
    476           ;;
    477           ;; Repeatedly scan through marks, adding a font-change for the
    478           ;; smallest Font-Mark with a charpos greater than Bound, until
    479           ;; we find no such mark.
    480           (do ((bound (1- offset) min)
    481                (min most-positive-fixnum most-positive-fixnum)
    482                (min-mark nil nil))
    483               (())
    484             (dolist (m marks)
    485               (when (fast-font-mark-p m)
    486                 (let ((charpos (mark-charpos m)))
    487                   (when (and (> charpos bound) (< charpos min))
    488                     (setq min charpos  min-mark m)))))
    489             (unless min-mark (return nil))
    490             (let ((len (if (eq line (buffer-open-line buffer))
     444  ;;
     445  ;; Release any old font-changes.
     446  (let ((changes (dis-line-font-changes dis-line)))
     447    (when changes
     448      (do ((prev changes current)
     449           (current (font-change-next changes)
     450                    (font-change-next current)))
     451          ((null current)
     452           (setf (dis-line-font-changes dis-line) nil)
     453           (shiftf (font-change-next prev) *free-font-changes* changes))
     454        (setf (font-change-mark current) nil))))
     455  ;;
     456  ;; If the line has any Font-Marks, add Font-Changes for them.
     457  (let ((marks (line-marks line)))
     458    (when (dolist (m marks nil)
     459            (when (fast-font-mark-p m) (return t)))
     460      (let ((prev nil))
     461        ;;
     462        ;; Find the last Font-Mark with charpos less than Offset.  If there is
     463        ;; such a Font-Mark, then there is a font-change to this font at X = 0.
     464        (let ((max -1)
     465              (max-mark nil))
     466          (dolist (m marks)
     467            (when (fast-font-mark-p m)
     468              (let ((charpos (mark-charpos m)))
     469                (when (and (< charpos offset) (> charpos max))
     470                  (setq max charpos  max-mark m)))))
     471          (when max-mark
     472            (setq prev (alloc-font-change 0 (font-mark-font max-mark) max-mark))
     473            (setf (dis-line-font-changes dis-line) prev)))
     474        ;;
     475        ;; Repeatedly scan through marks, adding a font-change for the
     476        ;; smallest Font-Mark with a charpos greater than Bound, until
     477        ;; we find no such mark.
     478        (do ((bound (1- offset) min)
     479             (min most-positive-fixnum most-positive-fixnum)
     480             (min-mark nil nil))
     481            (())
     482          (dolist (m marks)
     483            (when (fast-font-mark-p m)
     484              (let ((charpos (mark-charpos m)))
     485                (when (and (> charpos bound) (< charpos min))
     486                  (setq min charpos  min-mark m)))))
     487          (unless min-mark (return nil))
     488          (let ((len (if (eq line *open-line*)
    491489                         (cached-real-line-length line 10000 offset min)
    492490                         (real-line-length line 10000 offset min))))
    493               (when (< len width)
    494                 (let ((new (alloc-font-change
    495                             (+ len
    496                                (if string
     491            (when (< len width)
     492              (let ((new (alloc-font-change
     493                          (+ len
     494                             (if string
    497495                                 (- (length (the simple-string string)) underhang)
    498496                                 0))
    499                             (font-mark-font min-mark)
    500                             min-mark)))
    501                   (if prev
     497                          (font-mark-font min-mark)
     498                          min-mark)))
     499                (if prev
    502500                    (setf (font-change-next prev) new)
    503501                    (setf (dis-line-font-changes dis-line) new))
    504                   (setq prev new))))))))
    505     ;;
    506     ;; Recompute the line image.
    507     (cond
    508       (string
    509        (let ((len (strlen string))
    510              (chars (dis-line-chars dis-line))
    511              (xpos 0))
    512          (declare (type (or fixnum null) xpos) (simple-string chars))
    513          (display-some-chars string underhang len chars xpos width nil)
    514          (cond
    515            ((null xpos)
    516             (values string underhang offset))     
    517            ((eq line (buffer-open-line buffer))
    518             (compute-cached-line-image buffer offset dis-line xpos width))
    519            ((line-buffered-p line)
    520             (compute-buffered-line-image line offset dis-line xpos width))
    521            (t
    522             (compute-normal-line-image line offset dis-line xpos width)))))
    523       ((eq line (buffer-open-line buffer))
    524        (compute-cached-line-image offset dis-line 0 width))
    525       ((line-buffered-p line)
    526        (compute-buffered-line-image line offset dis-line 0 width))
    527       (t
    528        (compute-normal-line-image line offset dis-line 0 width)))))
     502                (setq prev new))))))))
     503  ;;
     504  ;; Recompute the line image.
     505  (cond
     506   (string
     507    (let ((len (strlen string))
     508          (chars (dis-line-chars dis-line))
     509          (xpos 0))
     510      (declare (type (or fixnum null) xpos) (simple-string chars))
     511      (display-some-chars string underhang len chars xpos width nil)
     512      (cond
     513       ((null xpos)
     514        (values string underhang offset))         
     515       ((eq line *open-line*)
     516        (compute-cached-line-image offset dis-line xpos width))
     517       ((line-buffered-p line)
     518        (compute-buffered-line-image line offset dis-line xpos width))
     519       (t
     520        (compute-normal-line-image line offset dis-line xpos width)))))
     521   ((eq line *open-line*)
     522    (compute-cached-line-image offset dis-line 0 width))
     523   ((line-buffered-p line)
     524    (compute-buffered-line-image line offset dis-line 0 width))
     525   (t
     526    (compute-normal-line-image line offset dis-line 0 width))))
  • branches/ide-1.0/ccl/hemlock/src/macros.lisp

    r6572 r6582  
    255255             (push `(,name (copy-mark ,pos :temporary)) let-slots))))))
    256256
    257 #|SAve this shit in case we want WITH-MARKto no longer cons marks.
     257#||SAve this shit in case we want WITH-MARKto no longer cons marks.
    258258(defconstant with-mark-total 50)
    259259(defvar *with-mark-free-marks* (make-array with-mark-total))
     
    316316      (push mark (line-marks (mark-line mark))))
    317317    mark))
    318 |#
    319 
     318||#
     319
     320
     321(defmacro use-buffer (buffer &body forms)
     322  "Use-Buffer Buffer {Form}*
     323  Has The effect of making Buffer the current buffer during the evaluation
     324  of the Forms.  For restrictions see the manual."
     325  (let ((gensym (gensym)))
     326    `(let ((,gensym *current-buffer*)
     327           (*current-buffer* ,buffer))
     328      (unwind-protect
     329           (progn
     330             (use-buffer-set-up ,gensym)
     331             ,@forms)
     332        (use-buffer-clean-up ,gensym)))))
    320333
    321334
  • branches/ide-1.0/ccl/hemlock/src/search1.lisp

    r6571 r6582  
    634634  If there is no match for the pattern then Mark is not modified and NIL
    635635  is returned."
    636   (close-line (line-%buffer (mark-line mark)))
     636  (close-line)
    637637  (multiple-value-bind (line start matched)
    638638                       (funcall (search-pattern-search-function search-pattern)
     
    650650  in the text starting at the given Mark.  If N is Nil, all occurrences
    651651  following the Mark are replaced."
    652   (let* ((buffer (line-%buffer (mark-line mark))))
    653     (close-line buffer)
    654     (do* ((replacement (coerce replacement 'simple-string))
    655           (new (length (the simple-string replacement)))
    656           (fun (search-pattern-search-function search-pattern))
    657           (forward-p (eq (search-pattern-direction search-pattern) :forward))
    658           (n (if n (1- n) -1) (1- n))
    659           (m (copy-mark mark :temporary)) line start matched)
    660          (())
    661       (multiple-value-setq (line start matched)
    662         (funcall fun search-pattern (mark-line m) (mark-charpos m)))
    663       (unless matched (return m))
    664       (setf (mark-line m) line  (mark-charpos m) start)
    665       (delete-characters m matched)
    666       (insert-string m replacement)
    667       (when forward-p (character-offset m new))
    668       (when (zerop n) (return m))
    669       (close-line buffer))))
     652  (close-line)
     653  (do* ((replacement (coerce replacement 'simple-string))
     654        (new (length (the simple-string replacement)))
     655        (fun (search-pattern-search-function search-pattern))
     656        (forward-p (eq (search-pattern-direction search-pattern) :forward))
     657        (n (if n (1- n) -1) (1- n))
     658        (m (copy-mark mark :temporary)) line start matched)
     659       (())
     660    (multiple-value-setq (line start matched)
     661      (funcall fun search-pattern (mark-line m) (mark-charpos m)))
     662    (unless matched (return m))
     663    (setf (mark-line m) line  (mark-charpos m) start)
     664    (delete-characters m matched)
     665    (insert-string m replacement)
     666    (when forward-p (character-offset m new))
     667    (when (zerop n) (return m))
     668    (close-line)))
  • branches/ide-1.0/ccl/hemlock/src/struct.lisp

    r6571 r6582  
    111111  (external-format :unix)     ; Line-termination, for the time being
    112112  process                     ; Maybe a listener
    113   (line-cache-length 200)     ; Length of string used for per-buffer gap.
    114   (open-chars (make-string 200)) ; String used for per-buffer cache
    115   (left-open-pos 0)           ; Index of first free character to left of
    116                               ; gap in open-chars.
    117   (right-open-pos 0)          ; Index of first used character to right of
    118                               ; gap in open-chars
    119   %open-line                  ; line which open-chars represent, or nil.
     113  (gap-context )              ; The value of *buffer-gap-context*
     114                              ; in the thread that can modify the buffer.
    120115  protected-region            ; (optional) write-protected region
    121116  (font-regions (ccl::init-dll-header (ccl::make-dll-header)))
    122117                                        ; a doubly-linked list of font regions.
    123118  active-font-region                    ; currently active font region
    124   (lock (ccl:make-lock))
    125119  )
    126120
     
    685679   any buffer whose fields list contains the field.")
    686680
    687 
    688 
    689 (defun buffer-open-line (buffer)
    690   (if (typep buffer 'buffer)
    691     (buffer-%open-line buffer)))
    692 
    693 (defun (setf buffer-open-line) (line buffer)
    694   (setf (buffer-%open-line buffer) line))
    695 
    696 
    697 
    698 
    699 
    700              
     681;;; Shared buffer-gap context, used to communicate between command threads
     682;;; and the event thread.  Note that this isn't buffer-specific; in particular,
     683;;; OPEN-LINE and friends may not point at a line that belongs to any
     684;;; buffer.
     685
     686(defstruct buffer-gap-context
     687  (lock (ccl::make-lock))
     688  (left-open-pos 0)
     689  (right-open-pos 0)
     690  (line-cache-length 200)
     691  (open-line nil)
     692  (open-chars (make-string 200))
     693)
     694
     695(define-symbol-macro *line-cache-length* (buffer-gap-context-line-cache-length *buffer-gap-context*))
     696(define-symbol-macro *open-line* (buffer-gap-context-open-line *buffer-gap-context*))
     697(define-symbol-macro *open-chars* (buffer-gap-context-open-chars *buffer-gap-context*))
     698(define-symbol-macro *left-open-pos* (buffer-gap-context-left-open-pos *buffer-gap-context*))
     699(define-symbol-macro *right-open-pos* (buffer-gap-context-right-open-pos *buffer-gap-context*))
     700
Note: See TracChangeset for help on using the changeset viewer.