v0.8.0: tangle to XDG (~/.local/share/cl-tty/), remove stale memex .lisp files
This commit is contained in:
@@ -32,7 +32,7 @@ implementation. It re-exports the public API symbols that consumers
|
||||
(~cl-tty.core~, user applications) rely on without pulling in
|
||||
implementation details.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse-package.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse-package.lisp :noweb no
|
||||
(defpackage :cl-tty.mouse
|
||||
(:use :cl :cl-tty.layout :cl-tty.input :cl-tty.box :cl-tty.rendering)
|
||||
(:export
|
||||
@@ -51,7 +51,7 @@ implementation details.
|
||||
|
||||
Standard boilerplate to enter the package defined above.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(in-package :cl-tty.mouse)
|
||||
#+END_SRC
|
||||
|
||||
@@ -63,7 +63,7 @@ that want mouse support simply inherit from ~mouse-mixin~ alongside
|
||||
their primary superclass. Each slot stores a closure invoked when the
|
||||
corresponding event fires; ~nil~ means "no handler."
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defclass mouse-mixin ()
|
||||
((on-mouse-down :initarg :on-mouse-down :initform nil :accessor on-mouse-down)
|
||||
(on-mouse-up :initarg :on-mouse-up :initform nil :accessor on-mouse-up)
|
||||
@@ -79,7 +79,7 @@ function dispatch because the mapping is one-to-one and never needs
|
||||
CLOS multiple-dispatch. Returns ~nil~ when no handler is bound (the
|
||||
caller can decide whether to bubble the event up).
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun handle-mouse-event (component event)
|
||||
(let* ((type (mouse-event-type event))
|
||||
(handler (case type
|
||||
@@ -98,7 +98,7 @@ innermost matching component wins (front-most in rendering order).
|
||||
yet (no ~layout-node~ bound). This makes hit-testing safe to call
|
||||
mid-render when the tree is partially constructed.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun hit-test (root x y)
|
||||
"Find the deepest component at (X, Y) by testing layout-node bounds.
|
||||
Recurses into component-children to find the innermost match.
|
||||
@@ -131,7 +131,7 @@ process without threading it through the entire component tree. This
|
||||
keeps the API simple for now; a future refactor could store the
|
||||
selection on a per-frame or per-window basis if needed.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defvar *selection* nil)
|
||||
#+END_SRC
|
||||
|
||||
@@ -143,7 +143,7 @@ avoiding name collisions. Using a struct (vs. a class) gives inline
|
||||
accessors and no CLOS overhead, which matters when the selection is
|
||||
read on every render frame.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defstruct (selection (:conc-name sel-))
|
||||
(start-x 0) (start-y 0) (end-x 0) (end-y 0) (text ""))
|
||||
#+END_SRC
|
||||
@@ -153,7 +153,7 @@ read on every render frame.
|
||||
Simple accessor that returns nil when nothing is selected (rather than
|
||||
an empty string), making it easy for callers to test with ~when~.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun get-selection ()
|
||||
(when *selection* (sel-text *selection*)))
|
||||
#+END_SRC
|
||||
@@ -168,7 +168,7 @@ Darwin uses ~pbcopy~. The approach avoids build-time feature detection
|
||||
the common case of a single SBCL binary used across X11 and Wayland
|
||||
sessions.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun copy-to-clipboard (text)
|
||||
#+linux
|
||||
(cond
|
||||
@@ -187,7 +187,7 @@ should draw a highlight overlay. A global flag (rather than threading
|
||||
the drag state through event handlers) mirrors the simplicity of
|
||||
~*selection*~ and makes it trivial to check in rendering code.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defvar *selection-active* nil
|
||||
"T when a drag selection is in progress.")
|
||||
#+END_SRC
|
||||
@@ -198,7 +198,7 @@ Stored as a cons cell ~(X . Y)~ of the mouse-down position. Using a
|
||||
cons (vs. a struct) keeps the imperative mutation simple — ~setf~ with
|
||||
~cons~ is a single expression.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defvar *selection-start* nil
|
||||
"Cons (X . Y) of mouse-down position during drag.")
|
||||
#+END_SRC
|
||||
@@ -209,7 +209,7 @@ Updated on every mouse-move during a drag so the rendering loop can
|
||||
draw the live highlight rectangle between ~*selection-start*~ and
|
||||
~*selection-end*~.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defvar *selection-end* nil
|
||||
"Cons (X . Y) of current mouse position during drag.")
|
||||
#+END_SRC
|
||||
@@ -220,7 +220,7 @@ Initializes all three drag state variables in one call. Both start and
|
||||
end are set to the same position so that before the first mouse-move
|
||||
the "selection" is a zero-width region (which renders as nothing).
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun start-selection (x y)
|
||||
"Begin a drag selection at (X Y)."
|
||||
(setf *selection-start* (cons x y)
|
||||
@@ -234,7 +234,7 @@ Called on every mouse-move event while dragging. Only updates the end
|
||||
position; the start remains fixed from the original mouse-down. The
|
||||
rendering loop reads both globals to draw the highlight rectangle.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun update-selection (x y)
|
||||
"Update the drag selection end position to (X Y)."
|
||||
(setf *selection-end* (cons x y)))
|
||||
@@ -246,7 +246,7 @@ Encapsulates the global flag behind a function so that callers don't
|
||||
need to know the variable name. Returning ~*selection-active*~
|
||||
directly works because it is always ~nil~ or ~T~.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun selection-active-p ()
|
||||
"Return T if a drag selection is in progress."
|
||||
*selection-active*)
|
||||
@@ -260,7 +260,7 @@ framebuffer via ~cl-tty.rendering:extract-text~, stores the result in
|
||||
~*selection*~, and returns the extracted string. The ~fb~ parameter
|
||||
must be the current framebuffer at the time of release.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun finalize-selection (fb)
|
||||
"End the drag selection and extract text from the framebuffer."
|
||||
(setf *selection-active* nil)
|
||||
@@ -283,7 +283,7 @@ Delegates to the rendering layer's ~fb-cell-link-url~ to look up the
|
||||
cell metadata. This indirection keeps mouse code independent of the
|
||||
framebuffer's internal storage format.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun cell-link-at (fb x y)
|
||||
"Return the link URL at (X Y) in framebuffer FB, or nil."
|
||||
(cl-tty.rendering:fb-cell-link-url fb x y))
|
||||
@@ -296,7 +296,7 @@ If ~cell-link-at~ finds a URL, open it with the OS default handler
|
||||
the caller can log or react to the result. The ~:wait nil~ avoids
|
||||
blocking the TTY UI while the browser launches.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/mouse.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/mouse.lisp :noweb no
|
||||
(defun open-link-at (fb x y)
|
||||
"If there is a link URL at (X Y) in FB, open it via xdg-open."
|
||||
(let ((url (cell-link-at fb x y)))
|
||||
@@ -314,7 +314,7 @@ Isolates test symbols in their own package to avoid polluting the
|
||||
production namespace. FiveAM's ~def-suite~ groups all mouse tests
|
||||
under a single name for convenient batch execution.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/mouse-tests.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/mouse-tests.lisp :noweb no
|
||||
(defpackage :cl-tty-mouse-test (:use :cl :cl-tty.mouse :fiveam))
|
||||
(in-package :cl-tty-mouse-test)
|
||||
|
||||
@@ -328,7 +328,7 @@ Verifies that the mixin class can be instantiated and passes a basic
|
||||
typep check. This guards against missing ~:initform~ values or
|
||||
superclass chain issues.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/mouse-tests.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/mouse-tests.lisp :noweb no
|
||||
(def-test mouse-mixin-create ()
|
||||
(let ((m (make-instance 'mouse-mixin)))
|
||||
(is-true (typep m 'mouse-mixin))))
|
||||
@@ -340,7 +340,7 @@ superclass chain issues.
|
||||
for any coordinates. This tests the ~ignore-errors~ guard path in the
|
||||
hit-testing logic.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/mouse-tests.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/mouse-tests.lisp :noweb no
|
||||
(def-test mouse-hit-test-point ()
|
||||
"hit-test returns nil when no component has position slots bound"
|
||||
(let ((obj (make-instance 'mouse-mixin)))
|
||||
@@ -354,7 +354,7 @@ Sets ~*selection*~ directly (simulating a completed drag) and checks
|
||||
that ~get-selection~ returns the expected text. This validates the
|
||||
~selection~ struct accessor chain end-to-end.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/mouse-tests.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/mouse-tests.lisp :noweb no
|
||||
(def-test selection-set-and-get ()
|
||||
(setf cl-tty.mouse::*selection* (make-selection :text "hello"))
|
||||
(is (equal "hello" (get-selection))))
|
||||
@@ -367,7 +367,7 @@ that ~get-selection~ returns the expected text. This validates the
|
||||
resets globals to avoid cross-test contamination (FiveAM does not
|
||||
automatically reset special variables between tests).
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/mouse-tests.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/mouse-tests.lisp :noweb no
|
||||
(def-test start-selection-initializes-state ()
|
||||
(start-selection 5 10)
|
||||
(is-true (selection-active-p))
|
||||
@@ -384,7 +384,7 @@ After ~start-selection~, calling ~update-selection~ must update
|
||||
~*selection-end*~ while leaving ~*selection-start*~ unchanged. This
|
||||
validates the drag-tracking update path.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/mouse-tests.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/mouse-tests.lisp :noweb no
|
||||
(def-test update-selection-moves-end ()
|
||||
(start-selection 0 0)
|
||||
(update-selection 3 7)
|
||||
@@ -401,7 +401,7 @@ simulates a drag selection, and verifies that ~finalize-selection~
|
||||
extracts the correct multi-line string. This exercises the full chain
|
||||
from framebuffer cell storage through coordinate normalization.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/mouse-tests.lisp :noweb no
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/mouse-tests.lisp :noweb no
|
||||
(def-test finalize-selection-extracts-text ()
|
||||
(let* ((fb-be (cl-tty.rendering:make-framebuffer-backend))
|
||||
(fb (cl-tty.rendering:fb-framebuffer fb-be)))
|
||||
|
||||
Reference in New Issue
Block a user