From e0d5ae685c7f518647234f30978d1964a5802386 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 6 Aug 2016 00:49:29 -0400 Subject: Initial trial of selection tracking Decided to track the location of the selection in a struct and make a function to move the current selection. But I can't mutably borrow the terminal because it's already mutable. Will need to rethink this. --- src/main.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index c11ad14..3b08ad6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,12 +5,32 @@ use rustty::ui::Painter; use std::time::Duration; +struct Selection<'a> { + x: usize, + y: usize, + terminal: &'a mut Terminal, +} + +impl<'a> Selection<'a> { + fn move_selection(&mut self, amount: usize) { + // Clear old selection cursor + self.terminal.printline(self.x, self.y, " "); + + self.y = self.y + amount; + + let knockout_cell = Cell::with_style(Color::Byte(0x07), Color::Black, Attr::Default); + self.terminal.printline_with_cell(0, 2, "->", knockout_cell); + } +} + fn main() { let mut term = Terminal::new().unwrap(); term.swap_buffers().unwrap(); let knockout_cell = Cell::with_style(Color::Byte(0x07), Color::Black, Attr::Default); + let selection = Selection { x: 2, y: 2, terminal: &mut term }; + loop { term.printline(0, 0, "Passextract (Press q or Ctrl-C to quit)"); @@ -35,6 +55,11 @@ fn main() { 'q' | '\x03' => { break; } + 'j' => { + + } + 'k' => { + } c @ _ => { } } -- cgit v1.2.3