Add error popup when external editor fails
This commit is contained in:
parent
4c7ac31699
commit
9aac9f6fdd
10 changed files with 95 additions and 90 deletions
|
|
@ -1,9 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use crossterm::style::{ContentStyle, Stylize};
|
||||
use euphoxide::api::PersonalAccountView;
|
||||
use euphoxide::conn::Status;
|
||||
use parking_lot::FairMutex;
|
||||
use toss::terminal::Terminal;
|
||||
|
||||
use crate::euph::Room;
|
||||
|
|
@ -133,7 +130,7 @@ impl AccountUiState {
|
|||
Focus::Password => bindings.binding("enter", "log in"),
|
||||
}
|
||||
bindings.binding("tab", "switch focus");
|
||||
util::list_editor_key_bindings(bindings, |c| c != '\n', false);
|
||||
util::list_editor_key_bindings(bindings, |c| c != '\n');
|
||||
}
|
||||
Self::LoggedIn(_) => bindings.binding("L", "log out"),
|
||||
}
|
||||
|
|
@ -142,7 +139,6 @@ impl AccountUiState {
|
|||
pub fn handle_input_event(
|
||||
&mut self,
|
||||
terminal: &mut Terminal,
|
||||
crossterm_lock: &Arc<FairMutex<()>>,
|
||||
event: &InputEvent,
|
||||
room: &Option<Room>,
|
||||
) -> EventResult {
|
||||
|
|
@ -170,10 +166,8 @@ impl AccountUiState {
|
|||
if util::handle_editor_input_event(
|
||||
&logged_out.email,
|
||||
terminal,
|
||||
crossterm_lock,
|
||||
event,
|
||||
|c| c != '\n',
|
||||
false,
|
||||
) {
|
||||
EventResult::Handled
|
||||
} else {
|
||||
|
|
@ -192,10 +186,8 @@ impl AccountUiState {
|
|||
if util::handle_editor_input_event(
|
||||
&logged_out.password,
|
||||
terminal,
|
||||
crossterm_lock,
|
||||
event,
|
||||
|c| c != '\n',
|
||||
false,
|
||||
) {
|
||||
EventResult::Handled
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use parking_lot::FairMutex;
|
||||
use toss::terminal::Terminal;
|
||||
|
||||
use crate::euph::Room;
|
||||
|
|
@ -23,7 +20,7 @@ pub fn widget(editor: &EditorState) -> BoxedWidget {
|
|||
pub fn list_key_bindings(bindings: &mut KeyBindingsList) {
|
||||
bindings.binding("esc", "abort");
|
||||
bindings.binding("enter", "authenticate");
|
||||
util::list_editor_key_bindings(bindings, |_| true, false);
|
||||
util::list_editor_key_bindings(bindings, |_| true);
|
||||
}
|
||||
|
||||
pub enum EventResult {
|
||||
|
|
@ -34,7 +31,6 @@ pub enum EventResult {
|
|||
|
||||
pub fn handle_input_event(
|
||||
terminal: &mut Terminal,
|
||||
crossterm_lock: &Arc<FairMutex<()>>,
|
||||
event: &InputEvent,
|
||||
room: &Option<Room>,
|
||||
editor: &EditorState,
|
||||
|
|
@ -48,14 +44,7 @@ pub fn handle_input_event(
|
|||
EventResult::ResetState
|
||||
}
|
||||
_ => {
|
||||
if util::handle_editor_input_event(
|
||||
editor,
|
||||
terminal,
|
||||
crossterm_lock,
|
||||
event,
|
||||
|_| true,
|
||||
false,
|
||||
) {
|
||||
if util::handle_editor_input_event(editor, terminal, event, |_| true) {
|
||||
EventResult::Handled
|
||||
} else {
|
||||
EventResult::NotHandled
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use euphoxide::conn::Joined;
|
||||
use parking_lot::FairMutex;
|
||||
use toss::styled::Styled;
|
||||
use toss::terminal::Terminal;
|
||||
|
||||
|
|
@ -34,7 +31,7 @@ fn nick_char(c: char) -> bool {
|
|||
pub fn list_key_bindings(bindings: &mut KeyBindingsList) {
|
||||
bindings.binding("esc", "abort");
|
||||
bindings.binding("enter", "set nick");
|
||||
util::list_editor_key_bindings(bindings, nick_char, false);
|
||||
util::list_editor_key_bindings(bindings, nick_char);
|
||||
}
|
||||
|
||||
pub enum EventResult {
|
||||
|
|
@ -45,7 +42,6 @@ pub enum EventResult {
|
|||
|
||||
pub fn handle_input_event(
|
||||
terminal: &mut Terminal,
|
||||
crossterm_lock: &Arc<FairMutex<()>>,
|
||||
event: &InputEvent,
|
||||
room: &Option<Room>,
|
||||
editor: &EditorState,
|
||||
|
|
@ -59,14 +55,7 @@ pub fn handle_input_event(
|
|||
EventResult::ResetState
|
||||
}
|
||||
_ => {
|
||||
if util::handle_editor_input_event(
|
||||
editor,
|
||||
terminal,
|
||||
crossterm_lock,
|
||||
event,
|
||||
nick_char,
|
||||
false,
|
||||
) {
|
||||
if util::handle_editor_input_event(editor, terminal, event, nick_char) {
|
||||
EventResult::Handled
|
||||
} else {
|
||||
EventResult::NotHandled
|
||||
|
|
|
|||
|
|
@ -380,6 +380,13 @@ impl EuphRoom {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
Reaction::ComposeError(e) => {
|
||||
self.popups.push_front(RoomPopup::Error {
|
||||
description: "Failed to use external editor".to_string(),
|
||||
reason: format!("{e}"),
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if self.handle_inspect_initiating_input_event(event).await {
|
||||
|
|
@ -470,8 +477,7 @@ impl EuphRoom {
|
|||
.await
|
||||
}
|
||||
State::Auth(editor) => {
|
||||
match auth::handle_input_event(terminal, crossterm_lock, event, &self.room, editor)
|
||||
{
|
||||
match auth::handle_input_event(terminal, event, &self.room, editor) {
|
||||
auth::EventResult::NotHandled => false,
|
||||
auth::EventResult::Handled => true,
|
||||
auth::EventResult::ResetState => {
|
||||
|
|
@ -481,8 +487,7 @@ impl EuphRoom {
|
|||
}
|
||||
}
|
||||
State::Nick(editor) => {
|
||||
match nick::handle_input_event(terminal, crossterm_lock, event, &self.room, editor)
|
||||
{
|
||||
match nick::handle_input_event(terminal, event, &self.room, editor) {
|
||||
nick::EventResult::NotHandled => false,
|
||||
nick::EventResult::Handled => true,
|
||||
nick::EventResult::ResetState => {
|
||||
|
|
@ -492,7 +497,7 @@ impl EuphRoom {
|
|||
}
|
||||
}
|
||||
State::Account(account) => {
|
||||
match account.handle_input_event(terminal, crossterm_lock, event, &self.room) {
|
||||
match account.handle_input_event(terminal, event, &self.room) {
|
||||
account::EventResult::NotHandled => false,
|
||||
account::EventResult::Handled => true,
|
||||
account::EventResult::ResetState => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue