1
0
Fork 0

- ensured only an instance of gemini TOC, gemini link and chat window could exixts.

This commit is contained in:
cage 2022-04-08 17:07:48 +02:00
parent a1ec070d03
commit 0e9c521fc1
4 changed files with 13 additions and 1 deletions

View File

@ -100,6 +100,7 @@
(defun open-toc-window (gemini-window) (defun open-toc-window (gemini-window)
(let* ((low-level-window (make-croatoan-window :enable-function-keys t))) (let* ((low-level-window (make-croatoan-window :enable-function-keys t)))
(maybe-close-window *gemini-toc-window*)
(setf *gemini-toc-window* (setf *gemini-toc-window*
(make-instance 'gemini-toc-window (make-instance 'gemini-toc-window
:title (_ "Table of contents") :title (_ "Table of contents")

View File

@ -197,7 +197,10 @@
(ui:error-message (_ "Invalid regular expression"))))) (ui:error-message (_ "Invalid regular expression")))))
(defun init-gemini-links (links &key (title (_ "Links")) (center-position nil)) (defun init-gemini-links (links &key (title (_ "Links")) (center-position nil))
"Note that no more that one link window can be presents on the
screen."
(let* ((low-level-window (make-croatoan-window :enable-function-keys t))) (let* ((low-level-window (make-croatoan-window :enable-function-keys t)))
(maybe-close-window *open-message-link-window*)
(setf *open-message-link-window* (setf *open-message-link-window*
(make-instance 'open-gemini-document-link-window (make-instance 'open-gemini-document-link-window
:center-position center-position :center-position center-position
@ -284,6 +287,7 @@
(defun init-chat-links (links) (defun init-chat-links (links)
(let* ((low-level-window (make-croatoan-window :enable-function-keys t))) (let* ((low-level-window (make-croatoan-window :enable-function-keys t)))
(maybe-close-window *open-message-link-window*)
(setf *open-message-link-window* (setf *open-message-link-window*
(make-instance 'open-chat-document-link-window (make-instance 'open-chat-document-link-window
:top-row-padding 0 :top-row-padding 0

View File

@ -1788,6 +1788,7 @@
:win-fgcolor :win-fgcolor
:win-refresh :win-refresh
:win-close :win-close
:maybe-close-window
:win-raise-to-top :win-raise-to-top
:win-move-cursor :win-move-cursor
:win-move-cursor-direction :win-move-cursor-direction

View File

@ -99,7 +99,7 @@
(win-show object)) (win-show object))
(defmethod print-object ((object wrapper-window) stream) (defmethod print-object ((object wrapper-window) stream)
(print-unreadable-object (object stream :type t :identity nil))) (print-unreadable-object (object stream :type t :identity t)))
(defmacro with-croatoan-window ((slot window) &body body) (defmacro with-croatoan-window ((slot window) &body body)
`(with-accessors ((,slot croatoan-window)) ,window `(with-accessors ((,slot croatoan-window)) ,window
@ -167,6 +167,12 @@ height, position and so on)"
(stack-remove-element *window-stack* window) (stack-remove-element *window-stack* window)
(close croatoan-window))) (close croatoan-window)))
(defun maybe-close-window (win)
"close `win' if it is a wrapper-window"
(and win
(typep win 'wrapper-window)
(win-close win)))
(defun win-raise-to-top (window) (defun win-raise-to-top (window)
(stack-raise-to-top *window-stack* window)) (stack-raise-to-top *window-stack* window))