From 39ae30681abce6a88da46316d843600cb52f1666 Mon Sep 17 00:00:00 2001 From: eknauel Date: Tue, 27 Sep 2005 08:45:50 +0000 Subject: [PATCH] get-selection-as-text/ref for group-info part of darcs patch Sat Sep 17 17:10:00 EEST 2005 Martin Gasbichler --- scheme/user-group-info.scm | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/scheme/user-group-info.scm b/scheme/user-group-info.scm index 71320af..9c251e7 100644 --- a/scheme/user-group-info.scm +++ b/scheme/user-group-info.scm @@ -234,6 +234,51 @@ (buffer buffer) (selection-list (make-gi-select-list gi (result-buffer-num-lines buffer)))) + + (define (group-info-element->value info) + (case info + ((gid) + (group-info:gid gi)) + ((name) + (group-info:name gi)) + (else ;members + (cdr info)))) + + (define (prepare-selection-for-command-mode infos) + (string-join + (map value->string + (map group-info-element->value infos)))) + + (define (prepare-selection-for-scheme-mode infos) + (string-append + "'" + (exp->string + (map group-info-element->value infos)))) + + (define (get-selection-as-text self for-scheme-mode? + focus-object-table) + (let ((infos + (select-list-get-selection selection-list))) + ((if for-scheme-mode? + prepare-selection-for-scheme-mode + prepare-selection-for-command-mode) + infos))) + + (define (get-selection-as-ref self focus-object-table) + (let ((infos + (select-list-get-selection selection-list)) + (make-reference (lambda (obj) + (make-focus-object-reference + focus-object-table obj)))) + (string-append + "(list " + (string-join + (map exp->string + (map make-reference + (map group-info-element->value infos)))) + ")"))) + + (lambda (message) (case message ((paint) @@ -255,6 +300,10 @@ (select-list-handle-key-press selection-list key)) self)))) + ((get-selection-as-text) + get-selection-as-text) + ((get-selection-as-ref) + get-selection-as-ref) (else (error "unknown message in make-group-info-browser" message))))))