source: project/release/4/dissector/parameters.scm @ 12396

Last change on this file since 12396 was 12286, checked in by felix winkelmann, 12 years ago

ported to chicken-4

File size: 2.7 KB
Line 
1;;;;;; Parameters relevant to the Dissector
2
3;;; Copyright (C) 2004, Taylor Campbell
4;;; All rights reserved.
5;;; See the LICENCE file for details.
6
7;;; The prompt for input to the dissector
8(define dissection-prompt
9  (make-parameter "dissect: "
10                  (lambda (new-prompt)
11                    (if (string? new-prompt)
12                        new-prompt
13                        (error "Bad dissection prompt"
14                               new-prompt)))))
15
16;;; The number of entries in one menu display.
17(define dissection-menu-section-size
18  (make-parameter 8
19                  (lambda (new-size)
20                    (if (and (integer?  new-size)
21                             (exact?    new-size)
22                             (positive? new-size))
23                        new-size
24                        (error "Bad dissection menu section size"
25                               new-size)))))
26
27;;; The function to print a dissection's overview.  This takes two
28;;; arguments: the object to print and the port to print it to.
29(define dissection-overview-printer
30  (make-parameter (lambda (focus port)
31                    (call-with-limited-output-port port
32                        (dissector-right-margin)
33                      (lambda (port)
34                        (write focus port)))
35                    (newline port)
36                    (flush-output port))
37                  (lambda (new-printer)
38                    (if (procedure? new-printer)
39                        new-printer
40                        (error "Bad dissection overview printer"
41                               new-printer)))))
42
43;;; The function to print a dissected object's components.  This takes
44;;; three arguments: the object to print, the number of characters
45;;; already printed to the port on that line, and the port to print it
46;;; to.
47(define dissection-menu-entry-printer
48  (make-parameter (lambda (component chars port)
49                    (call-with-limited-output-port port
50                        (- (dissector-right-margin) chars)
51                      (lambda (port)
52                        (write component port))))
53                  (lambda (new-printer)
54                    (if (procedure? new-printer)
55                        new-printer
56                        (error "Bad dissected component printer"
57                               new-printer)))))
58
59;;; The right margin for printing objects.
60(define dissector-right-margin
61  (make-parameter 71
62                  (lambda (new-margin)
63                    (if (and (integer? new-margin)
64                             (exact?   new-margin)
65                             (<   0    new-margin))
66                        new-margin
67                        (error "Bad right margin" new-margin)))))
Note: See TracBrowser for help on using the repository browser.