Reindent the body, use `append-map'.

This commit is contained in:
Eli Barzilay 2010-08-28 23:56:17 -04:00
parent 82749312f6
commit 0aa659ffe5

View File

@ -7,6 +7,7 @@
slideshow/pict slideshow/pict
slideshow/code slideshow/code
racket/class racket/class
racket/list
racket/path racket/path
racket/gui/base racket/gui/base
racket/runtime-path) racket/runtime-path)
@ -17,155 +18,152 @@
(define (do-initial-slides) (define (do-initial-slides)
(slide (slide
#:name "Title Slide" #:name "Title Slide"
(titlet "Slideshow Tutorial") (titlet "Slideshow Tutorial")
(blank) (blank)
(size-in-pixels (size-in-pixels
(bitmap (build-path (collection-path "icons") "PLT-206.png"))) (bitmap (build-path (collection-path "icons") "PLT-206.png")))
(blank) (blank)
(colorize (it "Press the spacebar to continue") "blue") (colorize (it "Press the spacebar to continue") "blue")
(comment "Welcome to Slideshow")) (comment "Welcome to Slideshow"))
(slide (slide
#:title "About Slideshow" #:title "About Slideshow"
(para (bt "Slideshow") (para (bt "Slideshow")
"is a library for creating slide presentations") "is a library for creating slide presentations")
(item "A Slideshow presentation is a PLT Scheme program") (item "A Slideshow presentation is a PLT Scheme program")
(item "Instead of a WYSIWYG interface," (item "Instead of a WYSIWYG interface,"
"you get the power of Scheme")) "you get the power of Scheme"))
(define (symbol n) (define (symbol n)
(text (string (integer->char n)) 'symbol (current-font-size))) (text (string (integer->char n)) 'symbol (current-font-size)))
(define sym:rightarrow (symbol 174)) (define sym:rightarrow (symbol 174))
(define sym:leftarrow (symbol 172)) (define sym:leftarrow (symbol 172))
(define (meta key) (define (meta key)
(hbl-append (t "Alt-") (hbl-append (t "Alt-")
(if (pict? key) key (tt key)) (if (pict? key) key (tt key))
(t ", Cmd-") (t ", Cmd-")
(if (pict? key) key (tt key)) (if (pict? key) key (tt key))
(t ", or Meta-") (t ", or Meta-")
(if (pict? key) key (tt key)))) (if (pict? key) key (tt key))))
(slide (slide
#:title "How to Control this Viewer" #:title "How to Control this Viewer"
(scale/improve-new-text (scale/improve-new-text
(table 3 (table 3
(apply (append-map
append (lambda (s) (list (para #:fill? #f (car s)) (t ":") (t (cadr s))))
(map (lambda (s) `(((,(meta "q")) "end show")
(list (para #:fill? #f (car s)) (t ":") (t (cadr s)))) (("Esc") "if confirmed, end show")
`(((,(meta "q")) "end show") ((,sym:rightarrow ", Space," ,(tt "f") "," ,(tt "n") ", or click") "next slide")
(("Esc") "if confirmed, end show") ((,sym:leftarrow ", Backspace, Delete, or" ,(tt "b")) "previous slide")
((,sym:rightarrow ", Space," ,(tt "f") "," ,(tt "n") ", or click") "next slide") ((,(tt "g")) "last slide")
((,sym:leftarrow ", Backspace, Delete, or" ,(tt "b")) "previous slide") ((,(tt "1")) "first slide")
((,(tt "g")) "last slide") ((,(meta "g")) "select a slide")
((,(tt "1")) "first slide") ((,(meta "p")) "show/hide slide number")
((,(meta "g")) "select a slide") ((,(meta "c")) "show/hide commentary")
((,(meta "p")) "show/hide slide number") ((,(meta "d")) "show/hide preview")
((,(meta "c")) "show/hide commentary") ((,(meta "m")) "show/hide mouse cursor")
((,(meta "d")) "show/hide preview") ((,(hbl-append (t "Shift-") sym:rightarrow) ", etc.") "move window 1 pixel")
((,(meta "m")) "show/hide mouse cursor") ((,(meta sym:rightarrow) ", etc.") "move window 10 pixels")))
((,(hbl-append (t "Shift-") sym:rightarrow) ", etc.") "move window 1 pixel") lbl-superimpose lbl-superimpose
((,(meta sym:rightarrow) ", etc.") "move window 10 pixels")))) gap-size (/ gap-size 2))
lbl-superimpose lbl-superimpose 0.9)
gap-size (/ gap-size 2)) (comment "This window shows comments for each slide. "
0.9) "The comments are typically fill in the details of what "
(comment "This window shows comments for each slide. " "the slide presenter says when giving the talk."))
"The comments are typically fill in the details of what "
"the slide presenter says when giving the talk."))
(define mytalk.rkt (tt "mytalk.rkt"))
(define mytalk.rkt (tt "mytalk.rkt")) (slide
#:title "Slideshow Programs"
(para "A Slideshow program has the form")
(scale/improve-new-text
(code #,(tt "#lang") slideshow
... #,(it "code to generate slide content") ...)
0.9)
(colorize (hline (* 3/4 client-w) gap-size) "green")
'alts
(list (list (para "To run a Slideshow program,")
(item "Double-click the" (bt "Slideshow") "executable or run"
(tt "slideshow") "on the command line")
(item "Click the" (bt "Open File...") "link and select the"
"Slideshow program file, such as" mytalk.rkt))
(list (para "Alternately, run a Slideshow program in DrRacket:")
(item "Open" mytalk.rkt "in DrRacket")
(item #:bullet (blank (+ (pict-width bullet) gap-size) 0)
"DrRacket's language should change automatically to"
(bt "Module"))
(item "Click" (bt "Run") "in DrRacket")
(colorize (bt "Use DrRacket only if you trust the program") "red"))
(parameterize ([current-para-width client-w])
(list (para (colorize (bt "Important security information:") "red"))
(para "A slideshow program has access to the"
(it "full") (it "Racket") (it "language"))
(para "If you don't know the creator of a slide program"
"(or if you don't trust them), run the slides through the"
(bt "Slideshow") "executable or"
(tt "slideshow") "command line")
(colorize
(para
"When run in" (bt "Slideshow") "instead of DrRacket,"
"a slide program cannot write files"
"or make network connections")
"blue")))
(list (para "When using a command line, you can specify the program directly:")
(hbl-append (tt "slideshow ") mytalk.rkt)
(blank)
(para "To print the talk:")
(hbl-append (tt "slideshow --print ") mytalk.rkt)
(blank)
(colorize
(para #:align 'right (it "Run") (tt "slideshow --help") (it "for more options"))
"blue"))))
(define (sub-para . l)
(colorize (para #:width (* 3/4 (current-para-width)) l) "blue"))
(slide (slide
#:title "Slideshow Programs" #:title "Slides and Picts"
(para "A Slideshow program has the form") (para "The body of a Slideshow program")
(scale/improve-new-text (item #:bullet (bt " 1.")
(code #,(tt "#lang") slideshow "Makes and combines" (hbl-append (bit "pict") (t "s")))
... #,(it "code to generate slide content") ...) (sub-para "For example,")
0.9) (code (t "Hello"))
(colorize (hline (* 3/4 client-w) gap-size) "green") (sub-para "creates a pict like this:")
'alts (colorize (t "Hello") "black")
(list (list (para "To run a Slideshow program,") (item #:bullet (bt " 2.") "Registers certain picts as slides")
(item "Double-click the" (bt "Slideshow") "executable or run" (sub-para "For example,")
(tt "slideshow") "on the command line") (code (slide (t "Hello")))
(item "Click the" (bt "Open File...") "link and select the" (sub-para "registers a slide containing only" (colorize (t "Hello") "black")))
"Slideshow program file, such as" mytalk.rkt))
(list (para "Alternately, run a Slideshow program in DrRacket:")
(item "Open" mytalk.rkt "in DrRacket")
(item #:bullet (blank (+ (pict-width bullet) gap-size) 0)
"DrRacket's language should change automatically to"
(bt "Module"))
(item "Click" (bt "Run") "in DrRacket")
(colorize (bt "Use DrRacket only if you trust the program") "red"))
(parameterize ([current-para-width client-w])
(list (para (colorize (bt "Important security information:") "red"))
(para "A slideshow program has access to the"
(it "full") (it "Racket") (it "language"))
(para "If you don't know the creator of a slide program"
"(or if you don't trust them), run the slides through the"
(bt "Slideshow") "executable or"
(tt "slideshow") "command line")
(colorize
(para
"When run in" (bt "Slideshow") "instead of DrRacket,"
"a slide program cannot write files"
"or make network connections")
"blue")))
(list (para "When using a command line, you can specify the program directly:")
(hbl-append (tt "slideshow ") mytalk.rkt)
(blank)
(para "To print the talk:")
(hbl-append (tt "slideshow --print ") mytalk.rkt)
(blank)
(colorize
(para #:align 'right (it "Run") (tt "slideshow --help") (it "for more options"))
"blue"))))
(define (sub-para . l) (slide
(colorize (para #:width (* 3/4 (current-para-width)) l) "blue")) #:title "The Rest of the Tutorial"
(para "The rest of this tutorial (starting with the next slide) is meant to"
"be viewed while reading the program source")
(blank)
(para #:width client-w "The source is")
(let ([s (path->string tutorial-show)])
(clickback
(scale/improve-new-text
(let ([p (tt s)])
(colorize
(pin-over p 0 (pict-height p)
(linewidth 2 (hline (pict-width p) 2)))
"blue"))
(min 1 (/ (* 0.8 client-w ) (pict-width (tt s)))))
(lambda ()
(let* ([f (new frame% [label (path-element->string
(file-name-from-path tutorial-show))]
[width 600] [height 400])]
[e (new text%)]
[c (new editor-canvas% [parent f] [editor e])])
(send e load-file s)
(send e change-style
(make-object style-delta% 'change-family 'modern)
0 'end)
(send f show #t))))))
(slide )
#:title "Slides and Picts"
(para "The body of a Slideshow program")
(item #:bullet (bt " 1.")
"Makes and combines" (hbl-append (bit "pict") (t "s")))
(sub-para "For example,")
(code (t "Hello"))
(sub-para "creates a pict like this:")
(colorize (t "Hello") "black")
(item #:bullet (bt " 2.") "Registers certain picts as slides")
(sub-para "For example,")
(code (slide (t "Hello")))
(sub-para "registers a slide containing only" (colorize (t "Hello") "black")))
(slide
#:title "The Rest of the Tutorial"
(para "The rest of this tutorial (starting with the next slide) is meant to"
"be viewed while reading the program source")
(blank)
(para #:width client-w "The source is")
(let ([s (path->string tutorial-show)])
(clickback
(scale/improve-new-text
(let ([p (tt s)])
(colorize
(pin-over p 0 (pict-height p)
(linewidth 2 (hline (pict-width p) 2)))
"blue"))
(min 1 (/ (* 0.8 client-w ) (pict-width (tt s)))))
(lambda ()
(let* ([f (new frame% [label (path-element->string
(file-name-from-path tutorial-show))]
[width 600] [height 400])]
[e (new text%)]
[c (new editor-canvas% [parent f] [editor e])])
(send e load-file s)
(send e change-style
(make-object style-delta% 'change-family 'modern)
0 'end)
(send f show #t))))))
)