mirror of https://codeberg.org/cage/tinmop/
- [RPC] added indices of matching chars in string that complete the
IRI in 'complete-net-address' This data would be useful to highlight parts of the string that matches the criteria to complete the user suggestions (typed on the address text entry).
This commit is contained in:
parent
65ed6b9425
commit
2b416820a1
|
@ -263,7 +263,6 @@
|
||||||
(gui:grid main-frame 0 0 :sticky :nswe)
|
(gui:grid main-frame 0 0 :sticky :nswe)
|
||||||
(gui-goodies:gui-resize-grid-all gui:*tk*)))))
|
(gui-goodies:gui-resize-grid-all gui:*tk*)))))
|
||||||
|
|
||||||
|
|
||||||
;; (let ((test-iri "gemini://omg.pebcak.club/"))
|
;; (let ((test-iri "gemini://omg.pebcak.club/"))
|
||||||
;; (slurp-gemini-stream test-iri
|
;; (slurp-gemini-stream test-iri
|
||||||
;; :process-function (lambda (lines) (misc:dbg "lines ~a" lines))))))))
|
;; :process-function (lambda (lines) (misc:dbg "lines ~a" lines))))))))
|
||||||
|
|
|
@ -17,9 +17,29 @@
|
||||||
|
|
||||||
(in-package :json-rpc-communication)
|
(in-package :json-rpc-communication)
|
||||||
|
|
||||||
|
(defclass iri-complete-response (box) ())
|
||||||
|
|
||||||
|
(defmethod yason:encode ((object iri-complete-response) &optional (stream *standard-output*))
|
||||||
|
(let ((json:*symbol-encoder* #'json:encode-symbol-as-lowercase)
|
||||||
|
(yason:*list-encoder* #'yason:encode-plist)
|
||||||
|
(json:*symbol-key-encoder* #'json:encode-symbol-as-lowercase))
|
||||||
|
(yason:with-output (stream)
|
||||||
|
(yason:with-object ()
|
||||||
|
(yason:with-object-element (:matches)
|
||||||
|
(yason:encode-array-elements (list->array (getf (unbox object) :matches))))
|
||||||
|
(yason:with-object-element (:indices)
|
||||||
|
(json:with-array ()
|
||||||
|
(loop for indices-group in (getf (unbox object) :indices) do
|
||||||
|
(yason:encode-array-elements (list->array (remove-if #'null indices-group))))))))))
|
||||||
|
|
||||||
(defun complete-net-address (hint)
|
(defun complete-net-address (hint)
|
||||||
(let ((prompt (ui:open-url-prompt)))
|
(let ((prompt (ui:open-url-prompt)))
|
||||||
(funcall (complete:make-complete-gemini-iri-fn prompt) hint)))
|
(multiple-value-bind (matched-strings x indices)
|
||||||
|
(funcall (complete:make-complete-gemini-iri-fn prompt) hint)
|
||||||
|
(declare (ignore x))
|
||||||
|
(make-instance 'iri-complete-response
|
||||||
|
:contents (list :matches matched-strings
|
||||||
|
:indices indices)))))
|
||||||
|
|
||||||
(defun request-success-dispatched-fn (status code-description meta response socket iri parsed-iri)
|
(defun request-success-dispatched-fn (status code-description meta response socket iri parsed-iri)
|
||||||
(declare (ignore iri))
|
(declare (ignore iri))
|
||||||
|
|
Loading…
Reference in New Issue