Changeset 554


Ignore:
Timestamp:
Feb 21, 2004, 5:19:58 PM (21 years ago)
Author:
Gary Byers
Message:

Maybe update the selection if the mark we move is the buffer's point.

Location:
trunk/ccl/hemlock/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/hemlock/src/htext1.lisp

    r55 r554  
    126126                  (len (length chars)))
    127127             (declare (simple-string chars))
    128              (when (> *line-cache-length* len)
     128             (when (> len *line-cache-length*)
    129129               (setf *line-cache-length* (* len 2))
    130130               (setf *open-chars* (make-string *line-cache-length*)))
  • trunk/ccl/hemlock/src/htext2.lisp

    r6 r554  
    1919(in-package :hemlock-internals)
    2020
     21(defun maybe-update-selection (mark)
     22  (let* ((line (mark-line mark))
     23         (buffer (if line (line-%buffer line)))
     24         (textstorage (if buffer (buffer-text-storage buffer))))
     25    (if (and buffer
     26             (eq mark (buffer-point buffer))
     27             textstorage)
     28      (textstorage-set-point-position textstorage))
     29    mark))
     30   
     31         
    2132
    2233
     
    248259(defun move-mark (mark new-position)
    249260  "Changes the Mark to point to the same position as New-Position."
    250   (let ((line (mark-line new-position)))
     261  (let* ((line (mark-line new-position)))
    251262    (change-line mark line))
    252263  (setf (mark-charpos mark) (mark-charpos new-position))
    253   mark)
     264  (maybe-update-selection mark))
     265
    254266
    255267
     
    288300  where it currently points.  If there aren't N characters before (or after)
    289301  the mark, Nil is returned."
    290   (let ((charpos (mark-charpos mark)))
    291     (if (< n 0)
    292         (let ((n (- n)))
    293           (if (< charpos n)
    294               (do ((line (line-previous (mark-line mark)) (line-previous line))
    295                    (n (- n charpos 1)))
    296                   ((null line) nil)
    297                 (let ((length (line-length* line)))
    298                   (cond ((<= n length)
    299                          (always-change-line mark line)
    300                          (setf (mark-charpos mark) (- length n))
    301                          (return mark))
    302                         (t
    303                          (setq n (- n (1+ length)))))))
    304               (progn (setf (mark-charpos mark) (- charpos n))
    305                      mark)))
    306         (let* ((line (mark-line mark))
    307                (length (line-length* line)))
    308           (if (> (+ charpos n) length)
    309               (do ((line (line-next line) (line-next line))
    310                    (n (- n (1+ (- length charpos)))))
    311                   ((null line) nil)
    312                 (let ((length (line-length* line)))
    313                   (cond ((<= n length)
    314                          (always-change-line mark line)
    315                          (setf (mark-charpos mark) n)
    316                          (return mark))
    317                         (t
    318                          (setq n (- n (1+ length)))))))
    319               (progn (setf (mark-charpos mark) (+ charpos n))
    320                      mark))))))
     302  (let* ((charpos (mark-charpos mark))
     303         (result-mark
     304          (if (< n 0)
     305            (let ((n (- n)))
     306              (if (< charpos n)
     307                (do ((line (line-previous (mark-line mark)) (line-previous line))
     308                     (n (- n charpos 1)))
     309                    ((null line) nil)
     310                  (let ((length (line-length* line)))
     311                    (cond ((<= n length)
     312                           (always-change-line mark line)
     313                           (setf (mark-charpos mark) (- length n))
     314                           (return mark))
     315                          (t
     316                           (setq n (- n (1+ length)))))))
     317                (progn (setf (mark-charpos mark) (- charpos n))
     318                       mark)))
     319            (let* ((line (mark-line mark))
     320                   (length (line-length* line)))
     321              (if (> (+ charpos n) length)
     322                (do ((line (line-next line) (line-next line))
     323                     (n (- n (1+ (- length charpos)))))
     324                    ((null line) nil)
     325                  (let ((length (line-length* line)))
     326                    (cond ((<= n length)
     327                           (always-change-line mark line)
     328                           (setf (mark-charpos mark) n)
     329                           (return mark))
     330                          (t
     331                           (setq n (- n (1+ length)))))))
     332                (progn (setf (mark-charpos mark) (+ charpos n))
     333                       mark))))))
     334    (if result-mark (maybe-update-selection result-mark))))
    321335
    322336
Note: See TracChangeset for help on using the changeset viewer.