diff --git a/scheme/layout.scm b/scheme/layout.scm index f791813..8ca1937 100644 --- a/scheme/layout.scm +++ b/scheme/layout.scm @@ -181,13 +181,24 @@ (mvwaddstr window pos 1 line) (loop (+ pos 1))))))))))) -(define (fill-up-string length string) + +(define (left-align-string length string) (if (> (string-length string) length) (substring string 0 length) (string-append string (make-string (- length (string-length string)) #\space)))) +(define (right-align-string length string) + (if (> (string-length string) length) + (substring string 0 length) + (string-append + (make-string (- length (string-length string)) + #\space) + string))) + +(define fill-up-string left-align-string) + (define (cut-to-size length string) (if (> (string-length string) length) (substring string 0 length) diff --git a/scheme/nuit-packages.scm b/scheme/nuit-packages.scm index 004be56..67dbc4f 100644 --- a/scheme/nuit-packages.scm +++ b/scheme/nuit-packages.scm @@ -48,6 +48,8 @@ sublist fill-up-string + right-align-string + left-align-string cut-to-size ;; old drawing cruft diff --git a/scheme/process.scm b/scheme/process.scm index afaf03d..181d318 100644 --- a/scheme/process.scm +++ b/scheme/process.scm @@ -6,34 +6,34 @@ (cut-to-size width (string-append - (fill-up-string 5 "PID") + (right-align-string 5 "PID") " " - (fill-up-string 5 "PPID") + (right-align-string 5 "PPID") " " - (fill-up-string 8 "USER") + (left-align-string 8 "USER") " " - (fill-up-string 5 "TIME") + (right-align-string 5 "TIME") " " - (fill-up-string 40 "COMMAND")))) + (left-align-string 40 "COMMAND")))) (define (layout-process width p) (cut-to-size width (string-append - (fill-up-string 5 (number->string (process-info-pid p))) + (right-align-string 5 (number->string (process-info-pid p))) " " - (fill-up-string 5 (number->string (process-info-ppid p))) + (right-align-string 5 (number->string (process-info-ppid p))) " " - (fill-up-string 8 (process-info-logname p)) + (left-align-string 8 (process-info-logname p)) " " - (fill-up-string 5 (number->string (process-info-time p))) + (right-align-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))))))) - + (left-align-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)))) (make-select-list