v0.8.0: tangle to XDG (~/.local/share/cl-tty/), remove stale memex .lisp files
This commit is contained in:
@@ -50,7 +50,7 @@ duration. They stack in the top-right corner.
|
||||
The ~cl-tty.dialog~ package uses the backend, input, and select
|
||||
subsystems. All public symbols are exported for user convenience.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog-package.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog-package.lisp
|
||||
;;; dialog-package.lisp — Package definition for cl-tty.dialog
|
||||
|
||||
(defpackage :cl-tty.dialog
|
||||
@@ -87,7 +87,7 @@ The active dialog stack. ~push-dialog~ conses onto this list;
|
||||
should bind its own instance so multiple screens can have independent
|
||||
dialog states.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(in-package :cl-tty.dialog)
|
||||
|
||||
(defvar *dialog-stack* nil
|
||||
@@ -100,7 +100,7 @@ List of active toast notifications. ~toast~ pushes, ~dismiss-toast~
|
||||
removes by identity. The render loop walks this list to draw toasts in
|
||||
the top-right corner.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defvar *toasts* nil
|
||||
"List of active toast notifications.")
|
||||
#+END_SRC
|
||||
@@ -111,7 +111,7 @@ The core dialog class stores a title, a size preset, the content
|
||||
component to render inside the panel, and an optional ~:on-dismiss~
|
||||
callback invoked when the dialog is popped.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defclass dialog ()
|
||||
((title :initarg :title :accessor dialog-title)
|
||||
(size :initarg :size :initform :medium :accessor dialog-size)
|
||||
@@ -125,7 +125,7 @@ Converts a size keyword (~:small~, ~:medium~, ~:large~) to pixel
|
||||
dimensions. Accepts optional ~max-w~ / ~max-h~ to clamp the result to
|
||||
terminal bounds, preventing off-screen overflow (fixed in v1.0.0).
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun dialog-size-pixels (size &optional (max-w 80) (max-h 24))
|
||||
(multiple-value-bind (dw dh)
|
||||
(case size
|
||||
@@ -142,7 +142,7 @@ Renders a dialog: draws a dimmed full-screen backdrop using
|
||||
~draw-rect~, then draws the bordered dialog panel centered on screen.
|
||||
Content is rendered via ~draw-text~ inside the panel area.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun render-dialog (dialog screen w h)
|
||||
(multiple-value-bind (dw dh) (dialog-size-pixels (dialog-size dialog) w h)
|
||||
(let ((x (floor (- w dw) 2))
|
||||
@@ -163,7 +163,7 @@ Content is rendered via ~draw-text~ inside the panel area.
|
||||
|
||||
Pushes a dialog onto =*dialog-stack*=. Returns the dialog for chaining.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun push-dialog (dialog)
|
||||
(push dialog *dialog-stack*)
|
||||
dialog)
|
||||
@@ -174,7 +174,7 @@ Pushes a dialog onto =*dialog-stack*=. Returns the dialog for chaining.
|
||||
Pops the top dialog from the stack. If an ~:on-dismiss~ callback is
|
||||
set on the dialog, it is called before returning.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun pop-dialog ()
|
||||
(when *dialog-stack*
|
||||
(let ((dialog (pop *dialog-stack*)))
|
||||
@@ -194,7 +194,7 @@ Simple alert with title, message, and an OK button. The button is a
|
||||
~select~ with a single "OK" option. Dismissing fires ~pop-dialog~ on
|
||||
both selection and backdrop dismiss.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun alert-dialog (title message)
|
||||
(make-instance 'dialog
|
||||
:title title
|
||||
@@ -210,7 +210,7 @@ both selection and backdrop dismiss.
|
||||
Confirm dialog with Yes/No buttons. Returns ~:yes~ or ~:no~ via the
|
||||
~on-yes~/~on-no~ callbacks. The dialog auto-dismisses on selection.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun confirm-dialog (title message &key on-yes on-no)
|
||||
(make-instance 'dialog
|
||||
:title title
|
||||
@@ -230,7 +230,7 @@ Confirm dialog with Yes/No buttons. Returns ~:yes~ or ~:no~ via the
|
||||
Modal wrapper around the ~select~ component. Presents a list of options
|
||||
and calls ~on-select~ with the chosen value after dismissing.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun select-dialog (title options &key on-select)
|
||||
(make-instance 'dialog
|
||||
:title title
|
||||
@@ -247,7 +247,7 @@ and calls ~on-select~ with the chosen value after dismissing.
|
||||
Modal wrapper around ~text-input~. Shows a text input field inside the
|
||||
dialog and calls ~on-submit~ with the entered value after dismissing.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun prompt-dialog (title &key on-submit)
|
||||
(make-instance 'dialog
|
||||
:title title
|
||||
@@ -268,7 +268,7 @@ has a message and a variant that determines its color (~:info~,
|
||||
|
||||
Lightweight class storing the message text and variant keyword.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defclass toast ()
|
||||
((message :initarg :message :accessor toast-message)
|
||||
(variant :initarg :variant :initform :info :accessor toast-variant)))
|
||||
@@ -280,7 +280,7 @@ Draws a toast in the top-right corner of the screen. The message is
|
||||
truncated to 60 columns with an ellipsis if necessary. The background
|
||||
color reflects the variant.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun render-toast (toast screen w)
|
||||
(let* ((msg (toast-message toast))
|
||||
(variant (toast-variant toast))
|
||||
@@ -302,7 +302,7 @@ Fire-and-forget toast notification. Creates a ~toast~ instance, pushes
|
||||
it onto =*toasts*~, and optionally schedules auto-dismissal via
|
||||
~dismiss-toast~ when ~duration~ is positive.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun toast (message &key (variant :info) (duration 0))
|
||||
(let ((toast (make-instance 'toast :message message :variant variant)))
|
||||
(push toast *toasts*)
|
||||
@@ -315,7 +315,7 @@ it onto =*toasts*~, and optionally schedules auto-dismissal via
|
||||
Removes a toast from =*toasts*~ by identity (~remove~ with default
|
||||
~:test #'eql~ compares by pointer for CLOS objects).
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/dialog.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/dialog.lisp
|
||||
(defun dismiss-toast (toast)
|
||||
(setf *toasts* (remove toast *toasts*)))
|
||||
#+END_SRC
|
||||
@@ -327,7 +327,7 @@ interaction.
|
||||
|
||||
** Test package and suite
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/dialog-tests.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/dialog-tests.lisp
|
||||
;;; dialog-tests.lisp — Tests for cl-tty.dialog
|
||||
|
||||
(defpackage :cl-tty-dialog-test
|
||||
@@ -343,7 +343,7 @@ interaction.
|
||||
|
||||
Basic dialog instantiation — verifies ~make-instance~ and accessors.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/dialog-tests.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/dialog-tests.lisp
|
||||
(def-test dialog-create ()
|
||||
(let ((d (make-instance 'dialog :title "Test")))
|
||||
(is-true (typep d 'dialog))
|
||||
@@ -354,7 +354,7 @@ Basic dialog instantiation — verifies ~make-instance~ and accessors.
|
||||
|
||||
~dialog-size-pixels~ returns the correct dimensions for ~:small~.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/dialog-tests.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/dialog-tests.lisp
|
||||
(def-test dialog-size-small ()
|
||||
(multiple-value-bind (w h) (dialog-size-pixels :small)
|
||||
(is (= 40 w))
|
||||
@@ -365,7 +365,7 @@ Basic dialog instantiation — verifies ~make-instance~ and accessors.
|
||||
|
||||
~dialog-size-pixels~ returns the correct dimensions for ~:medium~.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/dialog-tests.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/dialog-tests.lisp
|
||||
(def-test dialog-size-medium ()
|
||||
(multiple-value-bind (w h) (dialog-size-pixels :medium)
|
||||
(is (= 60 w))
|
||||
@@ -377,7 +377,7 @@ Basic dialog instantiation — verifies ~make-instance~ and accessors.
|
||||
Verifies stack operations: push adds to =*dialog-stack*~, pop removes
|
||||
the top element.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/dialog-tests.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/dialog-tests.lisp
|
||||
(def-test dialog-push-pop ()
|
||||
(let ((*dialog-stack* nil))
|
||||
(push-dialog (make-instance 'dialog :title "D1"))
|
||||
@@ -392,7 +392,7 @@ the top element.
|
||||
|
||||
Verifies that ~toast~ pushes onto =*toasts*~.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/dialog-tests.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/dialog-tests.lisp
|
||||
(def-test toast-create ()
|
||||
(let ((*toasts* nil))
|
||||
(toast "Hello" :variant :info :duration 0)
|
||||
@@ -403,7 +403,7 @@ Verifies that ~toast~ pushes onto =*toasts*~.
|
||||
|
||||
Verifies that ~dismiss-toast~ removes the toast from =*toasts*~.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../tests/dialog-tests.lisp
|
||||
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/tests/dialog-tests.lisp
|
||||
(def-test toast-dismiss ()
|
||||
(let ((*toasts* (list (make-instance 'toast :message "T" :variant :info))))
|
||||
(dismiss-toast (first *toasts*))
|
||||
|
||||
Reference in New Issue
Block a user