Add quit command
parent
0c68807814
commit
67f50d95f4
|
@ -779,6 +779,17 @@ Alternatives(&[to_stream!(One(Literal("add-attachment")), One(Filepath)), to_str
|
||||||
Ok((input, ToggleMouse))
|
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,
|
account_action,
|
||||||
print_setting,
|
print_setting,
|
||||||
toggle_mouse,
|
toggle_mouse,
|
||||||
|
quit,
|
||||||
))(input)
|
))(input)
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
.map_err(|err| err.into())
|
.map_err(|err| err.into())
|
||||||
|
|
|
@ -122,6 +122,7 @@ pub enum Action {
|
||||||
AccountAction(AccountName, AccountAction),
|
AccountAction(AccountName, AccountAction),
|
||||||
PrintSetting(String),
|
PrintSetting(String),
|
||||||
ToggleMouse,
|
ToggleMouse,
|
||||||
|
Quit,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Action {
|
impl Action {
|
||||||
|
@ -141,6 +142,7 @@ impl Action {
|
||||||
Action::AccountAction(_, _) => false,
|
Action::AccountAction(_, _) => false,
|
||||||
Action::PrintSetting(_) => false,
|
Action::PrintSetting(_) => false,
|
||||||
Action::ToggleMouse => false,
|
Action::ToggleMouse => false,
|
||||||
|
Action::Quit => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -982,6 +982,12 @@ impl State {
|
||||||
self.set_mouse(self.mouse);
|
self.set_mouse(self.mouse);
|
||||||
self.rcv_event(UIEvent::StatusEvent(StatusEvent::SetMouse(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 => {
|
v => {
|
||||||
self.rcv_event(UIEvent::Action(v));
|
self.rcv_event(UIEvent::Action(v));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue