LoGin 7b32f5080f
增加内存分配日志监视器 (#424)
* 完成内存日志监视,并输出日志到文件
* 修复进程退出后,procfs查看进程status文件会崩溃的问题
* 修复signal唤醒进程的判断条件问题
2023-11-07 21:39:27 +08:00

36 lines
1009 B
Rust

use crate::{
app::{App, AppResult},
backend::event::BackendEvent,
};
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
/// Handles the key events and updates the state of [`App`].
pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
match key_event.code {
// Exit application on `ESC` or `q`
KeyCode::Esc | KeyCode::Char('q') => {
app.quit();
}
// Exit application on `Ctrl-C`
KeyCode::Char('c') | KeyCode::Char('C') => {
if key_event.modifiers == KeyModifiers::CONTROL {
app.quit();
}
}
// Counter handlers
KeyCode::Right => {
app.increment_counter();
}
KeyCode::Left => {
app.decrement_counter();
}
// Other handlers you could add here.
_ => {}
}
Ok(())
}
pub fn handle_backend_events(_backend_event: BackendEvent, _app: &mut App) -> AppResult<()> {
return Ok(());
}