commit 912a35175769f79e089141266311164b1db78a6e
parent 14cc24802c51eb0a4348144a9633f89ee0423cb8
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 19 Jun 2023 15:48:20 +0200
Update user interface
Enter is no longer an alias for the 'n' command: it now repeats the last
action. We've also added the [1..n]gg command, which allows the user to
go directly to a specific slide.
Diffstat:
| M | diaposishell | | | 36 | ++++++++++++++++++++++++++---------- |
| M | diaposishell.1 | | | 63 | +++++++++++++++++++++++++++++++++++++++------------------------ |
2 files changed, 65 insertions(+), 34 deletions(-)
diff --git a/diaposishell b/diaposishell
@@ -17,6 +17,7 @@
islide=0 # Index of the current slide
nslides=0 # Number of slides to display
+input="n"
################################################################################
# Helper functions
@@ -50,9 +51,11 @@ short_help()
{
printf "G last\n"
printf "g first\n"
- printf "n, Enter next\n"
+ printf "<i>gg <i>th slide\n"
+ printf "n next\n"
printf "p previous\n"
printf "q quit\n"
+ printf "Enter repeat last action\n"
printf "\n"
printf "Enter to quit help\n"
}
@@ -127,14 +130,27 @@ while true; do
# Handle user action
else
- case "${c}" in
- h|\?) islide=$((-islide));;
- g) islide=1;;
- G) islide="${nslides}";;
- ''|n) islide=$(next_slide);;
- p) islide=$(prev_slide);;
- q) break;;
- *);; # Default: do nothing
- esac
+ save_input="${input}"
+ [ -z "${c}" ] && c=${input} # Use previous action
+ input="${c}"
+
+ if echo "${c}" | grep -Eq "^[0-9]+gg$"; then
+ islide="${c%gg}"
+ [ "${islide}" -lt "1" ] && islide=1
+ [ "${islide}" -gt "${nslides}" ] && islide="${nslides}"
+
+ else
+ case "${c}" in
+ h|\?) islide=$((-islide));;
+ g) islide=1;;
+ G) islide="${nslides}";;
+ n) islide=$(next_slide);;
+ p) islide=$(prev_slide);;
+ q) break;;
+
+ # Invalid user input. Restore the input to the previous one
+ *) input="${save_input}";;
+ esac
+ fi
fi
done
diff --git a/diaposishell.1 b/diaposishell.1
@@ -1,17 +1,18 @@
-\" Copyright (C) 2023 |Méso|Star> (contact@meso-star.com)
-\"
-\" This program is free software: you can redistribute it and/or modify
-\" it under the terms of the GNU General Public License as published by
-\" the Free Software Foundation, either version 3 of the License, or
-\" (at your option) any later version.
-\"
-\" This program is distributed in the hope that it will be useful,
-\" but WITHOUT ANY WARRANTY; without even the implied warranty of
-\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-\" GNU General Public License for more details.
-\"
-\" You should have received a copy of the GNU General Public License
-\" along with this program. If not, see <http://www.gnu.org/licenses/>.
+.\"
+.\" Copyright (C) 2023 |Méso|Star> (contact@meso-star.com)
+.\"
+.\" This program is free software: you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation, either version 3 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
.Dd June 12, 2023
.Dt DIAPOSISHELL 1
.Os
@@ -39,22 +40,36 @@ The options are as follows:
Enable shebang detection to allow slides to be run.
.El
.Sh KEYBINDS
-The following keybinds are validated by pressing the Enter key. By
-default, an empty entry corresponds to command
-.Ar n ,
-i.e. moving on to the next slide.
+The following keybinds are validated by pressing Enter. An empty entry
+repeats the last action. If no action has yet been performed, you move
+on to the next slide.
.Bl -tag -width Ds
-.It Ar h , \&?
+.It Cm h , \&?
Display short help.
-.It Ar G
+.It Cm G
Go to the last slide.
-.It Ar g
+.It Cm g
Go to the first slide.
-.It Ar n
+.Sm off
+.It Oo Ar 1..n Oc Xo
+.Cm gg
+.Sm on
+.Xc
+Go to the
+.Sm off
+.Ar i
+th
+.Sm on
+slide in
+.Oo Ar 1..n Oc
+with
+.Ar n
+the number of slides.
+.It Cm n
Go to next slide.
-.It Ar p
+.It Cm p
Go to previous slide.
-.It Ar q
+.It Cm q
Quit.
.El
.Sh EXIT STATUS