commander-s/scheme/network-viewer.scm

72 lines
2.4 KiB
Scheme
Raw Normal View History

2005-09-27 12:20:57 -04:00
(define (make-service-info-select-list si num-lines)
(make-select-list
(append
(list
(make-unmarked-text-element
(cons 'name (service-info:name si))
#t
(format #f "Name: ~a" (service-info:name si)))
(make-unmarked-text-element
(cons 'port (service-info:port si))
#t
(format #f "Port: ~a" (number->string
(service-info:port si))))
(make-unmarked-text-element
(cons 'protocol
(service-info:protocol si))
#t
(format #f "Protocol: ~a" (service-info:protocol si)))
(make-unmarked-text-element
(cons 'text "") #f "Aliases:"))
(map (lambda (alias)
(make-unmarked-text-element
(cons 'alias alias) #t
(format #f " ~a" alias)))
(service-info:aliases si)))
num-lines))
(define (make-service-info-viewer si buffer)
(let ((si si)
(select-list
(make-service-info-select-list
si (result-buffer-num-lines buffer))))
(define (prepare-selection-for-scheme-mode sel)
(format #f "(~a)"
(string-join
(map write-to-string (map cdr sel)))))
(define (prepare-selection-for-command-mode sel)
(string-join (map display-to-string (map cdr sel))))
(define (get-selection-as-text self for-scheme-mode? focus-object-table)
(paste-selection (select-list-get-selection select-list)
(select-list-has-marks? select-list)
for-scheme-mode?
(lambda (se)
(write-to-string (cdr se)))
(lambda (se)
(display-to-string (cdr se)))))
2005-09-27 12:20:57 -04:00
(lambda (message)
(case message
((paint)
(lambda (self win buffer have-focus?)
(paint-selection-list-at select-list 1 1 win
(result-buffer-num-cols buffer)
have-focus?)))
2005-09-27 12:20:57 -04:00
((key-press)
(lambda (self key control-x-pressed?)
(set! select-list
(select-list-handle-key-press select-list key))
2005-09-27 12:20:57 -04:00
self))
((get-selection-as-text)
get-selection-as-text)
2005-09-27 12:20:57 -04:00
((get-selection-as-ref)
"UII get-selection-as-ref")
(else
(error "service-info-viewer unknown message" message))))))
(register-plugin!
(make-view-plugin make-service-info-viewer service-info?))