2005-05-22 05:20:44 -04:00
|
|
|
(define (list-of-processes? thing)
|
|
|
|
(and (proper-list? thing)
|
|
|
|
(every process-info? thing)))
|
|
|
|
|
2005-05-31 15:31:38 -04:00
|
|
|
(define (make-header-line width)
|
|
|
|
(cut-to-size
|
|
|
|
width
|
|
|
|
(string-append
|
|
|
|
(fill-up-string 5 "PID")
|
|
|
|
" "
|
|
|
|
(fill-up-string 5 "PPID")
|
|
|
|
" "
|
|
|
|
(fill-up-string 5 "TIME")
|
|
|
|
" "
|
|
|
|
(fill-up-string 40 "COMMAND"))))
|
2005-05-25 05:44:27 -04:00
|
|
|
|
|
|
|
(define (layout-process width p)
|
2005-05-31 15:31:38 -04:00
|
|
|
(cut-to-size
|
|
|
|
width
|
|
|
|
(string-append
|
|
|
|
(fill-up-string 5 (number->string (process-info-pid p)))
|
|
|
|
" "
|
|
|
|
(fill-up-string 5 (number->string (process-info-ppid p)))
|
|
|
|
" "
|
|
|
|
(fill-up-string 5 (number->string (process-info-time p)))
|
|
|
|
" "
|
|
|
|
(fill-up-string 40 (string-append
|
|
|
|
(process-info-executable p)
|
|
|
|
" "
|
|
|
|
(string-join
|
|
|
|
(process-info-command-line p)))))))
|
2005-05-25 05:44:27 -04:00
|
|
|
|
2005-05-25 07:36:12 -04:00
|
|
|
(define (make-process-selection-list num-cols num-lines processes)
|
|
|
|
(let ((layout (lambda (p) (layout-process num-cols p))))
|
2005-05-25 05:44:27 -04:00
|
|
|
(make-select-list
|
2005-05-26 07:33:38 -04:00
|
|
|
(map
|
|
|
|
(lambda (p)
|
|
|
|
(make-unmarked-element p #t (layout-process num-cols p)))
|
|
|
|
processes)
|
2005-05-25 07:36:12 -04:00
|
|
|
num-lines)))
|
2005-05-20 11:20:34 -04:00
|
|
|
|
2005-05-31 09:15:31 -04:00
|
|
|
(define (make-pps-viewer processes buffer)
|
|
|
|
(let ((processes processes)
|
|
|
|
(select-list
|
|
|
|
(make-process-selection-list
|
|
|
|
(result-buffer-num-cols buffer)
|
2005-05-31 15:31:38 -04:00
|
|
|
(- (result-buffer-num-lines buffer) 1)
|
|
|
|
processes))
|
|
|
|
(header (make-header-line (result-buffer-num-cols buffer))))
|
2005-05-30 15:19:36 -04:00
|
|
|
(lambda (message)
|
2005-05-25 05:44:27 -04:00
|
|
|
|
2005-05-31 15:31:38 -04:00
|
|
|
(case message
|
|
|
|
|
|
|
|
((paint)
|
|
|
|
(lambda (self win buffer have-focus?)
|
|
|
|
(mvwaddstr win 0 0 header)
|
|
|
|
(paint-selection-list-at
|
|
|
|
select-list 0 1 win buffer have-focus?)))
|
|
|
|
|
|
|
|
((key-press)
|
2005-05-30 15:19:36 -04:00
|
|
|
(lambda (self key control-x-pressed?)
|
|
|
|
(set! select-list
|
|
|
|
(select-list-handle-key-press select-list key))
|
|
|
|
self))
|
|
|
|
|
|
|
|
(else
|
|
|
|
(error "pps-viewer unknown message" message))))))
|
2005-05-20 11:20:34 -04:00
|
|
|
|
2005-05-22 11:05:25 -04:00
|
|
|
(register-plugin!
|
2005-05-30 15:19:36 -04:00
|
|
|
(make-view-plugin make-pps-viewer list-of-processes?))
|