~soapdog/fafi-browser

d3b869e52d13d77995c8d2dd35ccadfe7d950214 — Andre Alves Garzia 2 years ago 1979077 master v0.12
adding a suffix to web links in gemini-renderer%
3 files changed, 11 insertions(+), 2 deletions(-)

M config.rkt
M renderers/gemini-renderer.rkt
M styles.rkt
M config.rkt => config.rkt +1 -1
@@ 26,6 26,6 @@ version

;; Config parameters

(define debug-mode? (make-parameter #t))
(define debug-mode? (make-parameter #f))



M renderers/gemini-renderer.rkt => renderers/gemini-renderer.rkt +9 -0
@@ 1,6 1,7 @@
#lang racket/gui

(require
  net/url
  "../styles.rkt"
  "../config.rkt"
  "../persist.rkt"


@@ 123,9 124,17 @@
        [(eq? level 5) (insert-with-styles txt (cons h5-style style-list))]
        [(eq? level 6) (insert-with-styles txt (cons h6-style style-list))]
        [else (insert-with-styles txt (cons h6-style style-list))]))
    (define (glyph-for-schema link)
      (define u (string->url link))
      (define s (or (url-scheme u) ""))
      (cond 
        [(equal? s "gemini") ""]
        [(string-prefix? s "http") " (web)"]
        [else ""]))

    (define (insert-link link label style-list)
      (when (not (non-empty-string? label)) (set! label link))
      (set! label (string-append label (glyph-for-schema link)))
      (let ((start (send text last-position)))
        (insert-with-styles label (cons hyperlink-style style-list))
        (define end (send text last-position))

M styles.rkt => styles.rkt +1 -1
@@ 18,7 18,7 @@
  (let ([delta (make-object style-delta%)])
    (send delta set-delta-foreground (make-object color% 68 119 170))
    (send delta set-alignment-on 'base)
    (send delta set-underlined-on #t)
    (send delta set-underlined-on #f)
    delta))

;; Style used for hyperlinks when clicked on