use std::time::Instant;
use crate::buffer::Buffer;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum KeyCode {
Char(char),
F(u8),
Backspace,
Enter,
Left,
Right,
Up,
Down,
Home,
End,
PageUp,
PageDown,
Tab,
BackTab,
Delete,
Insert,
Esc,
Null,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[allow(clippy::struct_excessive_bools)]
pub struct KeyModifiers {
pub shift: bool,
pub control: bool,
pub alt: bool,
pub super_key: bool,
}
impl KeyModifiers {
pub const NONE: Self = Self {
shift: false,
control: false,
alt: false,
super_key: false,
};
pub const fn any(&self) -> bool {
self.shift || self.control || self.alt || self.super_key
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MouseButton {
Left,
Right,
Middle,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MouseEvent {
pub x: u16,
pub y: u16,
pub button: Option<MouseButton>,
pub modifiers: KeyModifiers,
}
#[derive(Debug, Clone)]
pub enum InputEvent {
Key {
code: KeyCode,
modifiers: KeyModifiers,
},
MouseDown(MouseEvent),
MouseUp(MouseEvent),
MouseMove(MouseEvent),
MouseScroll {
x: u16,
y: u16,
delta: i16,
},
Resize {
width: u16,
height: u16,
},
FocusGained,
FocusLost,
Paste(String),
Error(String),
Shutdown,
}
#[derive(Debug)]
pub enum RenderCommand {
FullRedraw(Box<Buffer>),
Update(Box<Buffer>),
Resize {
width: u16,
height: u16,
},
SetCursor {
x: Option<u16>,
y: u16,
},
RawOutput {
bytes: Vec<u8>,
},
Shutdown,
}
#[derive(Debug, Clone)]
pub enum AgentEvent {
Tokens {
content: String,
source_id: u32,
is_final: bool,
},
ResponseStart {
source_id: u32,
},
ResponseEnd {
source_id: u32,
},
Error {
message: String,
source_id: u32,
},
ConnectionStatus {
connected: bool,
source_id: u32,
},
}
#[derive(Debug, Clone)]
#[allow(dead_code)]
pub struct FrameInfo {
pub frame_number: u64,
pub frame_start: Instant,
pub last_render_time: std::time::Duration,
pub fps: f32,
}
impl Default for FrameInfo {
fn default() -> Self {
Self {
frame_number: 0,
frame_start: Instant::now(),
last_render_time: std::time::Duration::ZERO,
fps: 0.0,
}
}
}