Every function, defclass, defstruct, defgeneric, defmethod, defmacro, defvar, and defparameter in every org file now has its own #+BEGIN_SRC block with literate prose above it explaining the design reasoning. Block counts before → after: package.org: 1 → 7 container-package.org: 1 → 1 (prose expanded) dirty.org: 4 → 6 render.org: 10 → 25 theme.org: 6 → 19 box-renderable.org: 9 → 29 scrollbox.org: 8 → 26 tabbar.org: 5 → 10 backend-protocol.org: 8 → 66 modern-backend.org: 17 → 53 detection.org: 4 → 6 layout-engine.org: 9 → 36 framebuffer.org: 8 → 37 markdown-renderer.org:13 → 38 dialog.org: 17 → 23 (merged dual structure) mouse.org: 4 → 25 select.org: 12 → 30 slot.org: 4 → 12 text-input.org: 11 → 53 Total: ~153 blocks → ~502 blocks Bugs fixed during restructuring: - render.org: stray π character typo (backenπd → backend) - modern-backend.org: sgr-attr missing closing paren + #+END_SRC - detection.org: invalid #\Esc character reference - select.org: extra closing paren in select-visible-options All 13 test suites pass at 100%.
48 lines
1.7 KiB
Common Lisp
48 lines
1.7 KiB
Common Lisp
(defpackage :cl-tty-mouse-test (:use :cl :cl-tty.mouse :fiveam))
|
|
(in-package :cl-tty-mouse-test)
|
|
|
|
(def-suite mouse-suite :description "Mouse tests")
|
|
(in-suite mouse-suite)
|
|
|
|
(def-test mouse-mixin-create ()
|
|
(let ((m (make-instance 'mouse-mixin)))
|
|
(is-true (typep m 'mouse-mixin))))
|
|
|
|
(def-test mouse-hit-test-point ()
|
|
"hit-test returns nil when no component has position slots bound"
|
|
(let ((obj (make-instance 'mouse-mixin)))
|
|
(is-false (hit-test obj 0 0))
|
|
(is-false (hit-test obj 100 100))))
|
|
|
|
(def-test selection-set-and-get ()
|
|
(setf cl-tty.mouse::*selection* (make-selection :text "hello"))
|
|
(is (equal "hello" (get-selection))))
|
|
|
|
(def-test start-selection-initializes-state ()
|
|
(start-selection 5 10)
|
|
(is-true (selection-active-p))
|
|
(is (equal '(5 . 10) cl-tty.mouse::*selection-start*))
|
|
(is (equal '(5 . 10) cl-tty.mouse::*selection-end*))
|
|
(setf cl-tty.mouse::*selection-active* nil
|
|
cl-tty.mouse::*selection-start* nil
|
|
cl-tty.mouse::*selection-end* nil))
|
|
|
|
(def-test update-selection-moves-end ()
|
|
(start-selection 0 0)
|
|
(update-selection 3 7)
|
|
(is (equal '(3 . 7) cl-tty.mouse::*selection-end*))
|
|
(setf cl-tty.mouse::*selection-active* nil
|
|
cl-tty.mouse::*selection-start* nil
|
|
cl-tty.mouse::*selection-end* nil))
|
|
|
|
(def-test finalize-selection-extracts-text ()
|
|
(let* ((fb-be (cl-tty.rendering:make-framebuffer-backend))
|
|
(fb (cl-tty.rendering:fb-framebuffer fb-be)))
|
|
(cl-tty.backend:draw-text fb-be 0 0 "hello" nil nil)
|
|
(cl-tty.backend:draw-text fb-be 0 1 "world" nil nil)
|
|
(start-selection 0 0)
|
|
(update-selection 4 1)
|
|
(let ((text (finalize-selection fb)))
|
|
(is (equal "hello
|
|
world" text)))))
|