diff --git a/lisp/channel-tui-main.lisp b/lisp/channel-tui-main.lisp index bd79c17..7f96d0f 100644 --- a/lisp/channel-tui-main.lisp +++ b/lisp/channel-tui-main.lisp @@ -562,14 +562,14 @@ (reverse (coerce (nth (st :input-hpos) h) 'list)) nil)) (setf (st :dirty) (list nil nil t))))) - ;; PageUp + ;; PageUp — scroll back by page (10 lines) ((or (eq ch :ppage) (eql ch 339)) (let ((max-offset (max 0 (- (length (st :messages)) 1)))) - (setf (st :scroll-offset) (min max-offset (+ (st :scroll-offset) 5)))) + (setf (st :scroll-offset) (min max-offset (+ (st :scroll-offset) 10)))) (setf (st :dirty) (list nil t nil))) - ;; PageDown + ;; PageDown — scroll forward by page ((or (eq ch :npage) (eql ch 338)) - (setf (st :scroll-offset) (max 0 (- (st :scroll-offset) 5))) + (setf (st :scroll-offset) (max 0 (- (st :scroll-offset) 10))) (setf (st :dirty) (list nil t nil))) ;; Printable (t @@ -1304,3 +1304,19 @@ (on-key 13) (let ((msgs (st :messages))) (fiveam:is (some (lambda (m) (search ".env" (getf m :content))) msgs)))) + +(fiveam:test test-pads-page-up + "Contract v0.7.2: PageUp scrolls by page size (> 5 lines)." + (init-state) + (dotimes (i 30) (add-msg :system (format nil "msg ~d" i))) + (setf (st :scroll-offset) 0) + (on-key :ppage) + (fiveam:is (> (st :scroll-offset) 5) "Should scroll by more than 5 lines")) + +(fiveam:test test-pads-page-down-clamp + "Contract v0.7.2: PageDown clamps to 0." + (init-state) + (dotimes (i 5) (add-msg :system (format nil "msg ~d" i))) + (setf (st :scroll-offset) 3) + (on-key :npage) + (fiveam:is (= 0 (st :scroll-offset)))) diff --git a/org/channel-tui-main.org b/org/channel-tui-main.org index 8647af6..3e48169 100644 --- a/org/channel-tui-main.org +++ b/org/channel-tui-main.org @@ -596,14 +596,14 @@ Event handlers + daemon I/O + main loop. (reverse (coerce (nth (st :input-hpos) h) 'list)) nil)) (setf (st :dirty) (list nil nil t))))) - ;; PageUp + ;; PageUp — scroll back by page (10 lines) ((or (eq ch :ppage) (eql ch 339)) (let ((max-offset (max 0 (- (length (st :messages)) 1)))) - (setf (st :scroll-offset) (min max-offset (+ (st :scroll-offset) 5)))) + (setf (st :scroll-offset) (min max-offset (+ (st :scroll-offset) 10)))) (setf (st :dirty) (list nil t nil))) - ;; PageDown + ;; PageDown — scroll forward by page ((or (eq ch :npage) (eql ch 338)) - (setf (st :scroll-offset) (max 0 (- (st :scroll-offset) 5))) + (setf (st :scroll-offset) (max 0 (- (st :scroll-offset) 10))) (setf (st :dirty) (list nil t nil))) ;; Printable (t @@ -1351,4 +1351,20 @@ Event handlers + daemon I/O + main loop. (on-key 13) (let ((msgs (st :messages))) (fiveam:is (some (lambda (m) (search ".env" (getf m :content))) msgs)))) + +(fiveam:test test-pads-page-up + "Contract v0.7.2: PageUp scrolls by page size (> 5 lines)." + (init-state) + (dotimes (i 30) (add-msg :system (format nil "msg ~d" i))) + (setf (st :scroll-offset) 0) + (on-key :ppage) + (fiveam:is (> (st :scroll-offset) 5) "Should scroll by more than 5 lines")) + +(fiveam:test test-pads-page-down-clamp + "Contract v0.7.2: PageDown clamps to 0." + (init-state) + (dotimes (i 5) (add-msg :system (format nil "msg ~d" i))) + (setf (st :scroll-offset) 3) + (on-key :npage) + (fiveam:is (= 0 (st :scroll-offset)))) #+end_src