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)))
|
||||
(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)
|
||||
(or (text-utils:string-starts-with-p fs:*directory-sep* hint)
|
||||
(text-utils:string-starts-with-p "." hint)
|
||||
|
@ -229,24 +239,24 @@ list af all possible candidtae for completion."
|
|||
|
||||
(defun make-complete-gemini-iri-fn (prompt)
|
||||
(lambda (hint)
|
||||
(if (expand-iri-as-local-path-p hint)
|
||||
(directory-complete hint)
|
||||
(when-let ((bag (remove-duplicates (funcall #'db:history-prompt->values
|
||||
prompt)
|
||||
:test #'string=)))
|
||||
(multiple-value-bind (matched-strings indices)
|
||||
(uri-matcher hint bag)
|
||||
(when matched-strings
|
||||
(values matched-strings
|
||||
nil ;for fuzzy search common prefix does
|
||||
(let ((actual-hint (maybe-remove-file-scheme hint)))
|
||||
(if (expand-iri-as-local-path-p actual-hint)
|
||||
(directory-complete actual-hint)
|
||||
(when-let ((bag (remove-duplicates (funcall #'db:history-prompt->values
|
||||
prompt)
|
||||
:test #'string=)))
|
||||
(multiple-value-bind (matched-strings indices)
|
||||
(uri-matcher actual-hint bag)
|
||||
(when matched-strings
|
||||
(values matched-strings
|
||||
nil ;for fuzzy search common prefix does
|
||||
;not makes sense; note also that
|
||||
;setting this to nil will force
|
||||
;selecting the first item in
|
||||
;'complete-window' (see:
|
||||
;complete-at-point and
|
||||
;insert-selected-suggestion),
|
||||
|
||||
indices)))))))
|
||||
indices))))))))
|
||||
|
||||
(defun complete-chat-message (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 +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)
|
||||
(handler-case
|
||||
(let ((parsed-iri (iri:iri-parse iri)))
|
||||
(if (iri:absolute-url-p iri)
|
||||
(if (string= (uri:scheme parsed-iri)
|
||||
gemini-constants:+gemini-scheme+)
|
||||
(start-stream-iri iri main-window use-cache)
|
||||
(client-os-utils:open-resource-with-external-program main-window iri))
|
||||
(open-local-path iri main-window)))
|
||||
(cond
|
||||
((gemini-parser:gemini-iri-p iri)
|
||||
(start-stream-iri iri main-window use-cache))
|
||||
((or (null (uri:scheme parsed-iri))
|
||||
(string= (uri:scheme parsed-iri)
|
||||
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)
|
||||
(notify-request-error e))))
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
:+standard-editor+
|
||||
:+octect-type+
|
||||
:+gemini-file-extension+
|
||||
:+file-scheme+
|
||||
;; GUI
|
||||
:+minimum-padding+
|
||||
:+ps-file-dialog-filter+
|
||||
|
|
Loading…
Reference in New Issue