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