mirror of
https://codeberg.org/cage/tinmop/
synced 2024-12-20 23:34:40 +01:00
- [gemini] allowed exploring directory using relative path;
- [gemini] allowed opening a file using tinmop itself (example: opening a gemini text file); - added a more hi-level function to open a file with an external program. - this function takes into account the file that should be opened with tinmop and uses 'xdg-open' as fallback if the user did not specified an association program file-type.
This commit is contained in:
parent
ff99cd50b6
commit
8b50eec3be
@ -173,3 +173,7 @@ color-regexp = ":rendering" cyan
|
||||
# open png files with gimp but cache them before
|
||||
# ▼▼▼▼▼▼▼▼▼
|
||||
# open "https?://png$" with "gimp" use cache
|
||||
# if you want to open some kind of file with tinmop try the following
|
||||
# valid values are "tinmop" "me" "internal"
|
||||
# ▼▼▼▼▼▼▼▼
|
||||
open "gmi$" with "tinmop"
|
@ -133,6 +133,16 @@
|
||||
(setf all-paths (sort all-paths #'string<))
|
||||
all-paths))
|
||||
|
||||
(defgeneric prepend-pwd (object))
|
||||
|
||||
(defmethod prepend-pwd ((object string))
|
||||
(if (cl-ppcre:scan "^\\." object)
|
||||
(text-utils:strcat (os-utils:pwd) *directory-sep* object)
|
||||
object))
|
||||
|
||||
(defmethod prepend-pwd ((object sequence))
|
||||
(map 'list #'prepend-pwd object))
|
||||
|
||||
(defun search-matching-file (root-directory &key (name ".*"))
|
||||
"Scan a filesystem saving files that match the provided criteria,
|
||||
does not follow symlinks."
|
||||
|
@ -136,6 +136,4 @@
|
||||
(progn
|
||||
(db:cache-invalidate url)
|
||||
(open-attachment url))
|
||||
(if program
|
||||
(os-utils:open-link-with-program program url)
|
||||
(os-utils:xdg-open cached-file)))))))))
|
||||
(os-utils:open-resource-with-external-program url nil))))))))
|
||||
|
@ -73,25 +73,17 @@
|
||||
(defun open-message-link (url enqueue)
|
||||
(let* ((parsed (iri:iri-parse url))
|
||||
(scheme (uri:scheme parsed)))
|
||||
(cond
|
||||
((string= gemini-constants:+gemini-scheme+ scheme)
|
||||
(if (string= gemini-constants:+gemini-scheme+ scheme)
|
||||
(let ((program-events:*process-events-immediately* t)
|
||||
(event (make-instance 'program-events:gemini-push-behind-downloading-event
|
||||
:priority program-events:+maximum-event-priority+)))
|
||||
(db:insert-in-history (ui:gemini-open-url-prompt) url)
|
||||
(db:gemlog-mark-as-seen url)
|
||||
(gemini-viewer:ensure-just-one-stream-rendering)
|
||||
(program-events:push-event event))
|
||||
(gemini-viewer:request url :enqueue enqueue
|
||||
:use-cached-file-if-exists t))
|
||||
((null scheme)
|
||||
(gemini-viewer:load-gemini-url url
|
||||
:give-focus-to-message-window nil))
|
||||
(t
|
||||
(let ((program (swconf:link-regex->program-to-use url)))
|
||||
(if program
|
||||
(os-utils:open-link-with-program program url)
|
||||
(os-utils:xdg-open url)))))))
|
||||
(event (make-instance 'program-events:gemini-push-behind-downloading-event
|
||||
:priority program-events:+maximum-event-priority+)))
|
||||
(db:insert-in-history (ui:gemini-open-url-prompt) url)
|
||||
(db:gemlog-mark-as-seen url)
|
||||
(gemini-viewer:ensure-just-one-stream-rendering)
|
||||
(program-events:push-event event)
|
||||
(gemini-viewer:request url :enqueue enqueue
|
||||
:use-cached-file-if-exists t))
|
||||
(os-utils:open-resource-with-external-program url nil))))
|
||||
|
||||
(defclass open-links-window ()
|
||||
((links
|
||||
|
@ -56,6 +56,9 @@
|
||||
(or (os-utils:getenv "TMPDIR")
|
||||
"/tmp/"))
|
||||
|
||||
(defun pwd ()
|
||||
(os-utils:getenv "PWD"))
|
||||
|
||||
(defun external-editor ()
|
||||
(let ((error-message
|
||||
(_ "No editor found, please configure the 'editor' directive in your configuration file"))
|
||||
@ -132,3 +135,13 @@
|
||||
:wait nil
|
||||
:output nil
|
||||
:error :output)))
|
||||
|
||||
(defun open-resource-with-external-program (resource give-focus-to-message-window)
|
||||
(let ((program (swconf:link-regex->program-to-use resource)))
|
||||
(if program
|
||||
(if (swconf:use-tinmop-as-external-program-p program)
|
||||
(gemini-viewer:load-gemini-url resource
|
||||
:give-focus-to-message-window
|
||||
give-focus-to-message-window)
|
||||
(os-utils:open-link-with-program program resource))
|
||||
(os-utils:xdg-open resource))))
|
||||
|
@ -279,6 +279,7 @@
|
||||
:add-extension
|
||||
:do-directory
|
||||
:collect-children
|
||||
:prepend-pwd
|
||||
:search-matching-file
|
||||
:regular-file-p
|
||||
:dirp
|
||||
@ -327,15 +328,17 @@
|
||||
:+ssl-key-name+
|
||||
:cpu-number
|
||||
:xdg-open
|
||||
:open-link-with-program
|
||||
:getenv
|
||||
:default-temp-dir
|
||||
:pwd
|
||||
:open-with-editor
|
||||
:exit-program
|
||||
:user-cache-dir
|
||||
:cached-file-path
|
||||
:generate-ssl-certificate
|
||||
:send-to-pipe))
|
||||
:send-to-pipe
|
||||
:open-link-with-program
|
||||
:open-resource-with-external-program))
|
||||
|
||||
(defpackage :text-utils
|
||||
(:use
|
||||
@ -1127,6 +1130,7 @@
|
||||
:config-password-echo-character
|
||||
:config-win-focus-mark
|
||||
:link-regex->program-to-use
|
||||
:use-tinmop-as-external-program-p
|
||||
:thread-message-symbol
|
||||
:thread-message-read-colors
|
||||
:thread-message-unread-colors
|
||||
|
@ -1017,7 +1017,7 @@
|
||||
((gemini-client:absolute-gemini-url-p url)
|
||||
(gemini-viewer:request url :use-cached-file-if-exists use-cached-file-if-exists))
|
||||
((fs:dirp url)
|
||||
(let* ((all-paths (fs:collect-children url))
|
||||
(let* ((all-paths (fs:prepend-pwd (fs:collect-children url)))
|
||||
(raw-text (with-output-to-string (stream)
|
||||
(write-sequence (gemini-parser:geminize-h1
|
||||
(format nil
|
||||
|
@ -811,6 +811,9 @@
|
||||
(values (program-name found)
|
||||
(use-cache-p found))))
|
||||
|
||||
(defun use-tinmop-as-external-program-p (program)
|
||||
(cl-ppcre:scan "(^me$)|(^internal$)|(tinmop)" program))
|
||||
|
||||
(defun config-win-focus-mark ()
|
||||
(values (access:accesses *software-configuration*
|
||||
+key-window+
|
||||
|
Loading…
Reference in New Issue
Block a user