aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs52
1 files changed, 32 insertions, 20 deletions
diff --git a/src/app.rs b/src/app.rs
index 56fcac7..33d4934 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -336,14 +336,14 @@ impl<'ctx> AppState<'ctx> {
336 let (width, height) = (self.width(), self.height()); 336 let (width, height) = (self.width(), self.height());
337 let canvas = &mut self.canvas; 337 let canvas = &mut self.canvas;
338 canvas.set_draw_color(self.grid.color); 338 canvas.set_draw_color(self.grid.color);
339 for i in 0..=width { 339 for i in 1..width {
340 let x = (i * cs) as i32; 340 let x = (i * cs) as i32;
341 let y = (height * cs) as i32; 341 let y = (height * cs) as i32;
342 let start = self.start + Point::new(x, 0); 342 let start = self.start + Point::new(x, 0);
343 let end = self.start + Point::new(x, y); 343 let end = self.start + Point::new(x, y);
344 canvas.draw_line(start, end).unwrap(); 344 canvas.draw_line(start, end).unwrap();
345 } 345 }
346 for j in 0..=height { 346 for j in 1..height {
347 let x = (width * cs) as i32; 347 let x = (width * cs) as i32;
348 let y = (j * cs) as i32; 348 let y = (j * cs) as i32;
349 let start = self.start + Point::new(0, y); 349 let start = self.start + Point::new(0, y);
@@ -560,17 +560,26 @@ impl<'ctx> AppState<'ctx> {
560 for (color, length) in utils::compress(scan) { 560 for (color, length) in utils::compress(scan) {
561 if color { 561 if color {
562 self.canvas 562 self.canvas
563 .fill_rect(Rect::new( 563 .fill_rect(rect!(
564 (pass as u32 * cs) as i32 + start.x(), 564 (pass as u32 * cs) as i32 + start.x(),
565 (line_nr as u32 * cs) as i32 + start.y(), 565 (line_nr as u32 * cs) as i32 + start.y(),
566 cs * length as u32, 566 cs * length as u32,
567 cs, 567 cs
568 )) 568 ))
569 .unwrap(); 569 .unwrap();
570 } 570 }
571 pass += length; 571 pass += length;
572 } 572 }
573 } 573 }
574 self.canvas.set_draw_color(GRID_COLOR);
575 self.canvas
576 .draw_rect(rect!(
577 start.x(),
578 start.y(),
579 self.width() * cs,
580 self.height() * cs
581 ))
582 .unwrap();
574 if grid_enabled { 583 if grid_enabled {
575 self.draw_grid(); 584 self.draw_grid();
576 } 585 }
@@ -884,19 +893,24 @@ impl<'ctx> AppState<'ctx> {
884 .push_str(&clipboard.clipboard_text().unwrap()); 893 .push_str(&clipboard.clipboard_text().unwrap());
885 } 894 }
886 } 895 }
887 if let Event::KeyDown { 896 match event {
888 keycode: Some(k), 897 Event::KeyDown {
889 keymod, 898 keycode: Some(k),
890 .. 899 keymod,
891 } = event 900 ..
892 { 901 } => match k {
893 match k {
894 Keycode::Backspace => self.command_box.backspace(), 902 Keycode::Backspace => self.command_box.backspace(),
895 Keycode::Delete => self.command_box.delete(), 903 Keycode::Delete => self.command_box.delete(),
896 Keycode::Left => self.command_box.backward(), 904 Keycode::Left => self.command_box.backward(),
897 Keycode::Right => self.command_box.forward(), 905 Keycode::Right => self.command_box.forward(),
898 Keycode::Up => self.command_box.hist_prev(), 906 Keycode::Up => self.command_box.hist_prev(),
899 Keycode::Down => self.command_box.hist_next(), 907 Keycode::Down => self.command_box.hist_next(),
908 Keycode::Return => self.eval_command(),
909 Keycode::Escape => {
910 self.command_box.clear();
911 self.message.text.clear();
912 self.mode = Mode::Draw;
913 }
900 _ if keymod == Mod::LCTRLMOD => match k { 914 _ if keymod == Mod::LCTRLMOD => match k {
901 Keycode::A => self.command_box.cursor_start(), 915 Keycode::A => self.command_box.cursor_start(),
902 Keycode::E => self.command_box.cursor_end(), 916 Keycode::E => self.command_box.cursor_end(),
@@ -906,16 +920,14 @@ impl<'ctx> AppState<'ctx> {
906 Keycode::U => self.command_box.delete_to_start(), 920 Keycode::U => self.command_box.delete_to_start(),
907 _ => (), 921 _ => (),
908 }, 922 },
909 Keycode::Return => self.eval_command(), 923 // how does one handle alt keys
910 Keycode::Escape => { 924 // _ if keymod == Mod::LALTMOD => match k {
911 self.command_box.clear(); 925 // Keycode::B => self.command_box.cursor_back_word(),
912 self.message.text = format!(" "); 926 // Keycode::F => self.command_box.cursor_forward_word(),
913 self.mode = Mode::Draw; 927 // _ => (),
914 } 928 // },
915 _ => (), 929 _ => (),
916 } 930 },
917 }
918 match event {
919 Event::TextInput { text, .. } => { 931 Event::TextInput { text, .. } => {
920 self.command_box.push_str(&text[..]); 932 self.command_box.push_str(&text[..]);
921 } 933 }