Changeset 6603
- Timestamp:
- May 25, 2007, 4:57:08 AM (18 years ago)
- File:
-
- 1 edited
-
branches/ide-1.0/ccl/hemlock/src/htext3.lisp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ide-1.0/ccl/hemlock/src/htext3.lisp
r6580 r6603 76 76 character) 77 77 (incf *left-open-pos*))))) 78 (adjust-line-origins-forward line) 78 79 (buffer-note-insertion buffer mark 1)))) 79 80 80 81 81 82 82 (defun insert-string (mark string &optional (start 0) (end (length string)))83 (defun insert-string (mark string #| &optional (start 0) (end (length string))|#) 83 84 "Inserts the String at the Mark. Do not use Start and End unless you 84 85 know what you're doing!" 85 86 (let* ((line (mark-line mark)) 87 (len (length string)) 86 88 (buffer (line-%buffer line)) 87 89 (string (coerce string 'simple-string)) … … 91 93 (when region 92 94 (delete-region region)) 93 (unless (zerop (- end start)) 94 (if (%sp-find-character string start end #\newline) 95 (with-mark ((mark mark :left-inserting)) 96 (do ((left-index start (1+ right-index)) 97 (right-index 98 (%sp-find-character string start end #\newline) 99 (%sp-find-character string (1+ right-index) end #\newline))) 100 ((null right-index) 101 (if (/= left-index end) 102 (insert-string mark string left-index end))) 103 (insert-string mark string left-index right-index) 104 (insert-character mark #\newline))) 105 (modifying-buffer 106 buffer 107 (modifying-line line mark) 108 (let ((length (- end start))) 109 (if (<= *right-open-pos* (+ *left-open-pos* end)) 110 (grow-open-chars (* (+ *line-cache-length* end) 2))) 111 112 (maybe-move-some-marks (charpos line) *left-open-pos* 113 (+ charpos length)) 114 (cond 115 ((eq (mark-%kind mark) :right-inserting) 116 (let ((new (- *right-open-pos* length))) 117 (%sp-byte-blt string start *open-chars* new *right-open-pos*) 118 (setq *right-open-pos* new))) 119 (t 120 (let ((new (+ *left-open-pos* length))) 121 (%sp-byte-blt string start *open-chars* *left-open-pos* new) 122 (setq *left-open-pos* new))))) 123 (buffer-note-insertion buffer mark (- end start))))))) 95 (unless (zerop len) 96 (if (%sp-find-character string 0 len #\newline) 97 (ninsert-region mark (string-to-region string)) 98 (modifying-buffer 99 buffer 100 (progn 101 (modifying-line line mark) 102 (if (<= *right-open-pos* (+ *left-open-pos* len)) 103 (grow-open-chars (* (+ *line-cache-length* len) 2))) 104 (maybe-move-some-marks (charpos line) *left-open-pos* 105 (+ charpos len)) 106 (cond 107 ((eq (mark-%kind mark) :right-inserting) 108 (let ((new (- *right-open-pos* len))) 109 (%sp-byte-blt string 0 *open-chars* new *right-open-pos*) 110 (setq *right-open-pos* new))) 111 (t 112 (let ((new (+ *left-open-pos* len))) 113 (%sp-byte-blt string 0 *open-chars* *left-open-pos* new) 114 (setq *left-open-pos* new))))) 115 (adjust-line-origins-forward line) 116 (buffer-note-insertion buffer mark (length string))))))) 117 118 124 119 125 120 … … 141 136 ;; simple case -- just BLT the characters in with insert-string 142 137 (if (eq first-line *open-line*) (close-line)) 143 (insert-string mark (line-chars first-line) first-charpos last-charpos)) 138 (let* ((string (line-chars first-line))) 139 (unless (and (eql first-charpos 0) 140 (eql last-charpos (length string))) 141 (setq string (subseq string first-charpos last-charpos))) 142 (insert-string mark string))) 144 143 (t 145 144 (close-line) … … 193 192 (+ last-charpos (- this-charpos charpos))))) 194 193 (setf (line-next previous) new-line previous new-line)) 194 (adjust-line-origins-forward line) 195 195 (buffer-note-insertion buffer mark nins))))))) 196 196 … … 210 210 ;; Simple case -- just BLT the characters in with insert-string. 211 211 (if (eq first-line *open-line*) (close-line)) 212 (insert-string mark (line-chars first-line) first-charpos last-charpos)) 212 (let* ((string (line-chars first-line))) 213 (unless (and (eq first-charpos 0) 214 (eql last-charpos (length string))) 215 (setq string (subseq string first-charpos last-charpos))) 216 (insert-string mark string))) 213 217 (t 214 218 (when (bufferp (line-%buffer first-line)) … … 265 269 (maybe-move-some-marks (this-charpos line last-line) charpos 266 270 (+ last-charpos (- this-charpos charpos))) 271 (adjust-line-origins-forward line) 267 272 (buffer-note-insertion buffer mark nins)))))))
Note:
See TracChangeset
for help on using the changeset viewer.
