Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
41558ecddd
25
src/main.rs
25
src/main.rs
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
use std::io::{stdin, stdout, Read, Write};
|
||||
use std::io::{stdin, stdout, Read, Stdout, Write};
|
||||
|
||||
use crossterm::{cursor, event, terminal, ExecutableCommand, Result};
|
||||
use event::{Event, KeyCode, KeyEvent};
|
||||
|
@ -266,19 +266,24 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let text = include_str!("main.rs");
|
||||
let mut state = State::from_str(text);
|
||||
let mut stdout = stdout();
|
||||
terminal::enable_raw_mode()?;
|
||||
stdout.execute(terminal::EnterAlternateScreen)?;
|
||||
|
||||
fn screen_main(stdout: &mut Stdout, mut state: State) -> Result<()> {
|
||||
while !state.quit {
|
||||
state.draw(&mut stdout)?;
|
||||
state.draw(stdout)?;
|
||||
let event = event::read()?;
|
||||
state.on_event(event);
|
||||
}
|
||||
|
||||
stdout.execute(terminal::LeaveAlternateScreen)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let text = include_str!("main.rs");
|
||||
let state = State::from_str(text);
|
||||
let mut stdout = stdout();
|
||||
terminal::enable_raw_mode()?;
|
||||
stdout.execute(terminal::EnterAlternateScreen)?;
|
||||
let result = screen_main(&mut stdout, state);
|
||||
stdout.execute(terminal::LeaveAlternateScreen)?;
|
||||
terminal::disable_raw_mode()?;
|
||||
result
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue