tag_operations.rs - icy_draw - [fork] icy_draw is the successor to mystic draw.
HTML git clone https://git.drkhsh.at/icy_draw.git
DIR Log
DIR Files
DIR Refs
DIR README
---
tag_operations.rs (1159B)
---
1 #![allow(clippy::missing_errors_doc)]
2 use crate::{EngineResult, Position, Tag};
3
4 use super::{undo_operations, EditState};
5
6 impl EditState {
7 pub fn add_new_tag(&mut self, new_tag: Tag) -> EngineResult<()> {
8 let op = undo_operations::AddTag::new(new_tag);
9 self.push_undo_action(Box::new(op))?;
10 self.current_tag = self.buffer.tags.len() - 1;
11 Ok(())
12 }
13
14 pub fn update_tag(&mut self, new_tag: Tag, index: usize) -> EngineResult<()> {
15 let old_tag = self.buffer.tags[index].clone();
16 let op = undo_operations::EditTag::new(index, old_tag, new_tag);
17 self.push_undo_action(Box::new(op))?;
18 Ok(())
19 }
20
21 pub fn move_tag(&mut self, tag: usize, pos: Position) -> EngineResult<()> {
22 let old_pos = self.buffer.tags[tag].position;
23 let op = undo_operations::MoveTag::new(tag, old_pos, pos);
24 self.push_undo_action(Box::new(op))?;
25 Ok(())
26 }
27
28 pub fn remove_tag(&mut self, tag: usize) -> EngineResult<()> {
29 let op = undo_operations::RemoveTag::new(tag, self.buffer.tags[tag].clone());
30 self.push_undo_action(Box::new(op))?;
31 Ok(())
32 }
33 }