egui_simple_term 0.1.0

A small embeddable terminal widget for egui: a colored prompt, line editing, command history, and a scrollable output backlog.
Documentation
use alloc::rc::Rc;
use eframe::egui::Color32;

/// A run of consecutive characters sharing one foreground and one background
/// color — the atom a [`Line`](crate::Line) is built from.
///
/// A transparent `bg` means "paint no background". Plain terminal text uses
/// [`no_bg`](Self::no_bg).
pub struct CellGroup {
    /// The characters in this run.
    pub chars: Rc<[char]>,
    /// Text color.
    pub fg: Color32,
    /// Background color; [`Color32::TRANSPARENT`] for none.
    pub bg: Color32,
}

impl CellGroup {
    /// A run with an explicit foreground and background color.
    pub fn new(chars: Rc<[char]>, fg: Color32, bg: Color32) -> Self {
        Self { chars, fg, bg }
    }

    /// A run with no background — the usual form for terminal text.
    pub fn no_bg(chars: Rc<[char]>, fg: Color32) -> Self {
        Self::new(chars, fg, Color32::TRANSPARENT)
    }

    /// Number of characters in the run.
    pub fn len(&self) -> usize {
        self.chars.len()
    }
}