mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-21 08:50:51 +01:00
- [GUI] fixed leaking lines parameter when rendering preformatted text;
- [gemini] added a missing newline character in 'geminize-preformatted'; - [GUI] parsed standard colors for gemini window's text; - [GUI] rendered the gemini protocol rerror responses to the gemtext window instead of poppinu out a dialog window.
This commit is contained in:
parent
fa6844a2ab
commit
559b5dae84
@ -66,7 +66,7 @@ gemini.quote.size = 12
|
|||||||
|
|
||||||
gemini.quote.weight = bold
|
gemini.quote.weight = bold
|
||||||
|
|
||||||
gemini.quote.slant = roman
|
gemini.quote.slant = italic
|
||||||
|
|
||||||
gemini.quote.underline = yes
|
gemini.quote.underline = yes
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ gemini.h2.background = #ffffff
|
|||||||
|
|
||||||
gemini.h2.font = Sans
|
gemini.h2.font = Sans
|
||||||
|
|
||||||
gemini.h2.size = 12
|
gemini.h2.size = 15
|
||||||
|
|
||||||
gemini.h2.weight = bold
|
gemini.h2.weight = bold
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@
|
|||||||
(gen-geminize-line link +link-prefix+)
|
(gen-geminize-line link +link-prefix+)
|
||||||
|
|
||||||
(defun geminize-preformatted (text)
|
(defun geminize-preformatted (text)
|
||||||
(format nil "~a~%~a~a~%"
|
(format nil "~a~%~a~%~a~%"
|
||||||
+preformatted-prefix+
|
+preformatted-prefix+
|
||||||
text
|
text
|
||||||
+preformatted-prefix+))
|
+preformatted-prefix+))
|
||||||
|
@ -61,14 +61,14 @@
|
|||||||
swconf:+key-favicon+))
|
swconf:+key-favicon+))
|
||||||
|
|
||||||
(defun gemini-window-colors ()
|
(defun gemini-window-colors ()
|
||||||
(values (access:accesses *client-configuration*
|
(values (gui-goodies:parse-color (access:accesses *client-configuration*
|
||||||
swconf:+key-gemini+
|
swconf:+key-gemini+
|
||||||
swconf:+key-main-window+
|
swconf:+key-main-window+
|
||||||
swconf:+key-background+)
|
swconf:+key-background+))
|
||||||
(access:accesses *client-configuration*
|
(gui-goodies:parse-color (access:accesses *client-configuration*
|
||||||
swconf:+key-gemini+
|
swconf:+key-gemini+
|
||||||
swconf:+key-main-window+
|
swconf:+key-main-window+
|
||||||
swconf:+key-foreground+)))
|
swconf:+key-foreground+))))
|
||||||
|
|
||||||
(defun font-configuration (key)
|
(defun font-configuration (key)
|
||||||
(gui-goodies:make-font (access:accesses *client-configuration*
|
(gui-goodies:make-font (access:accesses *client-configuration*
|
||||||
|
@ -253,10 +253,8 @@
|
|||||||
(vector-push-extend raw-line ir-rendered-lines)))
|
(vector-push-extend raw-line ir-rendered-lines)))
|
||||||
(key->font (key)
|
(key->font (key)
|
||||||
(ecase key
|
(ecase key
|
||||||
((:vertical-space :pre-end :text :li)
|
((:vertical-space :text :li)
|
||||||
nil)
|
(gui-conf:gemini-text-font-configuration))
|
||||||
(:as-is
|
|
||||||
(gui-conf:gemini-preformatted-text-font-configuration))
|
|
||||||
(:h1
|
(:h1
|
||||||
(gui-conf:gemini-h1-font-configuration))
|
(gui-conf:gemini-h1-font-configuration))
|
||||||
(:h2
|
(:h2
|
||||||
@ -265,16 +263,14 @@
|
|||||||
(gui-conf:gemini-h3-font-configuration))
|
(gui-conf:gemini-h3-font-configuration))
|
||||||
(:quote
|
(:quote
|
||||||
(gui-conf:gemini-quote-font-configuration))
|
(gui-conf:gemini-quote-font-configuration))
|
||||||
(:pre
|
((:pre :pre-end :as-is)
|
||||||
(gui-conf:gemini-preformatted-text-font-configuration))
|
(gui-conf:gemini-preformatted-text-font-configuration))
|
||||||
(:a
|
(:a
|
||||||
(gui-conf:gemini-link-font-configuration))))
|
(gui-conf:gemini-link-font-configuration))))
|
||||||
(key->colors (key)
|
(key->colors (key)
|
||||||
(ecase key
|
(ecase key
|
||||||
((:vertical-space :pre-end :text :li)
|
((:vertical-space :text :li)
|
||||||
nil)
|
(gui-conf:gemini-window-colors))
|
||||||
(:as-is
|
|
||||||
(gui-conf:gemini-preformatted-text-colors))
|
|
||||||
(:h1
|
(:h1
|
||||||
(gui-conf:gemini-h1-colors))
|
(gui-conf:gemini-h1-colors))
|
||||||
(:h2
|
(:h2
|
||||||
@ -283,16 +279,14 @@
|
|||||||
(gui-conf:gemini-h3-colors))
|
(gui-conf:gemini-h3-colors))
|
||||||
(:quote
|
(:quote
|
||||||
(gui-conf:gemini-quote-colors))
|
(gui-conf:gemini-quote-colors))
|
||||||
(:pre
|
((:pre :pre-end :as-is)
|
||||||
(gui-conf:gemini-preformatted-text-colors))
|
(gui-conf:gemini-preformatted-text-colors))
|
||||||
(:a
|
(:a
|
||||||
(gui-conf:gemini-link-colors))))
|
(gui-conf:gemini-link-colors))))
|
||||||
(key->justification (key)
|
(key->justification (key)
|
||||||
(ecase key
|
(ecase key
|
||||||
((:vertical-space :text :pre-end :li :a)
|
((:vertical-space :text :li :a)
|
||||||
nil)
|
:left)
|
||||||
(:as-is
|
|
||||||
(gui-conf:gemini-preformatted-text-justification))
|
|
||||||
(:h1
|
(:h1
|
||||||
(gui-conf:gemini-h1-justification))
|
(gui-conf:gemini-h1-justification))
|
||||||
(:h2
|
(:h2
|
||||||
@ -301,7 +295,7 @@
|
|||||||
(gui-conf:gemini-h3-justification))
|
(gui-conf:gemini-h3-justification))
|
||||||
(:quote
|
(:quote
|
||||||
(gui-conf:gemini-quote-justification))
|
(gui-conf:gemini-quote-justification))
|
||||||
(:pre
|
((:pre :pre-end :as-is)
|
||||||
(gui-conf:gemini-preformatted-text-justification))))
|
(gui-conf:gemini-preformatted-text-justification))))
|
||||||
(linkify (line line-number)
|
(linkify (line line-number)
|
||||||
(multiple-value-bind (link-bg link-fg)
|
(multiple-value-bind (link-bg link-fg)
|
||||||
@ -341,14 +335,13 @@
|
|||||||
(lambda () (print-info-message target-iri))
|
(lambda () (print-info-message target-iri))
|
||||||
:leave-callback
|
:leave-callback
|
||||||
(lambda () (print-info-message "")))
|
(lambda () (print-info-message "")))
|
||||||
|
|
||||||
(gui:append-line gemtext-widget "")))))
|
(gui:append-line gemtext-widget "")))))
|
||||||
(render-line (key text line-number)
|
(render-line (key text line-number)
|
||||||
(let ((font (key->font key))
|
(let ((font (key->font key))
|
||||||
(justification (key->justification key))
|
(justification (key->justification key))
|
||||||
(start-index `(:line ,line-number :char 0)))
|
(start-index `(:line ,line-number :char 0)))
|
||||||
(gui:append-text gemtext-widget text)
|
(gui:append-text gemtext-widget text)
|
||||||
(if font
|
(gui:append-line gemtext-widget "")
|
||||||
(multiple-value-bind (background foreground)
|
(multiple-value-bind (background foreground)
|
||||||
(key->colors key)
|
(key->colors key)
|
||||||
(let ((tag (gui:tag-create gemtext-widget
|
(let ((tag (gui:tag-create gemtext-widget
|
||||||
@ -361,11 +354,7 @@
|
|||||||
:foreground foreground
|
:foreground foreground
|
||||||
:background background
|
:background background
|
||||||
:justify justification)
|
:justify justification)
|
||||||
(gui:append-line gemtext-widget "")
|
tag)))))
|
||||||
tag))
|
|
||||||
(progn
|
|
||||||
(gui:append-line gemtext-widget "")
|
|
||||||
nil)))))
|
|
||||||
(loop with render-line-count = 0
|
(loop with render-line-count = 0
|
||||||
with starting-pre-block-line = -1
|
with starting-pre-block-line = -1
|
||||||
with ending-pre-block-line = -1
|
with ending-pre-block-line = -1
|
||||||
@ -408,12 +397,14 @@
|
|||||||
(render-line :quote (a:last-elt ir-rendered-lines) render-line-count))
|
(render-line :quote (a:last-elt ir-rendered-lines) render-line-count))
|
||||||
(:pre
|
(:pre
|
||||||
(vector-push-extend (format nil "") ir-rendered-lines)
|
(vector-push-extend (format nil "") ir-rendered-lines)
|
||||||
|
(incf render-line-count)
|
||||||
(setf starting-pre-block-line (1+ render-line-count))
|
(setf starting-pre-block-line (1+ render-line-count))
|
||||||
(setf current-pre-block-alt-text (ir-pre-alt-text line))
|
(setf current-pre-block-alt-text (ir-pre-alt-text line))
|
||||||
(render-line :pre (a:last-elt ir-rendered-lines) render-line-count))
|
(render-line :pre (a:last-elt ir-rendered-lines) render-line-count))
|
||||||
(:pre-end
|
(:pre-end
|
||||||
(vector-push-extend (format nil "") ir-rendered-lines)
|
(vector-push-extend (format nil "") ir-rendered-lines)
|
||||||
(setf ending-pre-block-line (1+ render-line-count))
|
(setf ending-pre-block-line (1+ render-line-count))
|
||||||
|
(incf render-line-count)
|
||||||
(render-line :pre-end (a:last-elt ir-rendered-lines) render-line-count))
|
(render-line :pre-end (a:last-elt ir-rendered-lines) render-line-count))
|
||||||
(:a
|
(:a
|
||||||
(incf render-line-count)
|
(incf render-line-count)
|
||||||
@ -449,6 +440,11 @@
|
|||||||
(t
|
(t
|
||||||
(notify-request-error (format nil (_ "No such file or directory: ~a") path)))))
|
(notify-request-error (format nil (_ "No such file or directory: ~a") path)))))
|
||||||
|
|
||||||
|
(defun render-gemtext-string (main-window parsed-lines &key (links-path-prefix ""))
|
||||||
|
(ev:with-enqueued-process-and-unblock ()
|
||||||
|
(clean-gemtext main-window)
|
||||||
|
(collect-ir-lines links-path-prefix gui-goodies:*main-frame* parsed-lines)))
|
||||||
|
|
||||||
(defun open-iri (iri main-window use-cache)
|
(defun open-iri (iri main-window use-cache)
|
||||||
(handler-case
|
(handler-case
|
||||||
(let ((parsed-iri (iri:iri-parse iri)))
|
(let ((parsed-iri (iri:iri-parse iri)))
|
||||||
@ -517,8 +513,14 @@
|
|||||||
((or (gemini-client:header-temporary-failure-p status-code)
|
((or (gemini-client:header-temporary-failure-p status-code)
|
||||||
(gemini-client:header-permanent-failure-p status-code)
|
(gemini-client:header-permanent-failure-p status-code)
|
||||||
(gemini-client:header-certificate-failure-p status-code))
|
(gemini-client:header-certificate-failure-p status-code))
|
||||||
(error (_ "~a ~a Error connecting to: ~a:~2%~a")
|
(let ((error-gemtext (cev:enqueue-request-and-wait-results :make-error-page
|
||||||
status-code status-description iri meta))
|
1
|
||||||
|
ev:+standard-event-priority+
|
||||||
|
iri
|
||||||
|
status-code
|
||||||
|
status-description
|
||||||
|
meta)))
|
||||||
|
(render-gemtext-string main-window error-gemtext)))
|
||||||
((gemini-client:header-redirect-p status-code)
|
((gemini-client:header-redirect-p status-code)
|
||||||
(when (gui:ask-yesno (format nil (_ "Follow redirection to ~a?") meta)
|
(when (gui:ask-yesno (format nil (_ "Follow redirection to ~a?") meta)
|
||||||
:title (_ "Redirection")
|
:title (_ "Redirection")
|
||||||
|
@ -435,10 +435,29 @@
|
|||||||
(defmethod yason:encode ((object gemini-toc) &optional (stream *standard-output*))
|
(defmethod yason:encode ((object gemini-toc) &optional (stream *standard-output*))
|
||||||
(encode-flat-array-of-plists (unbox object) stream))
|
(encode-flat-array-of-plists (unbox object) stream))
|
||||||
|
|
||||||
(defun gemini-parse-local-file (path)
|
(defun gemini-parse-string (string)
|
||||||
(let ((parsed-lines (gemini-parser:parse-gemini-file (fs:slurp-file path))))
|
(let ((parsed-lines (gemini-parser:parse-gemini-file string)))
|
||||||
(make-instance 'parsed-lines-slice
|
(make-instance 'parsed-lines-slice
|
||||||
:contents (rearrange-parsed-line-for-encoding parsed-lines))))
|
:contents (rearrange-parsed-line-for-encoding parsed-lines))))
|
||||||
|
|
||||||
|
(defun gemini-parse-local-file (path)
|
||||||
|
(if (fs:file-exists-p path)
|
||||||
|
(gemini-parse-string (fs:slurp-file path))
|
||||||
|
(error "No such file ~a" path)))
|
||||||
|
|
||||||
(defun gemini-slurp-local-file (path)
|
(defun gemini-slurp-local-file (path)
|
||||||
(fs:slurp-file path))
|
(fs:slurp-file path))
|
||||||
|
|
||||||
|
(defun make-error-page (iri code description meta)
|
||||||
|
(let* ((separator (make-string 10 :initial-element gemini-parser::+h2-underline+))
|
||||||
|
(gemtext (with-output-to-string (stream)
|
||||||
|
(write-sequence (gemini-parser:geminize-h2 (format nil
|
||||||
|
"~a ~a~%"
|
||||||
|
code
|
||||||
|
description))
|
||||||
|
stream)
|
||||||
|
(write-sequence (gemini-parser:geminize-preformatted separator)
|
||||||
|
stream)
|
||||||
|
(write-sequence (format nil "Error connecting to: ~a:~2%" iri) stream)
|
||||||
|
(write-sequence (format nil "~a~%" meta) stream))))
|
||||||
|
(gemini-parse-string gemtext)))
|
||||||
|
@ -75,6 +75,15 @@
|
|||||||
(gen-rpc "gemini-parse-local-file"
|
(gen-rpc "gemini-parse-local-file"
|
||||||
'gemini-parse-local-file
|
'gemini-parse-local-file
|
||||||
"path" 0)
|
"path" 0)
|
||||||
|
(gen-rpc "gemini-parse-string"
|
||||||
|
'gemini-parse-string
|
||||||
|
"string" 0)
|
||||||
|
(gen-rpc "make-error-page"
|
||||||
|
'make-error-page
|
||||||
|
"iri" 0
|
||||||
|
"code" 1
|
||||||
|
"description" 2
|
||||||
|
"meta" 3)
|
||||||
(gen-rpc "gemini-slurp-local-file"
|
(gen-rpc "gemini-slurp-local-file"
|
||||||
'gemini-slurp-local-file
|
'gemini-slurp-local-file
|
||||||
"path" 0)
|
"path" 0)
|
||||||
|
@ -3259,6 +3259,7 @@
|
|||||||
:gemini-h1-colors
|
:gemini-h1-colors
|
||||||
:gemini-h2-colors
|
:gemini-h2-colors
|
||||||
:gemini-h3-colors
|
:gemini-h3-colors
|
||||||
|
:gemini-window-colors
|
||||||
:gemini-preformatted-text-colors
|
:gemini-preformatted-text-colors
|
||||||
:gemini-quote-justification
|
:gemini-quote-justification
|
||||||
:gemini-h1-justification
|
:gemini-h1-justification
|
||||||
|
Loading…
x
Reference in New Issue
Block a user