rskit_cli/prompt/terminal/capabilities.rs
1/// What interaction model a [`Terminal`](super::Terminal) supports.
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub struct Capabilities {
4 keys: bool,
5}
6
7impl Default for Capabilities {
8 /// Line-driven, matching the default (cooked-stdio) terminal.
9 fn default() -> Self {
10 Self::line_driven()
11 }
12}
13
14impl Capabilities {
15 /// A key-driven terminal: reads individual [`Key`](crate::prompt::key::Key)s and can redraw frames,
16 /// enabling live arrow-key navigation.
17 #[must_use]
18 pub const fn key_driven() -> Self {
19 Self { keys: true }
20 }
21
22 /// A line-driven terminal: reads a whole line at a time (cooked stdio).
23 #[must_use]
24 pub const fn line_driven() -> Self {
25 Self { keys: false }
26 }
27
28 /// Whether the terminal reads individual keys (live widgets) rather than whole lines.
29 #[must_use]
30 pub const fn is_key_driven(self) -> bool {
31 self.keys
32 }
33}