MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / move_right

Method move_right

src/text_input.rs:176–202  ·  view source on GitHub ↗

Move cursor right by one character.

(&mut self, shift: bool)

Source from the content-addressed store, hash-verified

174
175 /// Move cursor right by one character.
176 pub fn move_right(&mut self, shift: bool) {
177 let len = self.text.chars().count();
178 if !shift {
179 // If there's a selection and no shift, collapse to end
180 if let Some((_start, end)) = self.selection_range() {
181 self.cursor_pos = end;
182 self.selection_anchor = None;
183 self.reset_blink();
184 return;
185 }
186 }
187 if self.cursor_pos < len {
188 if shift && self.selection_anchor.is_none() {
189 self.selection_anchor = Some(self.cursor_pos);
190 }
191 self.cursor_pos += 1;
192 if shift {
193 if self.selection_anchor == Some(self.cursor_pos) {
194 self.selection_anchor = None;
195 }
196 }
197 }
198 if !shift {
199 self.selection_anchor = None;
200 }
201 self.reset_blink();
202 }
203
204 /// Move cursor to the start of the previous word.
205 pub fn move_word_left(&mut self, shift: bool) {

Calls 2

selection_rangeMethod · 0.80
reset_blinkMethod · 0.80

Tested by 2

test_move_left_rightFunction · 0.64