Commit 1e160e15 authored by Aleksandar Bakic's avatar Aleksandar Bakic

And end-of-line bug fix and related cleanup.

parent 3de1cb33
......@@ -65,7 +65,7 @@
for e in l
do
(push e curr)
(when (eq e #\Newline)
(when (eql e #\Newline)
(push (list-obinseq (nreverse curr)) ll)
(setf curr nil))
finally
......@@ -136,7 +136,7 @@
"If the last line of A does not end with a newline, remove the first
line of B and append it to the last line of A; otherwise, do nothing."
(let ((a-last-line (cdr (binseq2-back a 1))))
(if (eq (obinseq-back a-last-line 1) #\Newline)
(if (eql (obinseq-back a-last-line 1) #\Newline)
(values a b)
(values
(binseq2-set a (1- (binseq2-length a))
......@@ -227,11 +227,11 @@ line of B and append it to the last line of A; otherwise, do nothing."
(defun binseq2-offset (s i)
(labels ((%offset (s i o)
(cond
((or (<= i 0) (eq s 'empty) (eq (car s) 'leaf)) o)
((<= i (binseq2-length (caddr s))) (%offset (caddr s) i o))
((or (eq s 'empty) (<= i 0) (eq (car s) 'leaf)) o)
((< i (binseq2-length (caddr s))) (%offset (caddr s) i o))
(t (%offset (cdddr s) (- i (binseq2-length (caddr s)))
(+ o (binseq2-size (caddr s))))))))
(%offset s (1+ i) 0)))
(%offset s i 0)))
(defun binseq2-front2 (s i)
(cond
......@@ -246,11 +246,11 @@ line of B and append it to the last line of A; otherwise, do nothing."
(defun binseq2-line2 (s i)
(labels ((%line (s i o)
(cond
((or (<= i 0) (eq s 'empty) (eq (car s) 'leaf)) o)
((<= i (binseq2-size (caddr s))) (%line (caddr s) i o))
((or (eq s 'empty) (<= i 0) (eq (car s) 'leaf)) o)
((< i (binseq2-size (caddr s))) (%line (caddr s) i o))
(t (%line (cdddr s) (- i (binseq2-size (caddr s)))
(+ o (binseq2-length (caddr s))))))))
(%line s (1+ i) 0)))
(%line s i 0)))
(defun binseq2-back (s i)
(cond
......
......@@ -373,14 +373,18 @@ suitable for use in a PERSISTENT-BUFFER."))
(setf (offset mark) offset)))
(defmethod end-of-line ((mark p-line-mark-mixin))
(let* ((curr-offset (offset mark))
(contents (slot-value (buffer mark) 'contents))
(next-line-offset (binseq2-offset
contents
(1+ (binseq2-line2 contents curr-offset)))))
(if (> next-line-offset curr-offset)
(setf (offset mark) (1- next-line-offset))
(setf (offset mark) (size (buffer mark))))))
(let* ((offset (offset mark))
(buffer (buffer mark))
(size (size buffer))
(contents (slot-value buffer 'contents))
(next-line-offset
(binseq2-offset contents (1+ (binseq2-line2 contents offset)))))
(setf (offset mark)
(cond
((> next-line-offset offset) (1- next-line-offset))
((and (> size 0) (eql (binseq2-get2 contents (1- size)) #\Newline))
(1- size))
(t size)))))
(defmethod buffer-line-number ((buffer persistent-buffer) (offset integer))
(loop for i from 0 below offset
......
......@@ -703,6 +703,19 @@ climacs")
(progn (end-of-line m) (end-of-line-p m)))))
t)
(defmultitest end-of-line.test-2
(let ((buffer (make-instance %%buffer)))
(insert-buffer-sequence buffer 0 "climacs
")
(let ((m (clone-mark (low-mark buffer) :left)))
(setf (offset m) 1)
(and (not (end-of-line-p m))
(progn (end-of-line m)
(values
(= (offset m) 7)
(buffer-object (buffer m) (offset m)))))))
t #\Newline)
(defmultitest beginning-of-buffer.test-1
(let ((buffer (make-instance %%buffer)))
(insert-buffer-sequence buffer 0 "climacs
......
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