Browse Source

Add quit command

jmap-eventsource
Manos Pitsidianakis 1 year ago
parent
commit
67f50d95f4
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 12
      src/command.rs
  2. 2
      src/command/actions.rs
  3. 6
      src/state.rs

12
src/command.rs

@ -779,6 +779,17 @@ Alternatives(&[to_stream!(One(Literal("add-attachment")), One(Filepath)), to_str
Ok((input, ToggleMouse))
}
)
},
{ tags: ["quit"],
desc: "quit meli",
tokens: &[One(Literal("quit"))],
parser:(
fn quit(input: &[u8]) -> IResult<&[u8], Action> {
let (input, _) = tag("quit")(input.trim())?;
let (input, _) = eof(input.trim())?;
Ok((input, Quit))
}
)
}
]);
@ -872,6 +883,7 @@ pub fn parse_command(input: &[u8]) -> Result<Action, MeliError> {
account_action,
print_setting,
toggle_mouse,
quit,
))(input)
.map(|(_, v)| v)
.map_err(|err| err.into())

2
src/command/actions.rs

@ -122,6 +122,7 @@ pub enum Action {
AccountAction(AccountName, AccountAction),
PrintSetting(String),
ToggleMouse,
Quit,
}
impl Action {
@ -141,6 +142,7 @@ impl Action {
Action::AccountAction(_, _) => false,
Action::PrintSetting(_) => false,
Action::ToggleMouse => false,
Action::Quit => true,
}
}
}

6
src/state.rs

@ -982,6 +982,12 @@ impl State {
self.set_mouse(self.mouse);
self.rcv_event(UIEvent::StatusEvent(StatusEvent::SetMouse(self.mouse)));
}
Quit => {
self.context
.sender
.send(ThreadEvent::Input((Key::Char('q'), vec![b'q'])))
.unwrap();
}
v => {
self.rcv_event(UIEvent::Action(v));
}

Loading…
Cancel
Save