Move cursor right by one character.
(&mut self, shift: bool)
| 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) { |