From b3ce9056de676c23004d9dda1648ebd6b2bdcd9e Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Fri, 8 May 2026 21:50:25 -0400 Subject: [PATCH] =?UTF-8?q?v0.7.2:=20pads=20=E2=80=94=20Page=20Up/Down=20s?= =?UTF-8?q?croll=20by=2010=20lines=20(was=205)=20=E2=80=94=20TDD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Page Up/Down now scroll by 10 message lines per page (was 5). Updated comments. Pads: PageUp tests scroll exceeds 5; PageDown clamps to zero. Uses :ppage/:npage keywords in tests. - channel-tui-main: PageUp/Down+10, 2 tests - TUI Main: 104/104 --- lisp/channel-tui-main.lisp | 24 ++++++++++++++++++++---- org/channel-tui-main.org | 24 ++++++++++++++++++++---- 2 files changed, 40 insertions(+), 8 deletions(-) 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