MCPcopy Create free account
hub / github.com/Eeive/Evcode-ide / insert_char

Method insert_char

src/editor/buffer.rs:132–149  ·  view source on GitHub ↗
(&mut self, ch: char)

Source from the content-addressed store, hash-verified

130 }
131
132 pub fn insert_char(&mut self, ch: char) {
133 let cursor_before = self.cursor;
134 let (start, deleted) = self.take_selection();
135 let char_idx = start.unwrap_or_else(|| self.cursor_char_idx());
136 if let Some(start) = start {
137 self.cursor = self.cursor.set_position_from_char(start, &self.document);
138 }
139
140 self.document.insert_char(char_idx, ch);
141 self.cursor = self.cursor.set_position_from_char(char_idx + 1, &self.document);
142
143 self.push_undo(UndoRecord {
144 start: char_idx,
145 inserted: ch.to_string(),
146 deleted,
147 cursor_before,
148 });
149 }
150
151 pub fn insert_newline(&mut self) {
152 self.insert_char('\n');

Callers 5

insert_newlineMethod · 0.45
apply_editor_keyFunction · 0.45

Calls 5

take_selectionMethod · 0.80
cursor_char_idxMethod · 0.80
push_undoMethod · 0.80
to_stringMethod · 0.80