show keyboard keys
This commit is contained in:
13
src/utils.rs
13
src/utils.rs
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user