Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:36:05.287Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

table_cell.rs

55 lines · 1.6 KB · rust
1use text::Anchor;
2use ui::SharedString;
3
4/// Position of a cell within the source CSV buffer
5#[derive(Clone, Debug)]
6pub struct CellContentSpan {
7    /// Start anchor of the cell content in the source buffer
8    pub start: Anchor,
9    /// End anchor of the cell content in the source buffer
10    pub end: Anchor,
11}
12
13/// A table cell with its content and position in the source buffer
14#[derive(Clone, Debug)]
15pub enum TableCell {
16    /// Cell existing in the CSV
17    Real {
18        /// Position of this cell in the source buffer
19        position: CellContentSpan,
20        /// Cached display value (for performance)
21        cached_value: SharedString,
22    },
23    /// Virtual cell, created to pad malformed row
24    Virtual,
25}
26
27impl TableCell {
28    /// Create a TableCell with buffer position tracking
29    pub fn from_buffer_position(
30        content: SharedString,
31        start_offset: usize,
32        end_offset: usize,
33        buffer_snapshot: &text::BufferSnapshot,
34    ) -> Self {
35        let start_anchor = buffer_snapshot.anchor_before(start_offset);
36        let end_anchor = buffer_snapshot.anchor_after(end_offset);
37
38        Self::Real {
39            position: CellContentSpan {
40                start: start_anchor,
41                end: end_anchor,
42            },
43            cached_value: content,
44        }
45    }
46
47    /// Get the display value for this cell
48    pub fn display_value(&self) -> Option<&SharedString> {
49        match self {
50            TableCell::Real { cached_value, .. } => Some(cached_value),
51            TableCell::Virtual => None,
52        }
53    }
54}
55
Served at tenant.openagents/omega Member data and write actions are omitted.