summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre A. Gomes <andremegafone@gmail.com>2024-09-18 11:19:52 +0300
committerAndre A. Gomes <andremegafone@gmail.com>2024-09-18 11:35:01 +0300
commitd719c2491d9e7ea75457dcfdcacb24865f7dc1c5 (patch)
treedd71af6899e50ec61b6c69ae60590597d15b5105
parentf362b2a006c20e49bd338131fd795aa0dc157913 (diff)
Refactor window title.
-rw-r--r--source/browser.lisp20
-rw-r--r--source/window.lisp9
2 files changed, 6 insertions, 23 deletions
diff --git a/source/browser.lisp b/source/browser.lisp
index 612438b15..69b121a1b 100644
--- a/source/browser.lisp
+++ b/source/browser.lisp
@@ -437,24 +437,8 @@ restored."
(-> set-window-title (&optional window) *)
(export-always 'set-window-title)
(defun set-window-title (&optional (window (current-window)))
- "Set current window title to the return value of (titler window). "
- (setf (ffi-window-title window) (funcall (titler window) window)))
-
-(-> window-default-title (window) string)
-(export-always 'window-default-title)
-(defun window-default-title (window)
- "Return a window title in the form 'Nyxt - URL'.
-If Nyxt was started from a REPL, use 'Nyxt REPL - URL' instead.
-This is useful to tell REPL instances from binary ones."
- (let* ((buffer (active-buffer window))
- (url (url buffer))
- (title (title buffer)))
- (setf title (if (str:emptyp title) "" title))
- (setf url (if (url-empty-p url) "<no url/name>" (render-url url)))
- (the (values string &optional)
- (str:concat "Nyxt" (when *run-from-repl-p* " REPL") " - "
- title (unless (str:emptyp title) " - ")
- url))))
+ "Set WINDOW title."
+ (setf (ffi-window-title window) (titler window)))
(-> open-urls ((maybe (cons quri:uri *))) *)
(defun open-urls (urls)
diff --git a/source/window.lisp b/source/window.lisp
index b089ca5e5..fa4827d72 100644
--- a/source/window.lisp
+++ b/source/window.lisp
@@ -18,11 +18,6 @@ Should be redefined by the renderer."))
(new-id)
:type unsigned-byte
:documentation "Unique identifier for a window.")
- (titler
- 'window-default-title
- :type (or function sym:function-symbol)
- :documentation "Return the title of the window.
-It's a function of the window argument that returns the title as a string.")
(active-buffer
:reader active-buffer
:export nil
@@ -94,6 +89,10 @@ The handlers take the window as argument."))
(print-unreadable-object (window stream :type t :identity t)
(format stream "~a" (id window))))
+(defmethod titler ((window window))
+ "Return the title of WINDOW."
+ (str:concat (title (active-buffer window)) " - Nyxt"))
+
(defmethod window-add-panel-buffer ((window window) (buffer panel-buffer) side)
"Add a panel buffer to a window. Side can either be :right or :left."
(pushnew buffer (panel-buffers window))