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