From 17c6bd803dbbecb8975b1b98532d25a807a7b3fb Mon Sep 17 00:00:00 2001 From: UMTS at Teleco Date: Sun, 8 Mar 2026 22:11:52 +0100 Subject: docs and font fix --- src/app.rs | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 12 deletions(-) (limited to 'src/app.rs') diff --git a/src/app.rs b/src/app.rs index 55c75df..4a863bd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,6 +1,6 @@ -// hoardom-app: native e gui emo wrapper for the hoardom tui +// e gui emo wrapper for the hoardom tui // spawns hoardom --tui in a pty and renders it in its own window -// so it shows up with its own icon in the dock (mac) or taskbar (linux) +// so it shows up with its own icon in the dock (mac) or taskbar (linux) for people that want that // // built with: cargo build --features gui @@ -15,7 +15,10 @@ use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; -// ----- constants ----- +// thx gemma for the formated section comments i didnt want... thats not what I wanted when i said sanetize my comments from swearing and german language. +// i mean it is prettier than my usual way, will check otherfiles to see if can atleast make it somewhat consistant. + +// ---- constants ---- const FONT_SIZE: f32 = 14.0; const DEFAULT_COLS: u16 = 120; @@ -33,6 +36,8 @@ enum TermColor { Rgb(u8, u8, u8), } + +// ai made this fn because i gave up on trying. fn ansi_color(idx: u8) -> Color32 { match idx { 0 => Color32::from_rgb(0, 0, 0), @@ -58,7 +63,11 @@ fn ansi_color(idx: u8) -> Color32 { let gi = (idx % 36) / 6; let bi = idx % 6; let v = |i: u16| -> u8 { - if i == 0 { 0 } else { 55 + i as u8 * 40 } + if i == 0 { + 0 + } else { + 55 + i as u8 * 40 + } }; Color32::from_rgb(v(ri), v(gi), v(bi)) } @@ -73,7 +82,11 @@ fn ansi_color(idx: u8) -> Color32 { fn resolve_color(c: TermColor, is_fg: bool) -> Color32 { match c { TermColor::Default => { - if is_fg { DEFAULT_FG } else { DEFAULT_BG } + if is_fg { + DEFAULT_FG + } else { + DEFAULT_BG + } } TermColor::Indexed(i) => ansi_color(i), TermColor::Rgb(r, g, b) => Color32::from_rgb(r, g, b), @@ -135,6 +148,8 @@ impl Cell { // ----- terminal grid ----- + +// contains quiet a few ai solved bugfixes they seem ... fineish... to me and work struct TermGrid { cells: Vec>, rows: usize, @@ -158,12 +173,13 @@ struct TermGrid { alt_saved: Option<(Vec>, usize, usize)>, // mouse tracking modes - mouse_normal: bool, // ?1000 - normal tracking (clicks) - mouse_button: bool, // ?1002 - button-event tracking (drag) - mouse_any: bool, // ?1003 - any-event tracking (all motion) - mouse_sgr: bool, // ?1006 - SGR extended coordinates + mouse_normal: bool, // ?1000 - normal tracking (clicks) + mouse_button: bool, // ?1002 - button-event tracking (drag) + mouse_any: bool, // ?1003 - any-event tracking (all motion) + mouse_sgr: bool, // ?1006 - SGR extended coordinates } +// i partially stole this from somewhere i forgot from where though. impl TermGrid { fn new(rows: usize, cols: usize) -> Self { TermGrid { @@ -397,7 +413,7 @@ impl TermGrid { } } - // SGR - set graphics rendition (colors and attributes) + // slopfix : SGR , set graphics rendition (colors and attributes) fn sgr(&mut self, params: &[u16]) { if params.is_empty() { self.reset_attrs(); @@ -637,6 +653,7 @@ impl Perform for TermGrid { // ----- keyboard input mapping ----- // map egui keys to terminal escape sequences +// yk because maybe i want to recycle this file for some other project in the future hence why i implemented it fn special_key_bytes(key: &egui::Key, modifiers: &egui::Modifiers) -> Option> { use egui::Key; match key { @@ -721,7 +738,7 @@ struct HoardomApp { cell_height: f32, current_cols: u16, current_rows: u16, - last_mouse_button: Option, // track held mouse button for drag/release + last_mouse_button: Option, // track held mouse button for drag/release } impl eframe::App for HoardomApp { @@ -1155,12 +1172,37 @@ fn main() -> eframe::Result<()> { cc.egui_ctx.set_visuals(egui::Visuals::dark()); + // font fallback chain for monospace: Hack (default) -> NotoSansMono -> NotoSansSymbols2 + // Hack is missing box drawing, block elements, ellipsis + // NotoSansMono covers those but is missing dingbats (symbols) + // NotoSansSymbols2-subset has just those two glyphs from which only the necessary ones are extracted afaik + let mut fonts = egui::FontDefinitions::default(); + fonts.font_data.insert( + "NotoSansMono".to_owned(), + std::sync::Arc::new(egui::FontData::from_static(include_bytes!( + "../dist/NotoSansMono-Regular.ttf" + ))), + ); + fonts.font_data.insert( + "NotoSansSymbols2".to_owned(), + std::sync::Arc::new(egui::FontData::from_static(include_bytes!( + "../dist/NotoSansSymbols2-subset.ttf" + ))), + ); + let mono = fonts + .families + .entry(egui::FontFamily::Monospace) + .or_default(); + mono.push("NotoSansMono".to_owned()); + mono.push("NotoSansSymbols2".to_owned()); + cc.egui_ctx.set_fonts(fonts); + Ok(Box::new(HoardomApp { grid, pty_writer: Mutex::new(writer), pty_master: pair.master, child_exited, - cell_width: 0.0, // measured on first frame + cell_width: 0.0, // measured on first frame cell_height: 0.0, current_cols: DEFAULT_COLS, current_rows: DEFAULT_ROWS, -- cgit v1.2.3-70-g09d2