diff --git a/etc/shared.conf b/etc/shared.conf index 4444297..6125c1d 100644 --- a/etc/shared.conf +++ b/etc/shared.conf @@ -229,8 +229,6 @@ open "^((gemini://)|(\\.)|(/)).+gmi$" with "tinmop" open "^((gemini://)|(\\.)|(/)).+sh$" with "tinmop" open ".gpub$" with "tinmop" - - ######################### # ⚠ EXPERIMENTAL ZONE ⚠ # ######################### diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index ebfd7f7..e7113f7 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -418,6 +418,13 @@ (getf response :cached) (getf response :iri))) +(defun render-monospaced-text (main-window lines) + (ev:with-enqueued-process-and-unblock () + (clean-gemtext main-window) + (gui:configure (gemtext-widget main-window) + :font (gui-conf:gemini-preformatted-text-font-configuration)) + (set-text-gemtext main-window lines))) + (defun open-local-path (path main-window &key (force-rendering nil)) (cond ((fs:file-exists-p path) @@ -434,9 +441,7 @@ 1 ev:+standard-event-priority+ path))) - (ev:with-enqueued-process-and-unblock () - (clean-gemtext main-window) - (set-text-gemtext main-window lines))) + (render-monospaced-text main-window lines)) (client-os-utils:open-resource-with-external-program main-window path)))) ((fs:directory-exists-p path) (gui:choose-directory :initial-dir path :parent main-window :mustexist t)) @@ -484,6 +489,21 @@ :query encoded-input :port port)))) +(defun slurp-text-data (main-window iri) + (labels ((maybe-open-if-completed (stream-info support-file) + (if (string-equal (getf stream-info :stream-status) + :completed) + (client-os-utils:open-resource-with-external-program main-window support-file) + (wait-enough-data))) + (wait-enough-data () + (let* ((stream-info (cev:enqueue-request-and-wait-results :gemini-stream-info + 1 + ev:+maximum-event-priority+ + iri)) + (support-file (getf stream-info :support-file))) + (maybe-open-if-completed stream-info support-file)))) + (wait-enough-data))) + (defun slurp-non-text-data (main-window iri) (labels ((maybe-open-if-completed (stream-info support-file) (if (string-equal (getf stream-info :stream-status) @@ -569,23 +589,26 @@ ((gemini-client:header-success-p status-code) (cond ((eq status +stream-status-streaming+) - (if (gemini-client:gemini-file-stream-p meta) - (progn - (maybe-stop-steaming-stream-thread) - (clean-gemtext main-window) - (start-streaming-thread iri - :use-cache nil - :status status - :process-function - (lambda (stream-wrapper lines) - ;; this test ensures that the - ;; collecting events left on - ;; the queue won't be actually - ;; processed, just discarded - (when (not (eq (status stream-wrapper) - +stream-status-canceled+)) - (collect-ir-lines iri main-window lines))))) - (slurp-non-text-data main-window iri))) + (cond + ((gemini-client:gemini-file-stream-p meta) + (maybe-stop-steaming-stream-thread) + (clean-gemtext main-window) + (start-streaming-thread iri + :use-cache nil + :status status + :process-function + (lambda (stream-wrapper lines) + ;; this test ensures that the + ;; collecting events left on + ;; the queue won't be actually + ;; processed, just discarded + (when (not (eq (status stream-wrapper) + +stream-status-canceled+)) + (collect-ir-lines iri main-window lines))))) + ((gemini-client:text-file-stream-p meta) + (slurp-text-data main-window iri)) + (t + (slurp-non-text-data main-window iri)))) ((eq status +stream-status-downloading+) (when (not (find-db-stream-url iri)) (enqueue-request-notify-error :gemini-request 1 iri use-cache))) diff --git a/src/gui/server/public-api-gemini-stream.lisp b/src/gui/server/public-api-gemini-stream.lisp index 185bc46..5dcfd44 100644 --- a/src/gui/server/public-api-gemini-stream.lisp +++ b/src/gui/server/public-api-gemini-stream.lisp @@ -75,7 +75,6 @@ (gemini-viewer::increment-bytes-count wrapper-object read-so-far) (write-sequence buffer file-stream :start 0 :end read-so-far) (force-output file-stream) - (misc:dbg "letti ~a" read-so-far) (if (download-completed-p buffer read-so-far) (progn (setf (gemini-viewer:stream-status wrapper-object) :completed)