show keyboard keys

This commit is contained in:
stjet
2025-02-07 06:31:56 +00:00
parent d182077e78
commit cb8d5abdbf
6 changed files with 217 additions and 26 deletions

View File

@@ -3,8 +3,10 @@ use std::path::PathBuf;
use termion::event::Key;
use crate::window_manager::KeyChar;
use crate::framebuffer::{ Dimensions, Point };
//use Linear A for escape, backspace, enter
//Linear A used only internally in onscreen keyboard: 𐘎 is alt, 𐘧 is switch board, 𐘾 is ctrl
pub fn key_to_char(key: Key) -> Option<KeyChar> {
match key {
Key::Char('\n') => Some(KeyChar::Press('𐘂')),
@@ -41,7 +43,6 @@ impl Substring for String {
break;
}
byte_end += char_length;
}
&self[byte_start..byte_end]
}
@@ -146,3 +147,13 @@ pub fn is_hex(c: char) -> bool {
HEX_CHARS.iter().position(|hc| hc == &c).is_some()
}
pub fn point_inside(point: Point, top_left: Point, size: Dimensions) -> bool {
let x = point[0];
let y = point[1];
let x2 = top_left[0];
let y2 = top_left[1];
let x3 = x2 + size[0];
let y3 = y2 + size[1];
x >= x2 && y >= x2 && x <= x3 && y <= y3
}