test functional for render, grid, input. Add some function. Add colot print in render ' pub fn print_c()', add offset for pos in render 'pub fn offset_pos()'. Create generete grid in main.rs as random value and test render this.

This commit is contained in:
lemon-cat committed 2026-05-14 18:04:42 +03:00
1 parent d9b301ea04
commit 9c61078414
4 files changed
+114 -29

No files matched your search

+23 -1
View File
@@ -3,7 +3,7 @@ use crossterm::{
event::{self, Event, KeyCode},
terminal::{disable_raw_mode, enable_raw_mode},
};
use std::io::{self, Write};
use std::io::{self, Write, stdout};
use crate::input;
@@ -29,6 +29,8 @@ pub fn Comand_pars() -> Result<ComandEvent, String> {
}
"key" => {
_ = enable_raw_mode();
let mut out = stdout();
_ = crossterm::execute!(out, crossterm::cursor::Hide);
return Ok(ComandEvent::Key);
}
_ => {}
@@ -42,18 +44,38 @@ pub enum KeyEvent {
None,
Exit,
Comand,
A,
W,
S,
D,
}
pub fn Key_pars() -> Result<Option<KeyEvent>, std::io::Error> {
if let Event::Key(key) = event::read()? {
match key.code {
KeyCode::Char('q') => {
_ = disable_raw_mode();
let mut out = stdout();
_ = crossterm::execute!(out, crossterm::cursor::Show);
return Ok(Some(KeyEvent::Exit));
}
KeyCode::Char('c') => {
_ = disable_raw_mode();
let mut out = stdout();
_ = crossterm::execute!(out, crossterm::cursor::Show);
return Ok(Some(KeyEvent::Comand));
}
KeyCode::Char('a') => {
return Ok(Some(KeyEvent::A));
}
KeyCode::Char('w') => {
return Ok(Some(KeyEvent::W));
}
KeyCode::Char('s') => {
return Ok(Some(KeyEvent::S));
}
KeyCode::Char('d') => {
return Ok(Some(KeyEvent::D));
}
_ => {}
}
}