refactor: TuiGuard -> TuiContext
This commit is contained in:
10
src/main.rs
10
src/main.rs
@ -221,11 +221,11 @@ fn get_initial_model(file_path: &Option<PathBuf>) -> Result<Model> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TuiGuard<'a> {
|
struct TuiContext<'a> {
|
||||||
terminal: Terminal<CrosstermBackend<&'a mut Stdout>>,
|
terminal: Terminal<CrosstermBackend<&'a mut Stdout>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TuiGuard<'a> {
|
impl<'a> TuiContext<'a> {
|
||||||
fn enter(out: &'a mut Stdout) -> Result<Self> {
|
fn enter(out: &'a mut Stdout) -> Result<Self> {
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
execute!(out, EnterAlternateScreen)?;
|
execute!(out, EnterAlternateScreen)?;
|
||||||
@ -236,7 +236,7 @@ impl<'a> TuiGuard<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Drop for TuiGuard<'a> {
|
impl<'a> Drop for TuiContext<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let _ = execute!(self.terminal.backend_mut(), LeaveAlternateScreen);
|
let _ = execute!(self.terminal.backend_mut(), LeaveAlternateScreen);
|
||||||
let _ = disable_raw_mode();
|
let _ = disable_raw_mode();
|
||||||
@ -249,9 +249,9 @@ fn run_tui(
|
|||||||
import_json: Option<serde_json::Value>,
|
import_json: Option<serde_json::Value>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut stdout = io::stdout();
|
let mut stdout = io::stdout();
|
||||||
let mut tui_context = TuiGuard::enter(&mut stdout)?;
|
let mut tui_context = TuiContext::enter(&mut stdout)?;
|
||||||
|
|
||||||
let mut app = App::new(model, file_path);
|
let mut app = App::new(model, file_path);
|
||||||
|
|
||||||
if let Some(json) = import_json {
|
if let Some(json) = import_json {
|
||||||
app.start_import_wizard(json);
|
app.start_import_wizard(json);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user