mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-24 09:17:37 +01:00
- improved opening net command, gemini and also kami address can be opened.
This commit is contained in:
parent
496c624ee7
commit
a3a68a7486
@ -137,8 +137,6 @@
|
||||
|
||||
;; global keymap
|
||||
|
||||
(define-key "M-k >" #'kami-open-url)
|
||||
|
||||
(define-key "q" #'quit) ; here we are calling the custom
|
||||
; function defined above
|
||||
(define-key "C-a" #'show-about-window)
|
||||
@ -155,7 +153,7 @@
|
||||
|
||||
(define-key "!" #'gemini-search)
|
||||
|
||||
(define-key ">" #'open-gemini-address)
|
||||
(define-key ">" #'open-net-address)
|
||||
|
||||
(define-key "M-c" #'open-chats-list-window)
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
(in-package :kami)
|
||||
|
||||
(a:define-constant +kami-scheme+ "np" :test #'string=)
|
||||
|
||||
(a:define-constant +download-buffer+ (expt 2 24) :test #'=)
|
||||
|
||||
(a:define-constant +octect-type+ '(unsigned-byte 8) :test #'equalp)
|
||||
|
@ -8,5 +8,6 @@
|
||||
(:local-nicknames (:9p :purgatory)
|
||||
(:a :alexandria))
|
||||
(:export
|
||||
:+kami-scheme+
|
||||
:generate-filesystem-window-handlers
|
||||
:iri->filesystem-window-handlers))
|
||||
|
@ -80,7 +80,7 @@
|
||||
(ui:close-open-message-link-window))
|
||||
(cond
|
||||
((string= gemini-constants:+gemini-scheme+ scheme)
|
||||
(db:insert-in-history (ui:gemini-open-url-prompt) url)
|
||||
(db:insert-in-history (ui:open-url-prompt) url)
|
||||
(db:gemlog-mark-as-seen url)
|
||||
(gemini-viewer:ensure-just-one-stream-rendering)
|
||||
(gemini-viewer:load-gemini-url url
|
||||
|
@ -2740,7 +2740,8 @@
|
||||
:chat-create-new
|
||||
:chat-list-go-up
|
||||
:chat-list-go-down
|
||||
:gemini-open-url-prompt
|
||||
:open-url-prompt
|
||||
:open-net-address
|
||||
:open-gemini-address
|
||||
:gemini-history-back
|
||||
:gemini-view-source
|
||||
@ -2805,7 +2806,7 @@
|
||||
:load-script-file
|
||||
:view-user-avatar
|
||||
:open-file-explorer
|
||||
:kami-open-url
|
||||
:open-kami-address
|
||||
:file-explorer-expand-path
|
||||
:file-explorer-close-path
|
||||
:file-explorer-rename-path
|
||||
|
@ -1895,23 +1895,30 @@ mot recent updated to least recent"
|
||||
|
||||
;;;; gemini
|
||||
|
||||
(defun gemini-open-url-prompt ()
|
||||
(defun open-url-prompt ()
|
||||
"This is used when opening gemini link too, see:
|
||||
open-message-link-window:open-message-link"
|
||||
(_ "Open Gemini url: "))
|
||||
(_ "Open url: "))
|
||||
|
||||
(defun open-gemini-address ()
|
||||
"Ask for a gemini address and try to load it"
|
||||
(defun open-net-address ()
|
||||
"Ask for an internet address and try to load it.
|
||||
Currently the only recognized protocols are gemini and kami."
|
||||
(flet ((on-input-complete (url)
|
||||
(gemini-viewer:load-gemini-url (trim-blanks url)
|
||||
:use-cached-file-if-exists t
|
||||
:priority program-events:+maximum-event-priority+)))
|
||||
|
||||
(let ((prompt (gemini-open-url-prompt)))
|
||||
(let ((trimmed-url (trim-blanks url)))
|
||||
(if (text-utils:string-starts-with-p kami:+kami-scheme+ trimmed-url)
|
||||
(open-kami-address trimmed-url)
|
||||
(open-gemini-address trimmed-url)))))
|
||||
(let ((prompt (open-url-prompt)))
|
||||
(ask-string-input #'on-input-complete
|
||||
:prompt prompt
|
||||
:complete-fn (complete:make-complete-gemini-iri-fn prompt)))))
|
||||
|
||||
|
||||
(defun open-gemini-address (url)
|
||||
(gemini-viewer:load-gemini-url url
|
||||
:use-cached-file-if-exists t
|
||||
:priority program-events:+maximum-event-priority+))
|
||||
|
||||
(defun gemini-history-back ()
|
||||
"Reopen a previous visited gemini address"
|
||||
(push-event (make-instance 'gemini-back-event)))
|
||||
@ -2208,8 +2215,8 @@ gemini page the program is rendering."
|
||||
:prompt (format nil (_ "Insert certificate key file: "))
|
||||
:complete-fn #'complete:directory-complete)))
|
||||
(on-cert-key-path-input-complete (key-path)
|
||||
(let ((prompt-history (gemini-open-url-prompt))
|
||||
(prompt (_ "Insert the gemini IRI where where credential are valid: ")))
|
||||
(let ((prompt-history (open-url-prompt))
|
||||
(prompt (_ "Insert the gemini address where where credential are valid: ")))
|
||||
(when (file-valid-p key-path)
|
||||
(setf cert-key-file key-path)
|
||||
(ui:ask-string-input #'on-valid-uri-complete
|
||||
@ -2294,7 +2301,7 @@ gemini page the program is rendering."
|
||||
(push-event event)))
|
||||
|
||||
(defun generate-latest-visited-url ()
|
||||
(let ((history (remove-duplicates (db:history-prompt->values (gemini-open-url-prompt))
|
||||
(let ((history (remove-duplicates (db:history-prompt->values (open-url-prompt))
|
||||
:test #'string=)))
|
||||
(with-output-to-string (stream)
|
||||
(format stream (gemini-parser:geminize-h1 (_ "Latest visited addresses~2%")))
|
||||
@ -2420,11 +2427,7 @@ printed, on the main window."
|
||||
(filesystem-tree-window:init actual-root)
|
||||
(focus-to-filesystem-explorer-window))))
|
||||
|
||||
(defun kami-open-url-prompt ()
|
||||
(_ "Open kami url: "))
|
||||
|
||||
(defun kami-open-url ()
|
||||
(flet ((on-input-complete (url)
|
||||
(defun open-kami-address (url)
|
||||
(with-enqueued-process ()
|
||||
(tui:with-notify-errors
|
||||
(let ((handlers (kami:iri->filesystem-window-handlers url)))
|
||||
@ -2442,11 +2445,7 @@ printed, on the main window."
|
||||
(file-explorer-close-path))))
|
||||
(error-message (format nil
|
||||
(_ "~s is not a valid kami address")
|
||||
url))))))))
|
||||
(let ((prompt (kami-open-url-prompt)))
|
||||
(ask-string-input #'on-input-complete
|
||||
:prompt prompt
|
||||
:complete-fn (complete:make-complete-gemini-iri-fn prompt)))))
|
||||
url)))))))
|
||||
|
||||
(defun file-explorer-expand-path ()
|
||||
(when-let* ((win *filesystem-explorer-window*)
|
||||
|
Loading…
x
Reference in New Issue
Block a user