Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename next/previous slide bindings to next/previous #155

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ fn default_typst_ppi() -> u32 {
#[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct KeyBindingsConfig {
#[serde(default = "default_next_slide_bindings")]
pub(crate) next_slide: Vec<KeyBinding>,
#[serde(default = "default_next_bindings")]
pub(crate) next: Vec<KeyBinding>,

#[serde(default = "default_previous_slide_bindings")]
pub(crate) previous_slide: Vec<KeyBinding>,
#[serde(default = "default_previous_bindings")]
pub(crate) previous: Vec<KeyBinding>,

#[serde(default = "default_first_slide_bindings")]
pub(crate) first_slide: Vec<KeyBinding>,
Expand Down Expand Up @@ -122,8 +122,8 @@ pub struct KeyBindingsConfig {
impl Default for KeyBindingsConfig {
fn default() -> Self {
Self {
next_slide: default_next_slide_bindings(),
previous_slide: default_previous_slide_bindings(),
next: default_next_bindings(),
previous: default_previous_bindings(),
first_slide: default_first_slide_bindings(),
last_slide: default_last_slide_bindings(),
go_to_slide: default_go_to_slide_bindings(),
Expand All @@ -145,11 +145,11 @@ fn make_keybindings<const N: usize>(raw_bindings: [&str; N]) -> Vec<KeyBinding>
bindings
}

fn default_next_slide_bindings() -> Vec<KeyBinding> {
fn default_next_bindings() -> Vec<KeyBinding> {
make_keybindings(["l", "j", "<right>", "<page_down>", "<down>", " "])
}

fn default_previous_slide_bindings() -> Vec<KeyBinding> {
fn default_previous_bindings() -> Vec<KeyBinding> {
make_keybindings(["h", "k", "<left>", "<page_up>", "<up>"])
}

Expand Down
2 changes: 1 addition & 1 deletion src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<'a> Exporter<'a> {
let mut next_slide = |commands: &mut Vec<CaptureCommand>| {
commands.push(CaptureCommand::SendKeys { keys: "l" });
commands.push(CaptureCommand::WaitForChange);
presentation.jump_next_slide();
presentation.jump_next();
};
for chunks in slide_chunks {
for _ in 0..chunks - 1 {
Expand Down
8 changes: 4 additions & 4 deletions src/input/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ pub(crate) enum Command {
/// This can happen on terminal resize.
Redraw,

/// Go to the next slide.
NextSlide,
/// Move forward in the presentation.
Next,

/// Go to the previous slide.
PreviousSlide,
/// Move backwards in the presentation.
Previous,

/// Go to the first slide.
FirstSlide,
Expand Down
8 changes: 4 additions & 4 deletions src/input/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ impl CommandKeyBindings {
use CommandDiscriminants::*;
let command = match discriminant {
Redraw => Command::Redraw,
NextSlide => Command::NextSlide,
PreviousSlide => Command::PreviousSlide,
Next => Command::Next,
Previous => Command::Previous,
FirstSlide => Command::FirstSlide,
LastSlide => Command::LastSlide,
GoToSlide => {
Expand Down Expand Up @@ -123,8 +123,8 @@ impl TryFrom<KeyBindingsConfig> for CommandKeyBindings {
return Err(KeyBindingsValidationError::Invalid("go_to_slide", "<number> matcher required"));
}
let bindings: Vec<_> = iter::empty()
.chain(zip(CommandDiscriminants::NextSlide, config.next_slide))
.chain(zip(CommandDiscriminants::PreviousSlide, config.previous_slide))
.chain(zip(CommandDiscriminants::Next, config.next))
.chain(zip(CommandDiscriminants::Previous, config.previous))
.chain(zip(CommandDiscriminants::FirstSlide, config.first_slide))
.chain(zip(CommandDiscriminants::LastSlide, config.last_slide))
.chain(zip(CommandDiscriminants::GoToSlide, config.go_to_slide))
Expand Down
12 changes: 6 additions & 6 deletions src/presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ impl Presentation {
self.state.current_slide_index()
}

/// Jump to the next slide.
pub(crate) fn jump_next_slide(&mut self) -> bool {
/// Jump forwards.
pub(crate) fn jump_next(&mut self) -> bool {
let current_slide = self.current_slide_mut();
if current_slide.move_next() {
return true;
Expand All @@ -76,8 +76,8 @@ impl Presentation {
}
}

/// Jump to the previous slide.
pub(crate) fn jump_previous_slide(&mut self) -> bool {
/// Jump backwards.
pub(crate) fn jump_previous(&mut self) -> bool {
let current_slide = self.current_slide_mut();
if current_slide.move_previous() {
return true;
Expand Down Expand Up @@ -557,8 +557,8 @@ mod test {
match self {
First => presentation.jump_first_slide(),
Last => presentation.jump_last_slide(),
Next => presentation.jump_next_slide(),
Previous => presentation.jump_previous_slide(),
Next => presentation.jump_next(),
Previous => presentation.jump_previous(),
Specific(index) => presentation.go_to_slide(*index),
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/presenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ impl<'a> Presenter<'a> {
};
let needs_redraw = match command {
Command::Redraw => true,
Command::NextSlide => presentation.jump_next_slide(),
Command::PreviousSlide => presentation.jump_previous_slide(),
Command::Next => presentation.jump_next(),
Command::Previous => presentation.jump_previous(),
Command::FirstSlide => presentation.jump_first_slide(),
Command::LastSlide => presentation.jump_last_slide(),
Command::GoToSlide(number) => presentation.go_to_slide(number.saturating_sub(1) as usize),
Expand Down
4 changes: 2 additions & 2 deletions src/processing/modals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ impl KeyBindingsModalBuilder {
pub(crate) fn build(theme: &PresentationTheme, config: &KeyBindingsConfig) -> Vec<RenderOperation> {
let mut builder = ModalBuilder::new("Key bindings");
builder.content.extend([
Self::build_line("Next slide", &config.next_slide),
Self::build_line("Previous slide", &config.previous_slide),
Self::build_line("Next", &config.next),
Self::build_line("Previous", &config.previous),
Self::build_line("First slide", &config.first_slide),
Self::build_line("Last slide", &config.last_slide),
Self::build_line("Go to slide", &config.go_to_slide),
Expand Down
Loading