Migrate F12 log to AsyncWidget
This commit is contained in:
parent
b8da97aaa4
commit
6f0088e194
2 changed files with 15 additions and 5 deletions
14
src/ui.rs
14
src/ui.rs
|
|
@ -23,13 +23,13 @@ use toss::{Terminal, WidgetExt};
|
|||
use crate::config::Config;
|
||||
use crate::logger::{LogMsg, Logger};
|
||||
use crate::macros::{logging_unwrap, ok_or_return, some_or_return};
|
||||
use crate::util::InfallibleExt;
|
||||
use crate::vault::Vault;
|
||||
|
||||
pub use self::chat::ChatMsg;
|
||||
use self::chat::ChatState;
|
||||
use self::chat2::ChatState;
|
||||
use self::input::{key, InputEvent, KeyBindingsList};
|
||||
use self::rooms::Rooms;
|
||||
use self::widgets::WidgetWrapper;
|
||||
use self::widgets2::ListState;
|
||||
|
||||
/// Time to spend batch processing events before redrawing the screen.
|
||||
|
|
@ -44,6 +44,12 @@ pub enum UiError {
|
|||
Io(#[from] io::Error),
|
||||
}
|
||||
|
||||
impl From<Infallible> for UiError {
|
||||
fn from(value: Infallible) -> Self {
|
||||
Err(value).infallible()
|
||||
}
|
||||
}
|
||||
|
||||
pub enum UiEvent {
|
||||
GraphemeWidthsChanged,
|
||||
LogChanged,
|
||||
|
|
@ -197,9 +203,7 @@ impl Ui {
|
|||
|
||||
let widget = match self.mode {
|
||||
Mode::Main => self.rooms.widget().await,
|
||||
Mode::Log => {
|
||||
WidgetWrapper::new(self.log_chat.widget(String::new(), true)).boxed_async()
|
||||
}
|
||||
Mode::Log => self.log_chat.widget(String::new(), true),
|
||||
};
|
||||
|
||||
if let Some(key_bindings_list) = key_bindings_list {
|
||||
|
|
|
|||
|
|
@ -141,3 +141,9 @@ pub enum Reaction<M: Msg> {
|
|||
},
|
||||
ComposeError(io::Error),
|
||||
}
|
||||
|
||||
impl<M: Msg> Reaction<M> {
|
||||
pub fn handled(&self) -> bool {
|
||||
!matches!(self, Self::NotHandled)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue