Implement Qt global line numbers mode
ober
c8954f201d0eed9d710fcfac8ef7a7e967790ac3
--- a/src/jerboa-emacs/qt/commands-parity5.ss +++ b/src/jerboa-emacs/qt/commands-parity5.ss @@ -1343,6 +1343,11 @@ (if enabled? "Blink cursor OFF" "Blink cursor ON")))) +(def (cmd-global-display-line-numbers-mode app) + "Toggle line-number margins across the current Qt frame." + (cmd-toggle-line-numbers app) + (hash-put! *qt-toggle-states* 'global-display-line-numbers-mode *line-numbers-visible*) + (hash-put! *qt-toggle-states* 'toggle-global-display-line-numbers *line-numbers-visible*)) (def *qt-run-with-timer-counter* 0) (def (next-run-with-timer-name!) @@ -1448,6 +1453,8 @@ (cons 'apheleia-format-buffer cmd-apheleia-format-buffer) (cons 'blink-cursor-mode cmd-blink-cursor-mode) (cons 'toggle-blink-cursor-mode cmd-blink-cursor-mode) + (cons 'global-display-line-numbers-mode cmd-global-display-line-numbers-mode) + (cons 'toggle-global-display-line-numbers cmd-global-display-line-numbers-mode) (cons 'run-with-timer cmd-run-with-timer) (cons 'ibuffer-mark cmd-ibuffer-mark) (cons 'ibuffer-delete cmd-ibuffer-delete) --- a/tests/test-qt-part2.ss +++ b/tests/test-qt-part2.ss @@ -24,6 +24,7 @@ qt-minibuffer-history-select qt-minibuffer-history-for) (jerboa-emacs qt commands) + (only (jerboa-emacs qt commands-edit) *line-numbers-visible*) (only (jerboa-emacs qt commands-core) *so-long-threshold*) (only (jerboa-emacs qt commands-parity5) schedule-user-timer!) (only (jerboa-emacs async) master-timer-tick!) @@ -106,7 +107,7 @@ (loop (+ i 1) (cons (string-append "line " (number->string i) "\n") acc))))) -(display "\n=== Qt Part2 Groups 44-60 ===\n") +(display "\n=== Qt Part2 Groups 44-61 ===\n") (test-case "group44 qt key/mouse fidelity" (check (qt-key-event->string QT_KEY_RETURN 0 "") => "C-m") @@ -289,10 +290,29 @@ (execute-command! app 'toggle-blink-cursor-mode) (check (sci-send ed SCI_GETCARETPERIOD 0) => 500) (check (echo-state-message (app-state-echo app)) => "Blink cursor ON"))) +(test-case "group61 global-display-line-numbers-mode changes margin width" + (let-values (((ed w app) (make-qt-test-app "part2-61"))) + (let ((win (qt-current-window (app-state-frame app))) + (old *line-numbers-visible*)) + (dynamic-wind + (lambda () + (set! *line-numbers-visible* #t) + (qt-line-number-area-set-visible! (qt-edit-window-line-number-area win) #t)) + (lambda () + (check (sci-send ed SCI_GETMARGINWIDTHN 0) => 48) + (execute-command! app 'global-display-line-numbers-mode) + (check (sci-send ed SCI_GETMARGINWIDTHN 0) => 0) + (check (echo-state-message (app-state-echo app)) => "Line numbers OFF") + (execute-command! app 'toggle-global-display-line-numbers) + (check (sci-send ed SCI_GETMARGINWIDTHN 0) => 48) + (check (echo-state-message (app-state-echo app)) => "Line numbers ON")) + (lambda () + (set! *line-numbers-visible* old) + (qt-line-number-area-set-visible! (qt-edit-window-line-number-area win) old)))))) (newline) (let ([total (+ *pass* *fail*)]) - (printf "Part2 results: ~a/~a tests passed (groups 44-60)~n" *pass* total) + (printf "Part2 results: ~a/~a tests passed (groups 44-61)~n" *pass* total) (when (> *fail* 0) (printf "FAILED: ~a test(s)~n" *fail*)) (when (= *fail* 0)