A simple CPU rendered GUI IDE experience.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use std::path::Path;

use dsb::Cell;
use dsb::cell::Style;

use crate::menu::Key;
use crate::menu::generic::{GenericMenu, MenuData};
use crate::text::{col, color_};
use crate::{FG, KillRing};
impl<'a> Key<'a> for &'a [String] {
    fn key(&self) -> impl Into<std::borrow::Cow<'a, str>> {
        self.join("")
    }
}
pub enum KillR {}
impl MenuData for KillR {
    const NAME: &'static str = "symbols";
    type Data = KillRing;

    type Element<'a> = &'a [String];

    fn gn(d: &Self::Data) -> impl Iterator<Item = Self::Element<'_>> {
        println!("x{d:?}");
        d.iter()
            .inspect(|x| {
                dbg!(&x);
            })
            .map(|x| &**x)
    }

    fn r(
        _: &Self::Data,
        x: Self::Element<'_>,
        _: &Path,
        c: usize,
        selected: bool,
        indices: &[u32],
        to: &mut Vec<Cell>,
    ) {
        let bg = if selected { col!("#262d3b") } else { col!("#1c212b") };
        let ds: Style = Style::new(FG, bg);
        let mut b = vec![Cell { style: ds, letter: None }; c];
        x.join("").chars().zip(&mut b).zip(1..).for_each(
            |((x, y), i)| {
                y.letter = Some(x);
                if indices.contains(&i) {
                    y.style |= (Style::BOLD, color_("#ffcc66"));
                }
            },
        );
        to.extend(b);
    }

    fn hash<'b>(x: &'b Self::Element<'_>) -> Option<impl std::hash::Hash> {
        Some(x)
    }
}
pub type KillRM = GenericMenu<KillR>;