Add keybinding for file reloading
This commit is contained in:
parent
337a60cef5
commit
5258447579
@ -43,7 +43,6 @@ pub enum Message {
|
||||
#[cfg(feature = "watch")]
|
||||
ToggleFileWatch,
|
||||
|
||||
#[cfg(feature = "watch")]
|
||||
ReloadFile,
|
||||
}
|
||||
|
||||
@ -139,7 +138,6 @@ fn handle_message(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "watch")]
|
||||
Message::ReloadFile => {
|
||||
state.reload_active_savefile()?;
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ fn handle_keyboard_input(
|
||||
msg_tx.send(Message::SetMode(Mode::SelectFile))?;
|
||||
}
|
||||
|
||||
(Mode::Normal, KeyCode::Char('r')) => {
|
||||
msg_tx.send(Message::ReloadFile)?;
|
||||
}
|
||||
|
||||
#[cfg(feature = "watch")]
|
||||
(Mode::Normal, KeyCode::Char('w')) => {
|
||||
msg_tx.send(Message::ToggleFileWatch)?;
|
||||
|
@ -4,6 +4,7 @@ use std::os::unix::prelude::OsStrExt;
|
||||
|
||||
use anyhow::Result;
|
||||
use jrny_save::Savefile;
|
||||
use tracing::debug;
|
||||
use tui_input::Input;
|
||||
|
||||
#[cfg(feature = "watch")]
|
||||
@ -92,10 +93,7 @@ impl State {
|
||||
self.file_watcher = None;
|
||||
}
|
||||
|
||||
#[cfg(feature = "watch")]
|
||||
pub fn reload_active_savefile(&mut self) -> Result<()> {
|
||||
use tracing::debug;
|
||||
|
||||
if let Some(cur_savefile) = &self.savefile {
|
||||
debug!("Reloading file");
|
||||
let new_savefile = Savefile::from_path(&cur_savefile.path)?;
|
||||
|
Loading…
Reference in New Issue
Block a user