revue/widget/developer/terminal/
types.rs1use crate::render::Modifier;
4use crate::style::Color;
5
6#[derive(Clone, Debug)]
8pub struct TermCell {
9 pub ch: char,
11 pub fg: Color,
13 pub bg: Color,
15 pub modifiers: Modifier,
17}
18
19impl Default for TermCell {
20 fn default() -> Self {
21 Self {
22 ch: ' ',
23 fg: Color::WHITE,
24 bg: Color::BLACK,
25 modifiers: Modifier::empty(),
26 }
27 }
28}
29
30impl TermCell {
31 pub fn new(ch: char) -> Self {
33 Self {
34 ch,
35 ..Default::default()
36 }
37 }
38
39 pub fn fg(mut self, color: Color) -> Self {
41 self.fg = color;
42 self
43 }
44
45 pub fn bg(mut self, color: Color) -> Self {
47 self.bg = color;
48 self
49 }
50
51 pub fn modifiers(mut self, modifiers: Modifier) -> Self {
53 self.modifiers = modifiers;
54 self
55 }
56}
57
58#[derive(Clone, Debug)]
60pub struct TermLine {
61 pub cells: Vec<TermCell>,
63 pub wrapped: bool,
65}
66
67impl TermLine {
68 pub fn new() -> Self {
70 Self {
71 cells: Vec::new(),
72 wrapped: false,
73 }
74 }
75
76 pub fn with_capacity(capacity: usize) -> Self {
78 Self {
79 cells: Vec::with_capacity(capacity),
80 wrapped: false,
81 }
82 }
83}
84
85impl Default for TermLine {
86 fn default() -> Self {
87 Self::new()
88 }
89}
90
91#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
93pub enum CursorStyle {
94 #[default]
96 Block,
97 Underline,
99 Bar,
101}
102
103#[derive(Clone, Debug, PartialEq, Eq)]
105pub enum TerminalAction {
106 Submit(String),
108 Cancel,
110 TabComplete(String),
112}