mirror of https://codeberg.org/cage/tinmop/
- [GUI] allowed expanding of local paths in the address bar;
- refactored callback related to opening address.
This commit is contained in:
parent
081fb45e06
commit
fd19aa8704
|
@ -222,11 +222,14 @@ list af all possible candidtae for completion."
|
|||
(setf indices (loop for i in ordering collect (elt indices i)))
|
||||
(values strings indices)))
|
||||
|
||||
(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)
|
||||
(text-utils:string-starts-with-p "~" hint)))
|
||||
|
||||
(defun make-complete-gemini-iri-fn (prompt)
|
||||
(lambda (hint)
|
||||
(if (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))
|
||||
(if (expand-iri-as-local-path-p hint)
|
||||
(directory-complete hint)
|
||||
(when-let ((bag (remove-duplicates (funcall #'db:history-prompt->values
|
||||
prompt)
|
||||
|
|
|
@ -164,7 +164,8 @@
|
|||
(defun autocomplete-iri-clsr (toolbar)
|
||||
(declare (ignore toolbar))
|
||||
(lambda (hint)
|
||||
(if (> (length hint) 2)
|
||||
(if (or (complete:expand-iri-as-local-path-p hint)
|
||||
(> (length hint) 2))
|
||||
(with-notify-errors
|
||||
(let ((match-results (cev:enqueue-request-and-wait-results :complete-net-address
|
||||
1
|
||||
|
@ -193,9 +194,8 @@
|
|||
(gen-ir-access pre-alt-text)
|
||||
|
||||
(defun link-click-mouse-1-callback (link-value main-window &key (use-cache t))
|
||||
(declare (ignore link-value))
|
||||
(lambda ()
|
||||
(funcall (start-stream-iri-clsr main-window :use-cache use-cache))))
|
||||
(open-iri link-value main-window use-cache)))
|
||||
|
||||
(defun collect-ir-lines (main-window lines)
|
||||
(with-accessors ((ir-lines ir-lines)
|
||||
|
@ -372,30 +372,45 @@
|
|||
(getf response :cached)
|
||||
(getf response :iri)))
|
||||
|
||||
(defun start-stream-iri-clsr (main-window use-cache &optional (status :streaming))
|
||||
(defun open-iri (iri main-window use-cache)
|
||||
(handler-case
|
||||
(let ((parsed-iri (iri:iri-parse iri)))
|
||||
(if (string= (uri:scheme parsed-iri)
|
||||
gemini-constants:+gemini-scheme+)
|
||||
(start-stream-iri iri main-window use-cache)
|
||||
(progn)))
|
||||
(error (e)
|
||||
#+debug-mode (misc:dbg "error quen getting iri from autocomplete ~a" e)
|
||||
(notify-request-error e))))
|
||||
|
||||
(defun start-stream-iri (iri main-window use-cache &optional (status :streaming))
|
||||
(let ((connecting-response (cev:enqueue-request-and-wait-results :gemini-request
|
||||
1
|
||||
ev:+maximum-event-priority+
|
||||
iri
|
||||
use-cache)))
|
||||
(multiple-value-bind (status-code
|
||||
status-description
|
||||
meta
|
||||
cached
|
||||
original-iri)
|
||||
(displace-gemini-response connecting-response)
|
||||
(cond
|
||||
((gemini-client:header-success-p status-code)
|
||||
(start-streaming-thread iri
|
||||
:use-cache nil
|
||||
:process-function (lambda (lines)
|
||||
(collect-ir-lines main-window lines)
|
||||
(misc:dbg "lines ~a" lines))
|
||||
:status status))))))
|
||||
|
||||
|
||||
(defun open-iri-clsr (main-window use-cache)
|
||||
(lambda ()
|
||||
(with-accessors ((tool-bar tool-bar)) main-window
|
||||
(with-accessors ((iri-entry iri-entry)) tool-bar
|
||||
(let* ((iri (trim-blanks (gui:text iri-entry)))
|
||||
(connecting-response (cev:enqueue-request-and-wait-results :gemini-request
|
||||
1
|
||||
ev:+maximum-event-priority+
|
||||
iri
|
||||
use-cache)))
|
||||
(multiple-value-bind (status-code
|
||||
status-description
|
||||
meta
|
||||
cached
|
||||
original-iri)
|
||||
(displace-gemini-response connecting-response)
|
||||
(cond
|
||||
((gemini-client:header-success-p status-code)
|
||||
(start-streaming-thread iri
|
||||
:use-cache nil
|
||||
:process-function (lambda (lines)
|
||||
(collect-ir-lines main-window lines)
|
||||
(misc:dbg "lines ~a" lines))
|
||||
:status status)))))))))
|
||||
(let* ((iri (trim-blanks (gui:text iri-entry))))
|
||||
(open-iri iri main-window use-cache))))))
|
||||
|
||||
(defun setup-main-window-events (main-window)
|
||||
(with-accessors ((tool-bar tool-bar)) main-window
|
||||
|
@ -409,9 +424,9 @@
|
|||
#$<KeyPress-Return>$
|
||||
(lambda (e)
|
||||
(declare (ignore e))
|
||||
(funcall (start-stream-iri-clsr main-window t)))
|
||||
(funcall (open-iri-clsr main-window t)))
|
||||
:append nil))
|
||||
(setf (gui:command go-button) (start-stream-iri-clsr main-window t)))))
|
||||
(setf (gui:command go-button) (open-iri-clsr main-window t)))))
|
||||
|
||||
(defmethod initialize-instance :after ((object tool-bar) &key &allow-other-keys)
|
||||
(with-accessors ((iri-entry iri-entry)
|
||||
|
|
|
@ -1563,6 +1563,7 @@
|
|||
:followed-user-complete
|
||||
:tags-complete
|
||||
:conversation-folder
|
||||
:expand-iri-as-local-path-p
|
||||
:make-complete-gemini-iri-fn
|
||||
:complete-chat-message
|
||||
:complete-always-empty
|
||||
|
|
Loading…
Reference in New Issue