mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-04 04:47:34 +01:00
- added a command to send data to an external program.
This commit is contained in:
parent
f33fcf1218
commit
abec6a9322
@ -279,6 +279,8 @@
|
||||
|
||||
(define-key "C-X m u" #'unsubscribe-to-hash *thread-keymap*)
|
||||
|
||||
(define-key "|" #'send-message-to-pipe *thread-keymap*)
|
||||
|
||||
;; message window keymap
|
||||
|
||||
(define-key "up" #'message-scroll-up *message-keymap*)
|
||||
@ -299,6 +301,8 @@
|
||||
|
||||
(define-key "ppage" #'message-scroll-previous-page *message-keymap*)
|
||||
|
||||
(define-key "|" #'send-to-pipe *message-keymap*)
|
||||
|
||||
;; gemini viewer keymap
|
||||
|
||||
(define-key "up" #'message-scroll-up *gemini-message-keymap*)
|
||||
|
@ -106,3 +106,15 @@
|
||||
:output nil
|
||||
:error :output)
|
||||
(values cert-file key-file)))
|
||||
|
||||
(defun send-to-pipe (data program-and-args)
|
||||
(croatoan:end-screen)
|
||||
(with-input-from-string (stream data)
|
||||
(let ((command-line-splitted (text-utils:split-words program-and-args)))
|
||||
(sb-ext:run-program (first command-line-splitted)
|
||||
(rest command-line-splitted)
|
||||
:search t
|
||||
:wait t
|
||||
:input stream
|
||||
:output t
|
||||
:error t))))
|
||||
|
@ -326,7 +326,8 @@
|
||||
:exit-program
|
||||
:user-cache-dir
|
||||
:cached-file-path
|
||||
:generate-ssl-certificate))
|
||||
:generate-ssl-certificate
|
||||
:send-to-pipe))
|
||||
|
||||
(defpackage :text-utils
|
||||
(:use
|
||||
@ -1329,6 +1330,7 @@
|
||||
:help-apropos-event
|
||||
:redraw-window-event
|
||||
:function-event
|
||||
:send-to-pipe-event
|
||||
:dispatch-program-events
|
||||
:add-pagination-status-event
|
||||
:status-id
|
||||
@ -2327,7 +2329,9 @@
|
||||
:gemini-streams-window-down
|
||||
:gemini-streams-window-close
|
||||
:gemini-streams-window-open-stream
|
||||
:gemini-refresh-page))
|
||||
:gemini-refresh-page
|
||||
:send-to-pipe
|
||||
:send-message-to-pipe))
|
||||
|
||||
(defpackage :scheduled-events
|
||||
(:use
|
||||
|
@ -1258,6 +1258,21 @@
|
||||
(with-accessors ((window payload)) object
|
||||
(windows:draw window)))
|
||||
|
||||
(defclass send-to-pipe-event (program-event)
|
||||
((data
|
||||
:initform nil
|
||||
:initarg :data
|
||||
:accessor data)
|
||||
(command
|
||||
:initform nil
|
||||
:initarg :command
|
||||
:accessor command)))
|
||||
|
||||
(defmethod process-event ((object send-to-pipe-event))
|
||||
(with-accessors ((data data)
|
||||
(command command)) object
|
||||
(os-utils:send-to-pipe data command)))
|
||||
|
||||
;;;; general usage
|
||||
|
||||
(defclass function-event (program-event) ())
|
||||
|
@ -1781,3 +1781,28 @@ mot recent updated to least recent"
|
||||
:url url)))
|
||||
(push-event event-abort)
|
||||
(push-event event-open)))
|
||||
|
||||
(defun send-to-pipe ()
|
||||
"Send contents of window to a command"
|
||||
(flet ((on-input-complete (command)
|
||||
(when (string-not-empty-p command)
|
||||
(when-let ((data (message-window:source-text *message-window*)))
|
||||
(push-event (make-instance 'send-to-pipe-event
|
||||
:data data
|
||||
:command command))
|
||||
(info-message (format nil (_ "Command ~s completed")))))))
|
||||
(ask-string-input #'on-input-complete
|
||||
:prompt (format nil (_ "Send to command: ")))))
|
||||
|
||||
(defun send-message-to-pipe ()
|
||||
"Send contents of a message to a command"
|
||||
(when-let* ((selected-message (line-oriented-window:selected-row-fields *thread-window*))
|
||||
(message (db:row-message-rendered-text selected-message)))
|
||||
(flet ((on-input-complete (command)
|
||||
(when (string-not-empty-p command)
|
||||
(push-event (make-instance 'send-to-pipe-event
|
||||
:data message
|
||||
:command command))
|
||||
(notify (format nil (_ "Command ~s completed"))))))
|
||||
(ask-string-input #'on-input-complete
|
||||
:prompt (format nil (_ "Send message to command: "))))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user