From 0e9c521fc156a20dd1c7e868ccf49f0629366e2a Mon Sep 17 00:00:00 2001 From: cage Date: Fri, 8 Apr 2022 17:07:48 +0200 Subject: [PATCH] - ensured only an instance of gemini TOC, gemini link and chat window could exixts. --- src/gemini-page-toc.lisp | 1 + src/open-message-link-window.lisp | 4 ++++ src/package.lisp | 1 + src/windows.lisp | 8 +++++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gemini-page-toc.lisp b/src/gemini-page-toc.lisp index fb2d3b1..e774419 100644 --- a/src/gemini-page-toc.lisp +++ b/src/gemini-page-toc.lisp @@ -100,6 +100,7 @@ (defun open-toc-window (gemini-window) (let* ((low-level-window (make-croatoan-window :enable-function-keys t))) + (maybe-close-window *gemini-toc-window*) (setf *gemini-toc-window* (make-instance 'gemini-toc-window :title (_ "Table of contents") diff --git a/src/open-message-link-window.lisp b/src/open-message-link-window.lisp index b4285bc..e88b4e9 100644 --- a/src/open-message-link-window.lisp +++ b/src/open-message-link-window.lisp @@ -197,7 +197,10 @@ (ui:error-message (_ "Invalid regular expression"))))) (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))) + (maybe-close-window *open-message-link-window*) (setf *open-message-link-window* (make-instance 'open-gemini-document-link-window :center-position center-position @@ -284,6 +287,7 @@ (defun init-chat-links (links) (let* ((low-level-window (make-croatoan-window :enable-function-keys t))) + (maybe-close-window *open-message-link-window*) (setf *open-message-link-window* (make-instance 'open-chat-document-link-window :top-row-padding 0 diff --git a/src/package.lisp b/src/package.lisp index 5d71357..992fccb 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1788,6 +1788,7 @@ :win-fgcolor :win-refresh :win-close + :maybe-close-window :win-raise-to-top :win-move-cursor :win-move-cursor-direction diff --git a/src/windows.lisp b/src/windows.lisp index c7aa0ff..5f004d7 100644 --- a/src/windows.lisp +++ b/src/windows.lisp @@ -99,7 +99,7 @@ (win-show object)) (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) `(with-accessors ((,slot croatoan-window)) ,window @@ -167,6 +167,12 @@ height, position and so on)" (stack-remove-element *window-stack* 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) (stack-raise-to-top *window-stack* window))