mirror of https://codeberg.org/cage/tinmop/
- allowed complete local path even when using file scheme ('file://').
This commit is contained in:
parent
2b19e708d9
commit
4ee09ae301
|
@ -222,6 +222,16 @@ list af all possible candidtae for completion."
|
||||||
(setf indices (loop for i in ordering collect (elt indices i)))
|
(setf indices (loop for i in ordering collect (elt indices i)))
|
||||||
(values strings indices)))
|
(values strings indices)))
|
||||||
|
|
||||||
|
(defun maybe-remove-file-scheme (maybe-file-scheme-iri)
|
||||||
|
(let ((parsed-as-iri (iri:iri-parse maybe-file-scheme-iri :null-on-error t)))
|
||||||
|
(if (and parsed-as-iri
|
||||||
|
(string= (uri:scheme parsed-as-iri) constants:+file-scheme+)
|
||||||
|
(and (text-utils:string-starts-with-p (text-utils:strcat constants:+file-scheme+
|
||||||
|
"://")
|
||||||
|
maybe-file-scheme-iri)))
|
||||||
|
(uri:path parsed-as-iri)
|
||||||
|
maybe-file-scheme-iri)))
|
||||||
|
|
||||||
(defun expand-iri-as-local-path-p (hint)
|
(defun expand-iri-as-local-path-p (hint)
|
||||||
(or (text-utils:string-starts-with-p fs:*directory-sep* hint)
|
(or (text-utils:string-starts-with-p fs:*directory-sep* hint)
|
||||||
(text-utils:string-starts-with-p "." hint)
|
(text-utils:string-starts-with-p "." hint)
|
||||||
|
@ -229,13 +239,14 @@ list af all possible candidtae for completion."
|
||||||
|
|
||||||
(defun make-complete-gemini-iri-fn (prompt)
|
(defun make-complete-gemini-iri-fn (prompt)
|
||||||
(lambda (hint)
|
(lambda (hint)
|
||||||
(if (expand-iri-as-local-path-p hint)
|
(let ((actual-hint (maybe-remove-file-scheme hint)))
|
||||||
(directory-complete hint)
|
(if (expand-iri-as-local-path-p actual-hint)
|
||||||
|
(directory-complete actual-hint)
|
||||||
(when-let ((bag (remove-duplicates (funcall #'db:history-prompt->values
|
(when-let ((bag (remove-duplicates (funcall #'db:history-prompt->values
|
||||||
prompt)
|
prompt)
|
||||||
:test #'string=)))
|
:test #'string=)))
|
||||||
(multiple-value-bind (matched-strings indices)
|
(multiple-value-bind (matched-strings indices)
|
||||||
(uri-matcher hint bag)
|
(uri-matcher actual-hint bag)
|
||||||
(when matched-strings
|
(when matched-strings
|
||||||
(values matched-strings
|
(values matched-strings
|
||||||
nil ;for fuzzy search common prefix does
|
nil ;for fuzzy search common prefix does
|
||||||
|
@ -245,8 +256,7 @@ list af all possible candidtae for completion."
|
||||||
;'complete-window' (see:
|
;'complete-window' (see:
|
||||||
;complete-at-point and
|
;complete-at-point and
|
||||||
;insert-selected-suggestion),
|
;insert-selected-suggestion),
|
||||||
|
indices))))))))
|
||||||
indices)))))))
|
|
||||||
|
|
||||||
(defun complete-chat-message (hint)
|
(defun complete-chat-message (hint)
|
||||||
(append (username-complete hint)
|
(append (username-complete hint)
|
||||||
|
|
|
@ -162,3 +162,5 @@ General Public License for more details."
|
||||||
(define-constant +octect-type+ '(unsigned-byte 8) :test #'equalp)
|
(define-constant +octect-type+ '(unsigned-byte 8) :test #'equalp)
|
||||||
|
|
||||||
(define-constant +gemini-file-extension+ "gmi" :test #'string=)
|
(define-constant +gemini-file-extension+ "gmi" :test #'string=)
|
||||||
|
|
||||||
|
(define-constant +file-scheme+ "file" :test #'string=)
|
||||||
|
|
|
@ -487,12 +487,15 @@
|
||||||
(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)))
|
||||||
(if (iri:absolute-url-p iri)
|
(cond
|
||||||
(if (string= (uri:scheme parsed-iri)
|
((gemini-parser:gemini-iri-p iri)
|
||||||
gemini-constants:+gemini-scheme+)
|
(start-stream-iri iri main-window use-cache))
|
||||||
(start-stream-iri iri main-window use-cache)
|
((or (null (uri:scheme parsed-iri))
|
||||||
(client-os-utils:open-resource-with-external-program main-window iri))
|
(string= (uri:scheme parsed-iri)
|
||||||
(open-local-path iri main-window)))
|
constants:+file-scheme+))
|
||||||
|
(open-local-path (uri:path parsed-iri) main-window))
|
||||||
|
(t
|
||||||
|
(client-os-utils:open-resource-with-external-program main-window iri))))
|
||||||
(error (e)
|
(error (e)
|
||||||
(notify-request-error e))))
|
(notify-request-error e))))
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
:+standard-editor+
|
:+standard-editor+
|
||||||
:+octect-type+
|
:+octect-type+
|
||||||
:+gemini-file-extension+
|
:+gemini-file-extension+
|
||||||
|
:+file-scheme+
|
||||||
;; GUI
|
;; GUI
|
||||||
:+minimum-padding+
|
:+minimum-padding+
|
||||||
:+ps-file-dialog-filter+
|
:+ps-file-dialog-filter+
|
||||||
|
|
Loading…
Reference in New Issue