Skip to content

Commit c85316e

Browse files
committed
Add command to jump to the first slide
1 parent 55c3a3e commit c85316e

File tree

11 files changed

+79
-7
lines changed

11 files changed

+79
-7
lines changed

lib/node_modules/@stdlib/repl/presentation/data/example.csv

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
currentSlide,"currentSlide\n"
2+
first,"first()\n"
23
jumpTo,"jumpTo( 2 )\n"
34
next,"next()\n"
45
numSlides,"numSlides\n"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"currentSlide":"currentSlide\n","jumpTo":"jumpTo( 2 )\n","next":"next()\n","numSlides":"numSlides\n","prev":"prev()\n","runSlide":"runSlide()\n"}
1+
{"currentSlide":"currentSlide\n","first":"first()\n","jumpTo":"jumpTo( 2 )\n","next":"next()\n","numSlides":"numSlides\n","prev":"prev()\n","runSlide":"runSlide()\n"}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
currentSlide,"\ncurrentSlide\n Returns the current presentation slide index.\n\n The returned index is the nominal (i.e., one-based) slide index.\n\n Returns\n -------\n idx: integer\n Current presentation slide index.\n\n Examples\n --------\n > currentSlide\n\n See Also\n --------\n jumpTo, next, numSlides, prev\n\n"
2+
first,"\nfirst()\n Jumps to the first slide.\n\n Examples\n --------\n > first()\n\n See Also\n --------\n jumpTo, last, next, prev\n\n"
23
jumpTo,"\njumpTo( n )\n Jumps to a specified slide, where `n` is the nominal slide number.\n\n Parameters\n ----------\n n: integer\n Nominal slide number (one-based).\n\n Examples\n --------\n > jumpTo( 2 )\n\n See Also\n --------\n next, prev\n\n"
3-
next,"\nnext()\n Moves the presentation to the next slide or slide fragment.\n\n Examples\n --------\n > next()\n\n See Also\n --------\n jumpTo, prev\n\n"
4+
next,"\nnext()\n Moves the presentation to the next slide or slide fragment.\n\n Examples\n --------\n > next()\n\n See Also\n --------\n first, jumpTo, last, prev\n\n"
45
numSlides,"\nnumSlides\n Returns the presentation length.\n\n Returns\n -------\n len: integer\n Number of slides.\n\n Examples\n --------\n > numSlides\n\n See Also\n --------\n currentSlide, jumpTo, next, prev\n\n"
5-
prev,"\nprev()\n Moves the presentation to the previous slide or slide fragment.\n\n Examples\n --------\n > prev()\n\n See Also\n --------\n jumpTo, next\n\n"
6+
prev,"\nprev()\n Moves the presentation to the previous slide or slide fragment.\n\n Examples\n --------\n > prev()\n\n See Also\n --------\n first, jumpTo, last, next\n\n"
67
runSlide,"\nrunSlide()\n Runs slide code.\n\n Examples\n --------\n > runSlide()\n\n See Also\n --------\n next, prev\n\n"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"currentSlide":"\ncurrentSlide\n Returns the current presentation slide index.\n\n The returned index is the nominal (i.e., one-based) slide index.\n\n Returns\n -------\n idx: integer\n Current presentation slide index.\n\n Examples\n --------\n > currentSlide\n\n See Also\n --------\n jumpTo, next, numSlides, prev\n\n","jumpTo":"\njumpTo( n )\n Jumps to a specified slide, where `n` is the nominal slide number.\n\n Parameters\n ----------\n n: integer\n \tNominal slide number (one-based).\n\n Examples\n --------\n > jumpTo( 2 )\n\n See Also\n --------\n next, prev\n\n","next":"\nnext()\n Moves the presentation to the next slide or slide fragment.\n\n Examples\n --------\n > next()\n\n See Also\n --------\n jumpTo, prev\n\n","numSlides":"\nnumSlides\n Returns the presentation length.\n\n Returns\n -------\n len: integer\n Number of slides.\n\n Examples\n --------\n > numSlides\n\n See Also\n --------\n currentSlide, jumpTo, next, prev\n\n","prev":"\nprev()\n Moves the presentation to the previous slide or slide fragment.\n\n Examples\n --------\n > prev()\n\n See Also\n --------\n jumpTo, next\n\n","runSlide":"\nrunSlide()\n Runs slide code.\n\n Examples\n --------\n > runSlide()\n\n See Also\n --------\n next, prev\n\n"}
1+
{"currentSlide":"\ncurrentSlide\n Returns the current presentation slide index.\n\n The returned index is the nominal (i.e., one-based) slide index.\n\n Returns\n -------\n idx: integer\n Current presentation slide index.\n\n Examples\n --------\n > currentSlide\n\n See Also\n --------\n jumpTo, next, numSlides, prev\n\n","first":"\nfirst()\n Jumps to the first slide.\n\n Examples\n --------\n > first()\n\n See Also\n --------\n jumpTo, last, next, prev\n\n","jumpTo":"\njumpTo( n )\n Jumps to a specified slide, where `n` is the nominal slide number.\n\n Parameters\n ----------\n n: integer\n \tNominal slide number (one-based).\n\n Examples\n --------\n > jumpTo( 2 )\n\n See Also\n --------\n next, prev\n\n","next":"\nnext()\n Moves the presentation to the next slide or slide fragment.\n\n Examples\n --------\n > next()\n\n See Also\n --------\n first, jumpTo, last, prev\n\n","numSlides":"\nnumSlides\n Returns the presentation length.\n\n Returns\n -------\n len: integer\n Number of slides.\n\n Examples\n --------\n > numSlides\n\n See Also\n --------\n currentSlide, jumpTo, next, prev\n\n","prev":"\nprev()\n Moves the presentation to the previous slide or slide fragment.\n\n Examples\n --------\n > prev()\n\n See Also\n --------\n first, jumpTo, last, next\n\n","runSlide":"\nrunSlide()\n Runs slide code.\n\n Examples\n --------\n > runSlide()\n\n See Also\n --------\n next, prev\n\n"}

lib/node_modules/@stdlib/repl/presentation/data/info.csv

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
currentSlide,"\ncurrentSlide\n Returns the current presentation slide index.\n"
2+
first,"\nfirst()\n Jumps to the first slide.\n"
23
jumpTo,"\njumpTo( n )\n Jumps to a specified slide, where `n` is the nominal slide number.\n"
34
next,"\nnext()\n Moves the presentation to the next slide or slide fragment.\n"
45
numSlides,"\nnumSlides\n Returns the presentation length.\n"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"currentSlide":"\ncurrentSlide\n Returns the current presentation slide index.\n","jumpTo":"\njumpTo( n )\n Jumps to a specified slide, where `n` is the nominal slide number.\n","next":"\nnext()\n Moves the presentation to the next slide or slide fragment.\n","numSlides":"\nnumSlides\n Returns the presentation length.\n","prev":"\nprev()\n Moves the presentation to the previous slide or slide fragment.\n","runSlide":"\nrunSlide()\n Runs slide code.\n"}
1+
{"currentSlide":"\ncurrentSlide\n Returns the current presentation slide index.\n","first":"\nfirst()\n Jumps to the first slide.\n","jumpTo":"\njumpTo( n )\n Jumps to a specified slide, where `n` is the nominal slide number.\n","next":"\nnext()\n Moves the presentation to the next slide or slide fragment.\n","numSlides":"\nnumSlides\n Returns the presentation length.\n","prev":"\nprev()\n Moves the presentation to the previous slide or slide fragment.\n","runSlide":"\nrunSlide()\n Runs slide code.\n"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
first()
3+
Jumps to the first slide.
4+
5+
Examples
6+
--------
7+
> first()
8+
9+
See Also
10+
--------
11+
jumpTo, last, next, prev
12+

lib/node_modules/@stdlib/repl/presentation/docs/commands/next.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ next()
88

99
See Also
1010
--------
11-
jumpTo, prev
11+
first, jumpTo, last, prev
1212

lib/node_modules/@stdlib/repl/presentation/docs/commands/prev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ prev()
88

99
See Also
1010
--------
11-
jumpTo, next
11+
first, jumpTo, last, next
1212

lib/node_modules/@stdlib/repl/presentation/lib/commands.js

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var onCurrentSlide = require( './commands/current_slide.js' );
24+
var onFirst = require( './commands/first.js' );
2425
var onJumpTo = require( './commands/jump_to.js' );
2526
var onNext = require( './commands/next.js' );
2627
var onNumSlides = require( './commands/num_slides.js' );
@@ -53,6 +54,7 @@ function commands( pres ) {
5354
// Define a list of REPL presentation-specific commands (NOTE: keep in alphabetical order):
5455
cmds = [];
5556
cmds.push( [ 'currentSlide', '', onCurrentSlide( pres ), true ] );
57+
cmds.push( [ 'first', 'f', onFirst( pres ), false ] );
5658
cmds.push( [ 'jumpTo', 'j', onJumpTo( pres ), false ] );
5759
cmds.push( [ 'next', 'n', onNext( pres ), false ] );
5860
cmds.push( [ 'numSlides', '', onNumSlides( pres ), true ] );
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MAIN //
22+
23+
/**
24+
* Returns a callback to be invoked upon calling the `first` command.
25+
*
26+
* @private
27+
* @param {Presentation} pres - presentation instance
28+
* @returns {Function} callback
29+
*/
30+
function command( pres ) {
31+
return onCommand;
32+
33+
/**
34+
* Jumps to the first slide.
35+
*
36+
* @private
37+
*/
38+
function onCommand() {
39+
pres._repl.once( 'drain', onDrain ); // eslint-disable-line no-underscore-dangle
40+
41+
/**
42+
* Callback invoked upon a `drain` event.
43+
*
44+
* @private
45+
*/
46+
function onDrain() {
47+
pres.first().show();
48+
}
49+
}
50+
}
51+
52+
53+
// EXPORTS //
54+
55+
module.exports = command;

0 commit comments

Comments
 (0)