visi_core/core/actions.rs
1use serde::{Deserialize, Serialize};
2
3/// A single edit made to a workbook, recorded so a host can observe or replay
4/// it.
5///
6/// `Sheet` appends one of these to `Sheet::uncommitted_actions` for each edit.
7/// Sheets are named rather than held by id, since an action is meant to
8/// survive being written down and applied elsewhere.
9///
10/// "Table" in the variant names means a *sheet*, following this codebase's
11/// older informal naming -- not an `ExcelTable`.
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub enum SheetAction {
14 /// A cell's raw text was replaced.
15 SetCellSrc {
16 /// Sheet the cell is on.
17 sheet_name: String,
18 /// Column index, 0-based.
19 col: usize,
20 /// Row index, 0-based.
21 row: usize,
22 /// The new text.
23 src: String,
24 },
25 /// A column was renamed.
26 UpdateColName {
27 /// Sheet the column is on.
28 sheet_name: String,
29 /// Column index, 0-based.
30 col: usize,
31 /// The new name.
32 name: String,
33 },
34 /// A sheet was renamed.
35 UpdateTableName {
36 /// The sheet's previous name.
37 old_name: String,
38 /// Its new name.
39 new_name: String,
40 },
41 /// An empty row was inserted.
42 InsertRow {
43 /// Sheet the row was inserted on.
44 sheet_name: String,
45 /// Position it was inserted at, 0-based.
46 index: usize,
47 },
48 /// A row was deleted.
49 DeleteRow {
50 /// Sheet the row was deleted from.
51 sheet_name: String,
52 /// Position it occupied, 0-based.
53 index: usize,
54 },
55 /// An empty column was inserted.
56 InsertCol {
57 /// Sheet the column was inserted on.
58 sheet_name: String,
59 /// Position it was inserted at, 0-based.
60 index: usize,
61 },
62 /// A column was deleted.
63 DeleteCol {
64 /// Sheet the column was deleted from.
65 sheet_name: String,
66 /// Position it occupied, 0-based.
67 index: usize,
68 },
69 /// A sheet was added to the workbook.
70 AddTable {
71 /// The sheet, in full.
72 sheet: Box<crate::core::Sheet>,
73 },
74 /// A sheet was removed from the workbook.
75 DeleteTable {
76 /// Name of the sheet that was removed.
77 sheet_name: String,
78 },
79}