Fix process format

This commit is contained in:
eknauel 2005-05-31 19:31:38 +00:00
parent df065fe14d
commit 49054b8d88
2 changed files with 41 additions and 24 deletions

View File

@ -38,6 +38,9 @@
exp->string
sublist
fill-up-string
cut-to-size
;; old drawing cruft
make-result-buffer
result-buffer?
@ -79,6 +82,7 @@
formats
signals
ncurses
pps
plugin
layout

View File

@ -2,24 +2,33 @@
(and (proper-list? thing)
(every process-info? thing)))
(define (string-take-max s nchars)
(if (>= nchars (string-length s))
s
(string-take s nchars)))
(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"))))
(define (layout-process width p)
(string-take-max
(apply format
(append
(list #f "~A ~A ~A ~A '~A ~A'~%")
(map (lambda (s) (s p))
(list process-info-pid
process-info-ppid
process-info-real-uid
process-info-%cpu
process-info-executable
process-info-command-line))))
width))
(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)))))))
(define (make-process-selection-list num-cols num-lines processes)
(let ((layout (lambda (p) (layout-process num-cols p))))
@ -35,16 +44,20 @@
(select-list
(make-process-selection-list
(result-buffer-num-cols buffer)
(result-buffer-num-lines buffer)
processes)))
(- (result-buffer-num-lines buffer) 1)
processes))
(header (make-header-line (result-buffer-num-cols buffer))))
(lambda (message)
(cond
((eq? message 'paint)
(lambda (self . args)
(apply paint-selection-list
(cons select-list args))))
((eq? message 'key-press)
(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)
(lambda (self key control-x-pressed?)
(set! select-list
(select-list-handle-key-press select-list key))