Sorting for processes
part of darcs patch Sat Sep 17 19:21:17 EEST 2005 Martin Gasbichler <gasbichl@informatik.uni-tuebingen.de>
This commit is contained in:
parent
2ba820f63a
commit
44c95c43e5
|
@ -146,7 +146,12 @@
|
|||
srfi-13
|
||||
formats
|
||||
signals
|
||||
ascii
|
||||
sorting
|
||||
srfi-8
|
||||
srfi-26
|
||||
|
||||
configuration
|
||||
focus-table
|
||||
ncurses
|
||||
pps
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
processes)
|
||||
num-lines)))
|
||||
|
||||
(define-option 'ps 'sort-user-up-key (char->ascii #\u))
|
||||
(define-option 'ps 'sort-user-down-key (char->ascii #\U))
|
||||
(define-option 'ps 'sort-pid-up-key (char->ascii #\p))
|
||||
(define-option 'ps 'sort-pid-down-key (char->ascii #\P))
|
||||
(define-option 'ps 'sort-time-up-key (char->ascii #\t))
|
||||
(define-option 'ps 'sort-time-down-key (char->ascii #\T))
|
||||
|
||||
(define (make-pps-viewer processes buffer)
|
||||
(let ((processes processes)
|
||||
(select-list
|
||||
|
@ -52,6 +59,24 @@
|
|||
processes))
|
||||
(header (make-header-line (result-buffer-num-cols buffer))))
|
||||
|
||||
(define sorting-keys
|
||||
(map
|
||||
(cut config 'ps <>)
|
||||
(list 'sort-time-up-key
|
||||
'sort-time-down-key
|
||||
'sort-user-up-key
|
||||
'sort-user-down-key
|
||||
'sort-pid-up-key
|
||||
'sort-pid-down-key)))
|
||||
|
||||
(define (set-processes! new-processes)
|
||||
(set! processes new-processes)
|
||||
(set! select-list
|
||||
(make-process-selection-list
|
||||
(result-buffer-num-cols buffer)
|
||||
(- (result-buffer-num-lines buffer) 1)
|
||||
new-processes)))
|
||||
|
||||
(define (get-selection-as-text self for-scheme-mode? focus-object-table)
|
||||
(let* ((marked (select-list-get-marked select-list)))
|
||||
(cond
|
||||
|
@ -68,7 +93,6 @@
|
|||
(map process-info-pid marked)))))))
|
||||
|
||||
(lambda (message)
|
||||
|
||||
(case message
|
||||
|
||||
((paint)
|
||||
|
@ -79,9 +103,32 @@
|
|||
|
||||
((key-press)
|
||||
(lambda (self key control-x-pressed?)
|
||||
(set! select-list
|
||||
(select-list-handle-key-press select-list key))
|
||||
self))
|
||||
(cond
|
||||
((member key sorting-keys)
|
||||
(receive (compare select)
|
||||
(cond
|
||||
((= key (config 'ps 'sort-time-up-key))
|
||||
(values < process-info-time))
|
||||
((= key (config 'ps 'sort-time-down-key))
|
||||
(values > process-info-time))
|
||||
((= key (config 'ps 'sort-user-up-key))
|
||||
(values string<? process-info-logname))
|
||||
((= key (config 'ps 'sort-user-down-key))
|
||||
(values string>? process-info-logname))
|
||||
((= key (config 'ps 'sort-pid-up-key))
|
||||
(values < process-info-pid))
|
||||
((= key (config 'ps 'sort-pid-down-key))
|
||||
(values > process-info-pid)))
|
||||
(set-processes!
|
||||
(list-sort
|
||||
(lambda (p1 p2)
|
||||
(compare (select p1) (select p2)))
|
||||
processes))
|
||||
self))
|
||||
(else
|
||||
(set! select-list
|
||||
(select-list-handle-key-press select-list key))
|
||||
self))))
|
||||
|
||||
((get-selection-as-text) get-selection-as-text)
|
||||
|
||||
|
|
Loading…
Reference in New Issue