diff --git a/src/api-client.lisp b/src/api-client.lisp index a1f1fe7..1b84a95 100644 --- a/src/api-client.lisp +++ b/src/api-client.lisp @@ -756,6 +756,7 @@ the latest 15 mentions)." mentions-so-far)) (defun update-mentions-folder (&key (delete-mentions-on-server t)) + (declare (ignorable delete-mentions-on-server)) ; because of the render macro '#-debug-mode' (let ((trees '())) (when-let* ((all-mentions (all-mentions)) (statuses (loop for mention in all-mentions @@ -773,6 +774,7 @@ the latest 15 mentions)." :folder db:+mentions-status-folder+ :localp t :min-id nil))) + #-debug-mode (when delete-mentions-on-server (loop for mention in all-mentions do (delete-notification (tooter:id mention)))) diff --git a/src/gemini-viewer.lisp b/src/gemini-viewer.lisp index 573ed9c..72c3d69 100644 --- a/src/gemini-viewer.lisp +++ b/src/gemini-viewer.lisp @@ -429,7 +429,8 @@ (loop named download-loop for ct from 0 - for line-as-array = (read-line-into-array download-stream) + for line-as-array = (with-print-error-message + (read-line-into-array download-stream)) while line-as-array do (gemini-client:debug-gemini "[stream] gemini file stream raw data line : ~a" line-as-array) @@ -493,45 +494,47 @@ (setf support-file (fs:temporary-file :extension extension))) (with-open-support-file (file-stream support-file) (let ((partial-content-not-opened t)) - (labels ((download-completed-p (buffer read-so-far) - (< read-so-far (length buffer))) - (opening-partial-contents-p (read-so-far) - (let ((buffer-size (swconf:link-regex->program-to-use-buffer-size path))) - (if buffer-size - (> read-so-far buffer-size) - (> read-so-far swconf:+buffer-minimum-size-to-open+)))) - (%fill-buffer () - (declare (optimize (debug 0) (speed 3))) - (when (downloading-allowed-p wrapper-object) - (multiple-value-bind (program-exists y wait-for-download) - (swconf:link-regex->program-to-use support-file) - (declare (ignore y)) - (multiple-value-bind (buffer read-so-far) - (read-array download-stream +read-buffer-size+) - (declare ((vector (unsigned-byte 8)) buffer)) - (declare (fixnum read-so-far)) - (increment-bytes-count wrapper-object read-so-far) - (if (download-completed-p buffer read-so-far) - (progn - (write-sequence buffer file-stream :start 0 :end read-so-far) - (force-output file-stream) - (setf (stream-status wrapper-object) :completed) - (gemini-client:close-ssl-socket socket) - (when (or wait-for-download - partial-content-not-opened) - (os-utils:open-resource-with-external-program support-file - nil))) - (progn - (write-sequence buffer file-stream) - (when (and partial-content-not-opened - program-exists - (not wait-for-download) - (opening-partial-contents-p (octect-count wrapper-object))) - (setf partial-content-not-opened nil) - (os-utils:open-resource-with-external-program support-file - nil)) - (%fill-buffer)))))))) - (%fill-buffer))))))) + (labels ((download-completed-p (buffer read-so-far) + (and buffer + (< read-so-far (length buffer)))) + (opening-partial-contents-p (read-so-far) + (let ((buffer-size (swconf:link-regex->program-to-use-buffer-size path))) + (if buffer-size + (> read-so-far buffer-size) + (> read-so-far swconf:+buffer-minimum-size-to-open+)))) + (%fill-buffer () + (declare (optimize (debug 0) (speed 3))) + (when (downloading-allowed-p wrapper-object) + (multiple-value-bind (program-exists y wait-for-download) + (swconf:link-regex->program-to-use support-file) + (declare (ignore y)) + (multiple-value-bind (buffer read-so-far) + (with-print-error-message + (read-array download-stream +read-buffer-size+)) + (declare ((vector (unsigned-byte 8)) buffer)) + (declare (fixnum read-so-far)) + (increment-bytes-count wrapper-object read-so-far) + (if (download-completed-p buffer read-so-far) + (progn + (write-sequence buffer file-stream :start 0 :end read-so-far) + (force-output file-stream) + (setf (stream-status wrapper-object) :completed) + (gemini-client:close-ssl-socket socket) + (when (or wait-for-download + partial-content-not-opened) + (os-utils:open-resource-with-external-program support-file + nil))) + (progn + (write-sequence buffer file-stream) + (when (and partial-content-not-opened + program-exists + (not wait-for-download) + (opening-partial-contents-p (octect-count wrapper-object))) + (setf partial-content-not-opened nil) + (os-utils:open-resource-with-external-program support-file + nil)) + (%fill-buffer)))))))) + (%fill-buffer))))))) (defun request-success-dispatched-clrs (enqueue) (lambda (status code-description meta response socket iri parsed-iri) diff --git a/src/program-events.lisp b/src/program-events.lisp index 4c7bdc8..6b6b0e5 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -1690,9 +1690,11 @@ (message-window specials:*message-window*)) (if mentions (labels ((print-mention (notification) - (format nil "type: ~a from ~a" - (tooter:kind notification) - (tooter:account-name (tooter:account notification)))) + (let ((raw-text (format nil + "type: ~a from ~a" + (tooter:kind notification) + (tooter:account-name (tooter:account notification))))) + (tui:make-tui-string raw-text))) (make-rows (mentions) (mapcar (lambda (mention) (make-instance 'line-oriented-window:line diff --git a/src/tui-utils.lisp b/src/tui-utils.lisp index 5563b51..435b319 100644 --- a/src/tui-utils.lisp +++ b/src/tui-utils.lisp @@ -508,7 +508,8 @@ latter has a length equals to `total-size'")) (error (e) (ui:notify (format nil (_ "Error: ~a") e) :life (* (swconf:config-notification-life) 5) - :as-error t)))) + :as-error t) + nil))) (defmacro with-print-error-message (&body body) #+debug-mode `(progn ,@body) @@ -516,4 +517,5 @@ latter has a length equals to `total-size'")) (progn ,@body) (error (e) - (ui:error-message (format nil (_ "Error: ~a") e))))) + (ui:error-message (format nil (_ "Error: ~a") e)) + nil)))