Skip to content

Commit

Permalink
feat: make navigation inside Hex window more unixy using hjkl, and 'q' (
Browse files Browse the repository at this point in the history
  • Loading branch information
jondot authored Aug 31, 2022
1 parent 1ed4869 commit c6bbba8
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,39 @@ pub(crate) fn handle_character_input(
} else if modifiers | KeyModifiers::NONE | KeyModifiers::SHIFT
== KeyModifiers::NONE | KeyModifiers::SHIFT
{
app.key_handler.char(&mut app.data, &mut app.display, &mut app.labels, char);
let is_hex = app.key_handler.is_focusing(Window::Hex);

match char {
'q' if is_hex => {
if !app.key_handler.is_focusing(Window::UnsavedChanges) {
if app.hash_contents() == app.data.hashed_contents {
return Ok(false);
}
app.set_focused_window(Window::UnsavedChanges);
}
}
'h' if is_hex => {
app.key_handler.left(&mut app.data, &mut app.display, &mut app.labels);
}
'l' if is_hex => {
app.key_handler.right(&mut app.data, &mut app.display, &mut app.labels);
}
'k' if is_hex => {
app.key_handler.up(&mut app.data, &mut app.display, &mut app.labels);
}
'j' if is_hex => {
app.key_handler.down(&mut app.data, &mut app.display, &mut app.labels);
}
'^' if is_hex => {
app.key_handler.home(&mut app.data, &mut app.display, &mut app.labels);
}
'$' if is_hex => {
app.key_handler.end(&mut app.data, &mut app.display, &mut app.labels);
}
_ => {
app.key_handler.char(&mut app.data, &mut app.display, &mut app.labels, char);
}
}
}
Ok(true)
}
Expand Down

0 comments on commit c6bbba8

Please sign in to comment.