v1.0.2: arrow keys, start menu paging support

key press convenience methods, fix logo, docs, add more chars
This commit is contained in:
stjet
2025-03-23 21:41:59 +00:00
parent cdb35767ac
commit fa4627316d
81 changed files with 278 additions and 86 deletions

View File

@@ -1,8 +1,9 @@
[package]
name = "ming-wm-lib"
version = "0.1.4"
version = "0.1.5"
repository = "https://github.com/stjet/ming-wm"
description = "library for building windows for ming-wm in rust"
readme = "README.md"
license = "GPL-3.0-or-later"
edition = "2021"

View File

@@ -1 +1,6 @@
Library for building [ming-wm](https://github.com/stjet/ming-wm) windows in Rust.
Documentation [here](https://docs.rs/ming-wm-lib).
The most likely usage of this crate is to implement the [WindowLike trait](https://docs.rs/ming-wm-lib/latest/ming_wm_lib/window_manager_types/trait.WindowLike.html), and then set up [IPC](https://docs.rs/ming-wm-lib/latest/ming_wm_lib/ipc/fn.listen.html) (which automatically handles serialisation).

View File

@@ -31,6 +31,7 @@ pub trait WindowLike {
const LOG: bool = false;
/// Listen and process what the window manager writes to our stdin
pub fn listen(mut window_like: impl WindowLike) {
panic::set_hook(Box::new(|panic_info| {
let (filename, line) = panic_info.location().map(|l| (l.file(), l.line())).unwrap_or(("<unknown>", 0));

View File

@@ -3,6 +3,7 @@ use std::io::Write;
use crate::dirs::data_dir;
/// Writes to `<XDG data directory>/ming-wm/logs.txt`. Use only for debugging!
pub fn log(message: &str) {
let data = data_dir().unwrap().into_os_string().into_string().unwrap();
let _ = create_dir(format!("{}/ming-wm", data));

View File

@@ -4,12 +4,14 @@ use std::vec::Vec;
use crate::framebuffer_types::Dimensions;
use crate::window_manager_types::{ WindowLike, KeyChar };
/// Window manager internal usage
pub enum WindowManagerMessage {
KeyChar(KeyChar),
Touch(usize, usize),
//
}
/// Window manager internal usage
pub type WindowBox = Box<dyn WindowLike>;
/*
@@ -50,10 +52,50 @@ impl WindowMessageResponse {
}
}
//struct because may add more fields later (so struct is better for code backward compatibility)
pub struct KeyPress {
pub key: char,
}
impl KeyPress {
pub fn is_enter(&self) -> bool {
self.key == '𐘂'
}
pub fn is_backspace(&self) -> bool {
self.key == '𐘁'
}
pub fn is_escape(&self) -> bool {
self.key == '𐘃'
}
pub fn is_up_arrow(&self) -> bool {
self.key == '𐙘'
}
pub fn is_down_arrow(&self) -> bool {
self.key == '𐘞'
}
pub fn is_left_arrow(&self) -> bool {
self.key == '𐙣'
}
pub fn is_right_arrow(&self) -> bool {
self.key == '𐙥'
}
pub fn is_arrow(&self) -> bool {
self.is_up_arrow() || self.is_down_arrow() || self.is_left_arrow() || self.is_right_arrow()
}
/// Is not enter, backspace, arrow keys (the Linear A stuff)
pub fn is_regular(&self) -> bool {
!self.is_enter() && !self.is_backspace() && !self.is_escape() && !self.is_arrow()
}
}
#[derive(Clone, Copy, PartialEq)]
pub enum Direction {
Left,
@@ -87,7 +129,7 @@ pub type WindowsVec = Vec<(usize, String)>;
#[non_exhaustive]
pub enum InfoType {
//let taskbar know what the current windows in the workspace are
/// Let taskbar know what the current windows in the workspace are
WindowsInWorkspace(WindowsVec, usize), //Vec<(id, name)>, focused id
//
}
@@ -102,7 +144,8 @@ pub enum WindowMessage {
Unfocus,
FocusClick,
ChangeDimensions(Dimensions),
Touch(usize, usize), //for onscreen keyboard only
/// For onscreen keyboard only
Touch(usize, usize),
//
}

View File

@@ -97,6 +97,7 @@ const THEME_INFOS: [(Themes, ThemeInfo); 5] = [
//
];
/// Window manager internal usage
pub fn get_theme_info(theme: &Themes) -> Option<ThemeInfo> {
for pair in THEME_INFOS {
if &pair.0 == theme {