|
1 | 1 | use crate::{
|
2 | 2 | ansi::{self, EraseMode, Op, OpStr},
|
3 | 3 | color::Rgb3,
|
4 |
| - display::{self, TextDisplay, ROWS, COLUMNS}, |
| 4 | + display::{self, TextDisplay, COLUMNS, ROWS}, |
5 | 5 | CHARACTER_DRAW_CYCLES,
|
6 | 6 | };
|
7 | 7 | use alloc::string::String;
|
@@ -65,13 +65,13 @@ impl CursorPos {
|
65 | 65 | enum VerticalLocation {
|
66 | 66 | Middle,
|
67 | 67 | Top,
|
68 |
| - Bottom |
| 68 | + Bottom, |
69 | 69 | }
|
70 | 70 |
|
71 | 71 | enum HorizontalLocation {
|
72 | 72 | Middle,
|
73 | 73 | Left,
|
74 |
| - Right |
| 74 | + Right, |
75 | 75 | }
|
76 | 76 |
|
77 | 77 | #[derive(Debug, Clone, Copy)]
|
@@ -239,29 +239,26 @@ impl TextField {
|
239 | 239 | .write(self.cursor.pos.row(), self.cursor.pos.col(), t);
|
240 | 240 | self.move_cursor(0, 1);
|
241 | 241 | }
|
242 |
| - '\n' => { |
243 |
| - match self.cursor.location() { |
244 |
| - (VerticalLocation::Bottom, _) => { |
245 |
| - self.cursor.unset_highlight(&mut self.text); |
246 |
| - self.text.scroll_down(1); |
247 |
| - self.move_cursor(0, -(self.cursor.pos.col() as isize)) |
248 |
| - }, |
249 |
| - _ => { |
250 |
| - self.move_cursor(1, -(self.cursor.pos.col() as isize)) |
251 |
| - } |
| 242 | + '\n' => match self.cursor.location() { |
| 243 | + (VerticalLocation::Bottom, _) => { |
| 244 | + self.cursor.unset_highlight(&mut self.text); |
| 245 | + self.text.scroll_down(1); |
| 246 | + self.move_cursor(0, -(self.cursor.pos.col() as isize)) |
252 | 247 | }
|
253 |
| - } |
| 248 | + _ => self.move_cursor(1, -(self.cursor.pos.col() as isize)), |
| 249 | + }, |
254 | 250 | '\r' => self.move_cursor(0, -(self.cursor.pos.col() as isize)),
|
255 | 251 | _ => {
|
256 | 252 | for c in t.escape_default() {
|
257 | 253 | self.text.write(self.cursor.pos.0, self.cursor.pos.1, c);
|
258 | 254 | match self.cursor.location() {
|
259 | 255 | (_, HorizontalLocation::Left | HorizontalLocation::Middle) => {
|
260 | 256 | self.move_cursor(0, 1);
|
261 |
| - }, |
262 |
| - (VerticalLocation::Top | VerticalLocation::Middle, HorizontalLocation::Right) => { |
263 |
| - self.move_cursor(1, -(self.cursor.pos.col() as isize)) |
264 |
| - }, |
| 257 | + } |
| 258 | + ( |
| 259 | + VerticalLocation::Top | VerticalLocation::Middle, |
| 260 | + HorizontalLocation::Right, |
| 261 | + ) => self.move_cursor(1, -(self.cursor.pos.col() as isize)), |
265 | 262 | (VerticalLocation::Bottom, HorizontalLocation::Right) => {
|
266 | 263 | self.cursor.unset_highlight(&mut self.text);
|
267 | 264 | self.text.scroll_down(1);
|
@@ -290,8 +287,10 @@ impl TextField {
|
290 | 287 | MoveCursorDelta { dx, dy } => {
|
291 | 288 | // Constrain dx and dy so that the result added to the current position
|
292 | 289 | // stays within the window
|
293 |
| - let x = (self.cursor.pos.col() as isize + dx).clamp(0, COLUMNS as isize - 1) - self.cursor.pos.col() as isize; |
294 |
| - let y = (self.cursor.pos.row() as isize + dy).clamp(0, ROWS as isize - 1) - self.cursor.pos.row() as isize; |
| 290 | + let x = (self.cursor.pos.col() as isize + dx).clamp(0, COLUMNS as isize - 1) |
| 291 | + - self.cursor.pos.col() as isize; |
| 292 | + let y = (self.cursor.pos.row() as isize + dy).clamp(0, ROWS as isize - 1) |
| 293 | + - self.cursor.pos.row() as isize; |
295 | 294 | self.move_cursor(y, x);
|
296 | 295 | }
|
297 | 296 | MoveCursorBeginningAndLine { dy } => {
|
|
0 commit comments