aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-08-17 20:51:28 -0400
committerTeddy Wing2016-08-17 20:51:28 -0400
commit2f0c32919be803fb0ec7f11f896e4e2e9c45b024 (patch)
tree12dd3f65faf7833b4308b739bb904abe800e09c2
parent8f7fc4deea1e02116e4435d1e8a6068fa63e0afd (diff)
parent7cdc4aab7d142b83cf85cf42de92971874d53fce (diff)
downloadPassextract-2f0c32919be803fb0ec7f11f896e4e2e9c45b024.tar.bz2
Merge branch 'g-jump-mappings'
-rw-r--r--src/main.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index c09eb4d..8e497c7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -34,11 +34,10 @@ fn strip_key(line: &str) -> String {
strings[1..].join(": ")
}
-fn move_selection(term: &mut Terminal, selection: &mut Point, style: Cell, amount: isize) {
+fn move_selection(term: &mut Terminal, selection: &mut Point, style: Cell, y: usize) {
term.printline(selection.x, selection.y, " ");
- let y = selection.y as isize;
- selection.y = (y + amount) as usize;
+ selection.y = y;
term.printline_with_cell(selection.x, selection.y, "->", style);
}
@@ -122,14 +121,22 @@ fn main() {
}
'j' => {
if selection.y < options.len() + 1 {
- move_selection(&mut term, &mut selection, knockout_cell, 1)
+ let y = selection.y;
+ move_selection(&mut term, &mut selection, knockout_cell, y + 1)
}
}
'k' => {
if selection.y > 2 {
- move_selection(&mut term, &mut selection, knockout_cell, -1)
+ let y = selection.y;
+ move_selection(&mut term, &mut selection, knockout_cell, y - 1)
}
}
+ 'g' => {
+ move_selection(&mut term, &mut selection, knockout_cell, 2)
+ }
+ 'G' => {
+ move_selection(&mut term, &mut selection, knockout_cell, options.len() + 1)
+ }
'\x0D' => {
match clipboard_ctx.set_contents(strip_key(&options[selection.y - 2]).to_owned()) {
Ok(_) => {