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

Method move_left

src/text_input.rs:147–173  ·  view source on GitHub ↗

Move cursor left by one character.

(&mut self, shift: bool)

Source from the content-addressed store, hash-verified

145
146 /// Move cursor left by one character.
147 pub fn move_left(&mut self, shift: bool) {
148 if !shift {
149 // If there's a selection and no shift, collapse to start
150 if let Some((start, _end)) = self.selection_range() {
151 self.cursor_pos = start;
152 self.selection_anchor = None;
153 self.reset_blink();
154 return;
155 }
156 }
157 if self.cursor_pos > 0 {
158 if shift && self.selection_anchor.is_none() {
159 self.selection_anchor = Some(self.cursor_pos);
160 }
161 self.cursor_pos -= 1;
162 if shift {
163 // If anchor equals cursor, clear selection
164 if self.selection_anchor == Some(self.cursor_pos) {
165 self.selection_anchor = None;
166 }
167 }
168 }
169 if !shift {
170 self.selection_anchor = None;
171 }
172 self.reset_blink();
173 }
174
175 /// Move cursor right by one character.
176 pub fn move_right(&mut self, shift: bool) {

Callers 2

test_move_left_rightFunction · 0.80

Calls 2

selection_rangeMethod · 0.80
reset_blinkMethod · 0.80

Tested by 1

test_move_left_rightFunction · 0.64