From 6e7dcd7865217698808883762c4609ff6a749038 Mon Sep 17 00:00:00 2001 From: Dan Rasmuson Date: Mon, 25 May 2026 10:27:17 -0500 Subject: [PATCH] mode/document: Add scroll-half-page-{up,down} (C-d/C-u in vi-normal) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vim users expect C-d and C-u to scroll by half a viewport. Nyxt already ships scroll-page-{up,down} and scroll-to-{top,bottom}, but no half-page variant, so the vi-normal keyscheme leaves C-d and C-u unbound. Add scroll-half-page-down and scroll-half-page-up as small wrappers around window.scrollBy(0, ±innerHeight/2), and bind them to C-d / C-u in the document-mode vi-normal keyscheme alongside the existing scroll-page-{up,down} bindings. --- source/mode/document.lisp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/mode/document.lisp b/source/mode/document.lisp index 72c5ab47128..58ff194a9d1 100644 --- a/source/mode/document.lisp +++ b/source/mode/document.lisp @@ -110,7 +110,9 @@ Important pieces of functionality are: "pageup" 'scroll-page-up "C-f" 'scroll-page-down "space" 'scroll-page-down - "pagedown" 'scroll-page-down))))) + "pagedown" 'scroll-page-down + "C-d" 'scroll-half-page-down + "C-u" 'scroll-half-page-up))))) (define-configuration document-buffer ((default-modes (cons 'document-mode %slot-value%)))) @@ -295,6 +297,14 @@ The amount scrolled is determined by the buffer's `horizontal-scroll-distance'." (ps-eval (ps:chain window (scroll-by 0 (- (* (ps:lisp (page-scroll-ratio (current-buffer))) (ps:@ window inner-height))))))) +(define-command scroll-half-page-down () + "Scroll down by half a page height." + (ps-eval (ps:chain window (scroll-by 0 (/ (ps:@ window inner-height) 2))))) + +(define-command scroll-half-page-up () + "Scroll up by half a page height." + (ps-eval (ps:chain window (scroll-by 0 (- (/ (ps:@ window inner-height) 2)))))) + (define-command zoom-page (&key (buffer (current-buffer))) "Zoom in the current buffer." (incf (ffi-buffer-zoom-ratio buffer) (zoom-ratio-step buffer)))