Skip to content

Commit

Permalink
Remove WidgetRet::Quit and TUIRet::Quit:
Browse files Browse the repository at this point in the history
These values are the same as the `WidgetRet::Command` and
`TUIRet::Command` for the `/quit` command.

Replace them with the `Command` variants to avoid representing the same
thing in multiple ways.
  • Loading branch information
osa1 committed Apr 6, 2024
1 parent bd34531 commit c6d380c
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion crates/libtiny_tui/src/exit_dialogue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl ExitDialogue {

pub(crate) fn keypressed(&self, key_action: &KeyAction) -> WidgetRet {
match key_action {
KeyAction::Input('y') | KeyAction::InputSend => WidgetRet::Quit,
KeyAction::Input('y') | KeyAction::InputSend => WidgetRet::Command("quit".to_string()),
_ => WidgetRet::Remove,
}
}
Expand Down
6 changes: 0 additions & 6 deletions crates/libtiny_tui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ async fn input_handler<S>(
Some(Ok(ev)) => {
let tui_ret = tui.borrow_mut().handle_input_event(ev, &mut rcv_editor_ret);
match tui_ret {
Some(TUIRet::Quit) => {
snd_ev.try_send(Event::Quit { msg: None }).unwrap();
let _ = snd_abort.try_send(());
return;
}

Some(TUIRet::KeyCommand { cmd, from }) => {
let result = tui.borrow_mut().try_handle_cmd(&cmd, &from);
match result {
Expand Down
5 changes: 0 additions & 5 deletions crates/libtiny_tui/src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ use termbox_simple::{CellBuf, Termbox};

#[derive(Debug)]
pub(crate) enum TUIRet {
/// User wants to quit.
Quit,

/// A command was submitted, either directly, or via a key bound to a command.
///
/// `cmd` won't have an initial '/'.
Expand Down Expand Up @@ -690,8 +687,6 @@ impl TUI {
}),

WidgetRet::Remove => unimplemented!(),

WidgetRet::Quit => Some(TUIRet::Quit),
}
}

Expand Down
3 changes: 0 additions & 3 deletions crates/libtiny_tui/src/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ pub(crate) enum WidgetRet {

/// Remove the widget. E.g. close the tab, hide the dialogue etc.
Remove,

/// User wants to quit, i.e. pressed `C-c <enter>` or a key bound to the `/quit` command.
Quit,
}

0 comments on commit c6d380c

Please sign in to comment.