From 39d54d257610706c918eb6cc3c87242b49d9016d Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 19 Sep 2012 10:34:08 -0600 Subject: [PATCH] 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'. --- collects/scribblings/slideshow/guide.scrbl | 2 ++ collects/slideshow/initial-ones.rkt | 4 ++-- collects/slideshow/viewer.rkt | 25 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/collects/scribblings/slideshow/guide.scrbl b/collects/scribblings/slideshow/guide.scrbl index f4d5ed3f66..bcdfc6a75e 100644 --- a/collects/scribblings/slideshow/guide.scrbl +++ b/collects/scribblings/slideshow/guide.scrbl @@ -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") diff --git a/collects/slideshow/initial-ones.rkt b/collects/slideshow/initial-ones.rkt index 64d585b963..6f8657f4c7 100644 --- a/collects/slideshow/initial-ones.rkt +++ b/collects/slideshow/initial-ones.rkt @@ -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") diff --git a/collects/slideshow/viewer.rkt b/collects/slideshow/viewer.rkt index e78546df86..4944896d5b 100644 --- a/collects/slideshow/viewer.rkt +++ b/collects/slideshow/viewer.rkt @@ -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?