divide plugins into `view-plugins' and `command-plugins'
This commit is contained in:
parent
428c9587cc
commit
73e44b5fbd
|
@ -335,6 +335,6 @@
|
||||||
(and (proper-list? thing)
|
(and (proper-list? thing)
|
||||||
(every fs-object? thing)))
|
(every fs-object? thing)))
|
||||||
|
|
||||||
(register-plugin! (make-plugin "ls"
|
(register-plugin!
|
||||||
browse-dir-list-receiver
|
(make-view-plugin browse-dir-list-receiver
|
||||||
list-of-fs-objects?))
|
list-of-fs-objects?))
|
||||||
|
|
|
@ -336,4 +336,4 @@
|
||||||
|
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(register-plugin! (make-plugin "browse-list" browse-list-receiver))
|
;(register-plugin! (make-plugin "browse-list" browse-list-receiver))
|
||||||
|
|
|
@ -61,8 +61,8 @@
|
||||||
(browse-dir-list-receiver browse-sel-message)))
|
(browse-dir-list-receiver browse-sel-message)))
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(register-plugin!
|
;(register-plugin!
|
||||||
(make-plugin "directory-files" dir-files-receiver))
|
; (make-plugin "directory-files" dir-files-receiver))
|
||||||
|
|
||||||
(register-plugin!
|
; (register-plugin!
|
||||||
(make-plugin "ls" dir-files-receiver))
|
; (make-plugin "ls" dir-files-receiver))
|
||||||
|
|
|
@ -444,10 +444,10 @@
|
||||||
plugin)))
|
plugin)))
|
||||||
(else
|
(else
|
||||||
(values
|
(values
|
||||||
(post-message standard-plugin
|
(post-message standard-view-plugin
|
||||||
(make-next-command-message
|
(make-next-command-message
|
||||||
command '() (buffer-num-cols command-buffer)))
|
command '() (buffer-num-cols command-buffer)))
|
||||||
standard-plugin)))))
|
standard-view-plugin)))))
|
||||||
|
|
||||||
;;Extracts the name of the function and its parameters
|
;;Extracts the name of the function and its parameters
|
||||||
(define extract-com-and-par
|
(define extract-com-and-par
|
||||||
|
@ -530,18 +530,17 @@
|
||||||
(eval (read-sexp-from-string exp) env)))))
|
(eval (read-sexp-from-string exp) env)))))
|
||||||
|
|
||||||
(define (post-message plugin message)
|
(define (post-message plugin message)
|
||||||
((plugin-fun plugin) message))
|
(cond
|
||||||
|
((view-plugin? plugin)
|
||||||
(define (determine-plugin-by-command command)
|
((view-plugin-fun plugin) message))
|
||||||
(or (find (lambda (r)
|
(else
|
||||||
(string=? (plugin-command r) command))
|
(error "don't know how to talk to this plugin type"
|
||||||
(plugin-list))
|
plugin))))
|
||||||
standard-plugin))
|
|
||||||
|
|
||||||
(define (determine-plugin-by-type result)
|
(define (determine-plugin-by-type result)
|
||||||
(find (lambda (r)
|
(find (lambda (r)
|
||||||
((plugin-type-predicate r) result))
|
((view-plugin-type-predicate r) result))
|
||||||
(plugin-list)))
|
(view-plugin-list)))
|
||||||
|
|
||||||
;;Management of the upper buffer
|
;;Management of the upper buffer
|
||||||
;;add a char to the buffer
|
;;add a char to the buffer
|
||||||
|
@ -603,12 +602,6 @@
|
||||||
(history-entry-command (entry-data entry)) width)))))
|
(history-entry-command (entry-data entry)) width)))))
|
||||||
(wrefresh win)))
|
(wrefresh win)))
|
||||||
|
|
||||||
(define (post-print-message command result-object)
|
|
||||||
(post-message
|
|
||||||
(determine-plugin-by-command command)
|
|
||||||
(make-print-message command result-object
|
|
||||||
(buffer-num-cols command-buffer))))
|
|
||||||
|
|
||||||
(define (paint-result-buffer print-object)
|
(define (paint-result-buffer print-object)
|
||||||
(let* ((window (app-window-curses-win result-window))
|
(let* ((window (app-window-curses-win result-window))
|
||||||
(text (print-object-text print-object))
|
(text (print-object-text print-object))
|
||||||
|
@ -788,6 +781,7 @@
|
||||||
((selection-message? message)
|
((selection-message? message)
|
||||||
"")))
|
"")))
|
||||||
|
|
||||||
(define standard-plugin
|
(define standard-view-plugin
|
||||||
(make-plugin #f standard-receiver-rec))
|
(make-view-plugin standard-receiver-rec
|
||||||
|
(lambda (val) #t)))
|
||||||
|
|
||||||
|
|
|
@ -101,11 +101,17 @@
|
||||||
;;; nuit plug-in registration
|
;;; nuit plug-in registration
|
||||||
|
|
||||||
(define-interface plugin-interface
|
(define-interface plugin-interface
|
||||||
(export make-plugin
|
(export make-view-plugin
|
||||||
plugin?
|
view-plugin?
|
||||||
plugin-command
|
view-plugin-fun
|
||||||
plugin-fun
|
view-plugin-type-predicate
|
||||||
plugin-type-predicate
|
|
||||||
|
make-command-plugin
|
||||||
|
command-plugin?
|
||||||
|
command-plugin-command
|
||||||
|
command-plugin-completer
|
||||||
|
command-plugin-evaluater
|
||||||
|
|
||||||
register-plugin!
|
register-plugin!
|
||||||
|
|
||||||
make-print-object
|
make-print-object
|
||||||
|
@ -147,7 +153,8 @@
|
||||||
message-command-string))
|
message-command-string))
|
||||||
|
|
||||||
(define-interface plugin-host-interface
|
(define-interface plugin-host-interface
|
||||||
(export plugin-list
|
(export command-plugin-list
|
||||||
|
view-plugin-list
|
||||||
make-next-command-message
|
make-next-command-message
|
||||||
make-init-with-result-message
|
make-init-with-result-message
|
||||||
make-key-pressed-message
|
make-key-pressed-message
|
||||||
|
|
|
@ -1,26 +1,33 @@
|
||||||
(define *plugins* '())
|
(define *command-plugins* '())
|
||||||
|
|
||||||
(define (plugin-list)
|
(define *view-plugins* '())
|
||||||
*plugins*)
|
|
||||||
|
|
||||||
(define-record-type plugin :plugin
|
(define (command-plugin-list)
|
||||||
(really-make-plugin command fun type-predicate)
|
*command-plugins*)
|
||||||
plugin?
|
|
||||||
(command plugin-command)
|
|
||||||
(fun plugin-fun)
|
|
||||||
(type-predicate plugin-type-predicate))
|
|
||||||
|
|
||||||
(define-record-discloser :plugin
|
(define (view-plugin-list)
|
||||||
(lambda (r)
|
*view-plugins*)
|
||||||
`(plugin ,(plugin-command r) ,(plugin-fun r))))
|
|
||||||
|
|
||||||
(define (make-plugin command fun . more)
|
(define-record-type view-plugin :view-plugin
|
||||||
(let-optionals more
|
(make-view-plugin fun type-predicate)
|
||||||
((type-predicate (lambda (v) #f)))
|
view-plugin?
|
||||||
(really-make-plugin command fun type-predicate)))
|
(fun view-plugin-fun)
|
||||||
|
(type-predicate view-plugin-type-predicate))
|
||||||
|
|
||||||
|
(define-record-type command-plugin :command-plugin
|
||||||
|
(make-command-plugin command completer evaluater)
|
||||||
|
command-plugin?
|
||||||
|
(command command-plugin-command)
|
||||||
|
(completer command-plugin-completer)
|
||||||
|
(evaluater command-plugin-evaluater))
|
||||||
|
|
||||||
(define (register-plugin! plugin)
|
(define (register-plugin! plugin)
|
||||||
(set! *plugins* (cons plugin *plugins*)))
|
(cond
|
||||||
|
((command-plugin? plugin)
|
||||||
|
(set! *command-plugins* (cons plugin *command-plugins*)))
|
||||||
|
((view-plugin? plugin)
|
||||||
|
(set! *view-plugins* (cons plugin *view-plugins*)))
|
||||||
|
(error "unknown plugin type" plugin)))
|
||||||
|
|
||||||
;; answers
|
;; answers
|
||||||
|
|
||||||
|
|
|
@ -36,4 +36,4 @@
|
||||||
"'()")))
|
"'()")))
|
||||||
|
|
||||||
(register-plugin!
|
(register-plugin!
|
||||||
(make-plugin "ps" pps-receiver list-of-processes?))
|
(make-view-plugin pps-receiver list-of-processes?))
|
||||||
|
|
Loading…
Reference in New Issue