1
0
Fork 0

- [GUI] added downloading of data with text/* MIME type (but not gemini);

- [GUI] refactored rendering of simple text data;

- [GUI] removed debugging form.
This commit is contained in:
cage 2023-03-15 17:42:22 +01:00
parent 26f843d2bd
commit 67d2a06630
3 changed files with 43 additions and 23 deletions

View File

@ -229,8 +229,6 @@ open "^((gemini://)|(\\.)|(/)).+gmi$" with "tinmop"
open "^((gemini://)|(\\.)|(/)).+sh$" with "tinmop"
open ".gpub$" with "tinmop"
#########################
# ⚠ EXPERIMENTAL ZONE ⚠ #
#########################

View File

@ -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)))

View File

@ -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)