Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: add keyboard field to MultipleSegment recording metadata

Cursor Agent86640c2fac10
diff --git a/crates/project/src/meta.rs b/crates/project/src/meta.rs
index 05248b5df..4217516ab 100644
--- a/crates/project/src/meta.rs
+++ b/crates/project/src/meta.rs
@@ -10,7 +10,7 @@ use std::{
use tracing::{debug, info, warn};
use crate::{
- CaptionsData, CursorEvents, CursorImage, ProjectConfiguration, XY,
+ CaptionsData, CursorEvents, CursorImage, KeyboardEvents, ProjectConfiguration, XY,
cursor::SHORT_CURSOR_SHAPE_DEBOUNCE_MS,
};
@@ -361,6 +361,9 @@ pub struct MultipleSegment {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[specta(type = Option<String>)]
pub cursor: Option<RelativePathBuf>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[specta(type = Option<String>)]
+ pub keyboard: Option<RelativePathBuf>,
}
impl MultipleSegment {
@@ -395,6 +398,22 @@ impl MultipleSegment {
data
}
+ pub fn keyboard_events(&self, meta: &RecordingMeta) -> KeyboardEvents {
+ let Some(keyboard_path) = &self.keyboard else {
+ return KeyboardEvents::default();
+ };
+
+ let full_path = meta.path(keyboard_path);
+
+ match KeyboardEvents::load_from_file(&full_path) {
+ Ok(data) => data,
+ Err(e) => {
+ eprintln!("Failed to load keyboard data: {e}");
+ KeyboardEvents::default()
+ }
+ }
+ }
+
pub fn latest_start_time(&self) -> Option<f64> {
let mut value = self.display.start_time?;