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)
|
||||
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) "'")
|
||||
|
|
Loading…
Reference in New Issue