fix cursor positioning if cursor is located on the last line
This commit is contained in:
parent
0aeb6b35ff
commit
fefb4b002d
|
@ -318,29 +318,60 @@
|
||||||
(new-y (- (+ (- pos-fin-ln no-wrapped-lines)
|
(new-y (- (+ (- pos-fin-ln no-wrapped-lines)
|
||||||
first-line-offset)
|
first-line-offset)
|
||||||
1)))
|
1)))
|
||||||
; (debug-message "num-cols "
|
(debug-message "num-cols "
|
||||||
; num-cols
|
num-cols
|
||||||
; " no-wrapped-lines "
|
" no-wrapped-lines "
|
||||||
; no-wrapped-lines
|
no-wrapped-lines
|
||||||
; " first-line-offset "
|
" first-line-offset "
|
||||||
; first-line-offset
|
first-line-offset
|
||||||
; " new-y " new-y
|
" new-y " new-y
|
||||||
; " length "
|
" length "
|
||||||
; item-length
|
item-length
|
||||||
; " pos-fin-ln "
|
" pos-fin-ln "
|
||||||
; pos-fin-ln
|
pos-fin-ln
|
||||||
; " pos-col "
|
" text-index "
|
||||||
; pos-col)
|
text-index
|
||||||
(if (and (not (zero? 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))
|
(zero? (remainder text-index num-cols))
|
||||||
(= text-index item-length))
|
(= text-index item-length))
|
||||||
(set-buffer-pos-y! buffer (+ new-y 1))
|
(set-buffer-pos-y! buffer num-lines))
|
||||||
(set-buffer-pos-y! buffer new-y))
|
((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
|
;; x position
|
||||||
(set-buffer-pos-x! buffer (+ first-column
|
(set-buffer-pos-x! buffer (+ first-column
|
||||||
(modulo text-index num-cols)))
|
(modulo text-index num-cols)))
|
||||||
|
|
||||||
|
(debug-message "cursor position "
|
||||||
|
(buffer-pos-x buffer)
|
||||||
|
" "
|
||||||
|
(buffer-pos-y buffer))
|
||||||
; (debug-message "num-cols " num-cols
|
; (debug-message "num-cols " num-cols
|
||||||
; " pos-col " pos-col
|
; " pos-col " pos-col
|
||||||
; " text '" (buffer-text-current-line buffer) "'")
|
; " text '" (buffer-text-current-line buffer) "'")
|
||||||
|
|
Loading…
Reference in New Issue