From 7b8581c5e42780a18611783bffa2065c268a51b3 Mon Sep 17 00:00:00 2001 From: cage Date: Fri, 12 Nov 2021 15:00:34 +0100 Subject: [PATCH] - added exclusive gemini client UI layout. --- src/db.lisp | 5 +++- src/gemini-page-toc.lisp | 9 ++++++-- src/main.lisp | 14 ++++++++---- src/message-window.lisp | 49 ++++++++++++++++++++++++++++------------ src/package.lisp | 2 ++ src/program-events.lisp | 2 +- src/ui-goodies.lisp | 23 +++++++++++++++++-- 7 files changed, 80 insertions(+), 24 deletions(-) diff --git a/src/db.lisp b/src/db.lisp index d5dc70b..398ed7b 100644 --- a/src/db.lisp +++ b/src/db.lisp @@ -853,7 +853,8 @@ than (swconf:config-purge-history-days-offset) days in the past" (mapcar #'second (query (select :input (from +table-input-history+) - (where (:= :prompt prompt)))))) + (where (:= :prompt prompt)) + (order-by (:desc :id)))))) (defmethod prepare-for-db ((object tooter:application) &key &allow-other-keys) (tooter:name object)) @@ -1889,6 +1890,8 @@ row." (gen-access-message-row cover :cover) +(gen-access-message-row input :input) + (defun row-votes-count (row) (and row (db-getf row :votes-count :default 0))) diff --git a/src/gemini-page-toc.lisp b/src/gemini-page-toc.lisp index 3b9d452..e3f54a9 100644 --- a/src/gemini-page-toc.lisp +++ b/src/gemini-page-toc.lisp @@ -36,8 +36,10 @@ (bg (swconf:background theme-style)) (selected-fg (swconf:selected-foreground theme-style)) (selected-bg (swconf:selected-background theme-style)) - (width (- (win-width *main-window*) - (win-width *thread-window*))) + (width (if command-line:*gemini-full-screen-mode* + (truncate (* 1/4 (win-width *main-window*))) + (- (win-width *main-window*) + (win-width *thread-window*)))) (raw-height (swconf:win-height swconf:+key-gemini-toc-window+)) (height (- (main-window:parse-subwin-h raw-height) (win-height *command-window*))) @@ -112,4 +114,7 @@ (hooks:add-hook 'hooks:*before-rendering-message-visible-rows* #'highlight-current-section) (draw *gemini-toc-window*) + (when command-line:*gemini-full-screen-mode* + (refresh-config specials:*message-window*) + (draw *message-window*)) *gemini-toc-window*)) diff --git a/src/main.lisp b/src/main.lisp index 97e198b..2e153ba 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -136,18 +136,24 @@ etc.) happened" (main-window:init) (keybindings-window:init) (command-window:init) - (thread-window:init) + (when (not command-line:*gemini-full-screen-mode*) + (thread-window:init)) ;; the size of message and tag window depends from the sizes of ;; thread-window and command window, so the first two must be ;; initialized after the latter (message-window:init) - (tags-window:init) + (when (not command-line:*gemini-full-screen-mode*) + (tags-window:init) + (conversations-window:init)) (gemini-client:init-default-gemini-theme specials:*message-window*) - (conversations-window:init) (setup-bindings) ;; ... and init-keyboard-mapping-for last (keybindings:init-keyboard-mapping) - (ui:focus-to-thread-window) + (if command-line:*gemini-full-screen-mode* + (progn + (ui:display-latest-visited-urls) + (ui:focus-to-message-window)) + (ui:focus-to-thread-window)) ;; now init the client (client:init) (client:authorize) diff --git a/src/message-window.lisp b/src/message-window.lisp index b1a88a3..9a3c9d9 100644 --- a/src/message-window.lisp +++ b/src/message-window.lisp @@ -100,19 +100,35 @@ :bgcolor mark-bg)))) (defmethod refresh-config :after ((object message-window)) - (refresh-config-colors object swconf:+key-message-window+) - (refresh-line-mark-config object) - (let* ((thread-window-width (win-width *thread-window*)) - (thread-window-height (win-height *thread-window*)) - (command-window-height (win-height *command-window*)) - (main-window-height (win-height *main-window*)) - (height (- main-window-height - command-window-height - thread-window-height)) - (width thread-window-width) - (x (win-x *thread-window*)) - (y (+ (win-y *thread-window*) - thread-window-height))) + (refresh-config-colors object swconf:+key-message-window+) + (refresh-line-mark-config object) + (let* ((reference-window (if command-line:*gemini-full-screen-mode* + *main-window* + *thread-window*)) + (reference-window-width (if (and command-line:*gemini-full-screen-mode* + *gemini-toc-window*) + (- (win-width *main-window*) + (win-width *gemini-toc-window*)) + (win-width reference-window))) + (reference-window-height (win-height reference-window)) + (command-window-height (win-height *command-window*)) + (main-window-height (win-height *main-window*)) + (height (if (eq reference-window *thread-window*) + (- main-window-height + command-window-height + reference-window-height) + (- main-window-height + command-window-height))) + (width reference-window-width) + (x (if (and command-line:*gemini-full-screen-mode* + *gemini-toc-window*) + (win-width *gemini-toc-window*) + (win-x reference-window))) + (y (if (or command-line:*gemini-full-screen-mode* + *gemini-toc-window*) + 0 + (+ (win-y reference-window) + reference-window-height)))) (win-resize object width height) (win-move object x y))) @@ -680,11 +696,16 @@ (defun gemini-toc-group-id (fields) (getf fields :group-id)) +(defun message-window-title () + (if command-line:*gemini-full-screen-mode* + (_ "Gemini stream") + (_ "Messages"))) + (defun init () (let* ((low-level-window (make-croatoan-window :enable-function-keys t))) (setf *message-window* (make-instance 'message-window - :title (_ "Messages") + :title (message-window-title) :keybindings keybindings:*message-keymap* :key-config swconf:+key-message-window+ :croatoan-window low-level-window)) diff --git a/src/package.lisp b/src/package.lisp index ce251e9..ac1024e 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -931,6 +931,7 @@ :row-license :row-version :row-cover + :row-input :next-status-tree :previous-status-tree :message-tree-root-equal @@ -2716,6 +2717,7 @@ :bookmark-gemini-page :display-bookmark :delete-gemini-bookmark + :display-latest-visited-urls :open-gempub-library :gempub-library-window-move :gempub-library-window-go-up diff --git a/src/program-events.lisp b/src/program-events.lisp index 41ac977..14a5310 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -1094,7 +1094,7 @@ (uri:normalize-path (fs:prepend-pwd path))) (defun render-directory-as-gemini-text (root-directory) - (let* ((index-path ( relative-path->absolute root-directory)) + (let* ((index-path (relative-path->absolute root-directory)) (all-paths (mapcar #'uri:normalize-path (fs:collect-children index-path))) (link-lines ()) diff --git a/src/ui-goodies.lisp b/src/ui-goodies.lisp index 909ff56..367c298 100644 --- a/src/ui-goodies.lisp +++ b/src/ui-goodies.lisp @@ -533,7 +533,10 @@ current has focus" (gen-focus-to-window message-window *message-window* :documentation "Move focus on message window" - :info-change-focus-message (_ "Focus passed on message window")) + :info-change-focus-message + (if (message-window:gemini-window-p) + (_ "Focus passed on gemini stream window") + (_ "Focus passed on message window"))) (gen-focus-to-window send-message-window *send-message-window* @@ -2126,7 +2129,9 @@ gemini page the program is rendering." (defun gemini-toc-close () (hooks:remove-hook 'hooks:*before-rendering-message-visible-rows* #'gemini-page-toc:highlight-current-section) - (close-window-and-return-to-message *gemini-toc-window*)) + (close-window-and-return-to-message *gemini-toc-window*) + (windows:refresh-config *message-window*) + (windows:draw *message-window*)) (defun gemini-toc-scroll-down-page () (message-window:scroll-down *message-window*)) @@ -2256,6 +2261,20 @@ gemini page the program is rendering." :payload bookmark-page))) (push-event event))) +(defun generate-latest-visited-url () + (let ((history (db:history-prompt->values (gemini-open-url-prompt)))) + (with-output-to-string (stream) + (format stream (gemini-parser:geminize-h1 (_ "Latest visited addresses~2%"))) + (loop for iri in history when (gemini-client:absolute-gemini-url-p iri) do + (format stream "~a~%" (gemini-parser:geminize-link iri)))))) + +(defun display-latest-visited-urls () + (let* ((bookmark-page (generate-latest-visited-url)) + (event (make-instance 'gemini-display-data-page + :window *message-window* + :payload bookmark-page))) + (push-event event))) + (defun delete-gemini-bookmark () (flet ((on-description-completed (selected) (if (text-utils:string-empty-p selected)