Slideshow viewer: "s" and "a" keys navigate next/previous by title

The new keys are useful for skipping animation groups. They
actually navigate by slide name, which defaults to the slide title,
but can be specified separately with the `#:name' argument to
`slide'.
This commit is contained in:
Matthew Flatt 2012-09-19 10:34:08 -06:00
parent 8a02ff54ac
commit 39d54d2576
3 changed files with 29 additions and 2 deletions

View File

@ -63,6 +63,8 @@ Alt-q (or Meta-q) to end the slides. Here are more controls:
(list "Left arrow, Backspace, Delete, or b" "previous slide")
(list "g" "last slide")
(list "1" "first slide")
(list "s" "next slide with a different title/name")
(list "a" "previous slide starting different title/name")
(list "Alt-g, Cmd-g, or Meta-g" "select a slide")
(list "Alt-p, Cmd-p, or Meta-p" "show/hide slide number")
(list "Alt-c, Cmd-c, or Meta-c" "show/hide commentary")

View File

@ -57,8 +57,8 @@
(("Esc") "if confirmed, end show")
((,sym:rightarrow ", Space," ,(tt "f") "," ,(tt "n") ", or click") "next slide")
((,sym:leftarrow ", Backspace, Delete, or" ,(tt "b")) "previous slide")
((,(tt "g")) "last slide")
((,(tt "1")) "first slide")
((,(tt "1") "/" ,(tt "g")) "first/last slide")
((,(tt "a") "/" ,(tt "s")) "previous/next slide name")
((,(meta "g")) "select a slide")
((,(meta "p")) "show/hide slide number")
((,(meta "c")) "show/hide commentary")

View File

@ -229,6 +229,10 @@
[(#\b #\backspace #\rubout prior)
(prev)
#t]
[(#\s)
(next-title add1 #f)]
[(#\a)
(next-title sub1 #t)]
[(#\g)
(stop-transition)
(send f set-blank-cursor #f)
@ -355,6 +359,27 @@
(stop-transition)
(change-slide 1)))
(define/public (next-title d1 far-end?)
;; skip to next slide that has a different title
(stop-transition)
(define current-title (sliderec-title (talk-list-ref current-page)))
(change-slide
(- (let loop ([pos (d1 current-page)])
(cond
[(negative? pos) 0]
[(= pos slide-count) (sub1 slide-count)]
[(equal? current-title (sliderec-title (talk-list-ref pos))) (loop (d1 pos))]
[far-end?
(define new-title (sliderec-title (talk-list-ref pos)))
(let loop ([prev-pos pos] [pos (d1 pos)])
(cond
[(negative? pos) 0]
[(= pos slide-count) (sub1 slide-count)]
[(equal? new-title (sliderec-title (talk-list-ref pos))) (loop pos (d1 pos))]
[else prev-pos]))]
[else pos]))
current-page)))
(define/public (slide-changed pos)
(when (or (= pos current-page)
(and (or config:use-prefetch?