ass_editor/events/
event_builders.rs1use super::DocumentEvent;
7use crate::core::{Position, Range};
8
9#[cfg(not(feature = "std"))]
10use alloc::string::String;
11
12impl DocumentEvent {
14 pub fn text_inserted(position: Position, text: String) -> Self {
16 let length = text.len();
17 Self::TextInserted {
18 position,
19 text,
20 length,
21 }
22 }
23
24 pub fn text_deleted(range: Range, deleted_text: String) -> Self {
26 Self::TextDeleted {
27 range,
28 deleted_text,
29 }
30 }
31
32 pub fn text_replaced(range: Range, old_text: String, new_text: String) -> Self {
34 Self::TextReplaced {
35 range,
36 old_text,
37 new_text,
38 }
39 }
40
41 pub fn cursor_moved(old_position: Position, new_position: Position) -> Self {
43 Self::CursorMoved {
44 old_position,
45 new_position,
46 }
47 }
48
49 pub fn document_saved(file_path: String, save_as: bool) -> Self {
51 Self::DocumentSaved { file_path, save_as }
52 }
53
54 pub fn validation_completed(
56 issues_count: usize,
57 error_count: usize,
58 warning_count: usize,
59 validation_time_ms: u64,
60 ) -> Self {
61 Self::ValidationCompleted {
62 issues_count,
63 error_count,
64 warning_count,
65 validation_time_ms,
66 }
67 }
68}