diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index 3c7cea8..33243f9 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -126,10 +126,13 @@ (fit-toc-char-width main-window toc-widget-width))) main-window))) -(defun slurp-gemini-stream (main-window iri stream-wrapper &key - (use-cache t) - (process-function #'identity) - (aborting-function (constantly nil))) +(defun slurp-gemini-stream (main-window iri stream-wrapper + &key + (use-cache t) + (process-function #'identity) + (aborting-function (constantly nil))) + (ev:with-enqueued-process-and-unblock () + (set-focus-to-gemtext main-window)) (enqueue-request-notify-error :gemini-request 1 iri use-cache) (labels ((stream-exausted-p () (let ((status-completed (comm:make-request :gemini-stream-completed-p @@ -160,10 +163,10 @@ 1 ev:+standard-event-priority+ iri) - (ev:with-enqueued-process-and-unblock () - (set-bookmark-button-true main-window)) - (ev:with-enqueued-process-and-unblock () - (set-bookmark-button-false main-window))) + (ev:with-enqueued-process-and-unblock () + (set-bookmark-button-true main-window)) + (ev:with-enqueued-process-and-unblock () + (set-bookmark-button-false main-window))) (ev:with-enqueued-process-and-unblock () (set-gemlog-toolbar-button-appearance main-window iri)) (ev:with-enqueued-process-and-unblock () @@ -1071,12 +1074,6 @@ (gui:bind toc-listbox #$<>$ (toc-callback-clsr main-window)) - (gui:bind gemtext-widget - #$$ - (lambda (e) - (declare (ignore e)) - (gui:configure-mouse-pointer gemtext-widget (gui:find-cursor :xterm)) - (gui:force-focus (gui:root-toplevel)))) (setf (gui:command go-button) (open-iri-clsr main-window t)) (setf (gui:command reload-button) (reload-iri-clsr main-window)) (setf (gui:command back-button) (back-iri-clsr main-window)) @@ -1325,96 +1322,99 @@ (setf (gui:text (iri-entry (tool-bar main-window))) text) (gui:clear-selection entry))) +(defun set-focus-to-gemtext (main-window) + (gui:focus (gui:inner-text (gemtext-widget main-window)))) + (defun get-address-bar-text (main-window) (trim-blanks (gui:text (iri-entry (tool-bar main-window))))) (defun initialize-keybindings (main-window) - (gui:bind (gui:root-toplevel) - (client-configuration:get-keybinding :quit) - (lambda (e) - (declare (ignore e)) - (menu:quit))) - (gui:bind (gui:root-toplevel) - (client-configuration:get-keybinding :search) - (lambda (e) - (declare (ignore e)) - (funcall (menu:show-search-frame-clsr main-window))) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:get-keybinding :stream) - (lambda (e) - (declare (ignore e)) - (menu:show-streams)) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:get-keybinding :certificates) - (lambda (e) - (declare (ignore e)) - (menu:show-certificates)) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:config-keybinding-tour-manage) - (lambda (e) - (declare (ignore e)) - (menu:show-tour)) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:get-keybinding :gemlog) - (lambda (e) - (declare (ignore e)) - (menu:manage-gemlogs)) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:get-keybinding :about) - (lambda (e) - (declare (ignore e)) - (menu:help-about)) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:get-keybinding :type-address) - (lambda (e) - (declare (ignore e)) - (let* ((autocomplete-entry (iri-entry (tool-bar main-window))) - (entry (nodgui.mw:autocomplete-entry-widget autocomplete-entry))) - (gui:focus entry) - (gui:set-selection entry 0 :end))) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:config-keybinding-tour-shuffle) - (lambda (e) - (declare (ignore e)) - (client-tour-window:enqueue-shuffle-tour)) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:config-keybinding-tour-next) - (lambda (e) - (declare (ignore e)) - (funcall (tour-visit-next-iri-clsr main-window))) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:get-keybinding :back) - (lambda (e) - (declare (ignore e)) - (funcall (back-iri-clsr main-window))) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:get-keybinding :up) - (lambda (e) - (declare (ignore e)) - (funcall (up-iri-clsr main-window))) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:config-keybinding-bookmark-toggle) - (lambda (e) - (declare (ignore e)) - (funcall (toggle-bookmark-iri-clsr main-window))) - :exclusive t) - (gui:bind (gui:root-toplevel) - (client-configuration:config-keybinding-bookmark-show) - (lambda (e) - (declare (ignore e)) - (funcall (menu:show-bookmarks-clsr main-window))) - :exclusive t)) + (let ((inner-gemtext-widget (gui:inner-text (gemtext-widget main-window)))) + (gui:bind inner-gemtext-widget + (client-configuration:get-keybinding :quit) + (lambda (e) + (declare (ignore e)) + (menu:quit))) + (gui:bind inner-gemtext-widget + (client-configuration:get-keybinding :search) + (lambda (e) + (declare (ignore e)) + (funcall (menu:show-search-frame-clsr main-window))) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:get-keybinding :stream) + (lambda (e) + (declare (ignore e)) + (menu:show-streams)) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:get-keybinding :certificates) + (lambda (e) + (declare (ignore e)) + (menu:show-certificates)) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:config-keybinding-tour-manage) + (lambda (e) + (declare (ignore e)) + (menu:show-tour)) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:get-keybinding :gemlog) + (lambda (e) + (declare (ignore e)) + (menu:manage-gemlogs)) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:get-keybinding :about) + (lambda (e) + (declare (ignore e)) + (menu:help-about)) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:get-keybinding :type-address) + (lambda (e) + (declare (ignore e)) + (let* ((autocomplete-entry (iri-entry (tool-bar main-window))) + (entry (nodgui.mw:autocomplete-entry-widget autocomplete-entry))) + (gui:focus entry) + (gui:set-selection entry 0 :end))) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:config-keybinding-tour-shuffle) + (lambda (e) + (declare (ignore e)) + (client-tour-window:enqueue-shuffle-tour)) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:config-keybinding-tour-next) + (lambda (e) + (declare (ignore e)) + (funcall (tour-visit-next-iri-clsr main-window))) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:get-keybinding :back) + (lambda (e) + (declare (ignore e)) + (funcall (back-iri-clsr main-window))) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:get-keybinding :up) + (lambda (e) + (declare (ignore e)) + (funcall (up-iri-clsr main-window))) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:config-keybinding-bookmark-toggle) + (lambda (e) + (declare (ignore e)) + (funcall (toggle-bookmark-iri-clsr main-window))) + :exclusive t) + (gui:bind inner-gemtext-widget + (client-configuration:config-keybinding-bookmark-show) + (lambda (e) + (declare (ignore e)) + (funcall (menu:show-bookmarks-clsr main-window)))))) (defun init-main-window (starting-iri) (setf gui:*debug-tk* nil)