From fefb4b002de38925d0da75cee253f474c9c1241e Mon Sep 17 00:00:00 2001 From: eknauel Date: Fri, 20 May 2005 08:02:05 +0000 Subject: [PATCH] fix cursor positioning if cursor is located on the last line --- scheme/input-buffer.scm | 67 ++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/scheme/input-buffer.scm b/scheme/input-buffer.scm index 1ac283c..81a1558 100644 --- a/scheme/input-buffer.scm +++ b/scheme/input-buffer.scm @@ -318,29 +318,60 @@ (new-y (- (+ (- pos-fin-ln no-wrapped-lines) first-line-offset) 1))) -; (debug-message "num-cols " -; num-cols -; " no-wrapped-lines " -; no-wrapped-lines -; " first-line-offset " -; first-line-offset -; " new-y " new-y -; " length " -; item-length -; " pos-fin-ln " -; pos-fin-ln -; " pos-col " -; pos-col) - (if (and (not (zero? text-index)) - (zero? (remainder text-index num-cols)) - (= text-index item-length)) - (set-buffer-pos-y! buffer (+ new-y 1)) - (set-buffer-pos-y! buffer new-y)) + (debug-message "num-cols " + num-cols + " no-wrapped-lines " + no-wrapped-lines + " first-line-offset " + first-line-offset + " new-y " new-y + " length " + item-length + " pos-fin-ln " + pos-fin-ln + " text-index " + text-index + " pos-line " + (buffer-pos-line buffer) + " num-lines " + num-lines) +; (if (and (not (zero? text-index)) +; (zero? (remainder text-index num-cols)) +; (= text-index item-length)) +; (set-buffer-pos-y! buffer (+ new-y 1)) +; (set-buffer-pos-y! buffer new-y)) + + + (cond + ((and (>= new-y num-lines) + (not (zero? text-index)) + (zero? (remainder text-index num-cols)) + (= text-index item-length)) + (set-buffer-pos-y! buffer num-lines)) + ((and (>= new-y num-lines) + (< text-index item-length)) + (set-buffer-pos-y! buffer + (- num-lines + (- (+ no-wrapped-lines 1) + first-line-offset)))) + ((>= new-y num-lines) + (set-buffer-pos-y! buffer (- num-lines 1))) + ((and (not (zero? text-index)) + (zero? (remainder text-index num-cols)) + (= text-index item-length)) + (set-buffer-pos-y! buffer (+ new-y 1))) + (else + (set-buffer-pos-y! buffer new-y))) + ;; x position (set-buffer-pos-x! buffer (+ first-column (modulo text-index num-cols))) + (debug-message "cursor position " + (buffer-pos-x buffer) + " " + (buffer-pos-y buffer)) ; (debug-message "num-cols " num-cols ; " pos-col " pos-col ; " text '" (buffer-text-current-line buffer) "'")