From 0f96cc9b9f3d82f80e435d69d95a2ca1798021c7 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Tue, 17 Jan 2017 16:11:01 +0100 Subject: Make Home/End handling a bit more intuitive --- hex.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/hex.c b/hex.c index 3d9c13f..5688085 100644 --- a/hex.c +++ b/hex.c @@ -1368,7 +1368,7 @@ enum action ACTION_SCROLL_DOWN, ACTION_GOTO_BOTTOM, ACTION_GOTO_PAGE_NEXT, ACTION_UP, ACTION_DOWN, ACTION_LEFT, ACTION_RIGHT, - + ACTION_ROW_START, ACTION_ROW_END, ACTION_FIELD_PREVIOUS, ACTION_FIELD_NEXT, ACTION_COUNT @@ -1442,6 +1442,29 @@ app_process_action (enum action action) app_invalidate (); break; + case ACTION_ROW_START: + { + int64_t new = g_ctx.view_cursor / ROW_SIZE * ROW_SIZE; + new = MAX (new, g_ctx.data_offset); + new = MIN (new, g_ctx.data_offset + g_ctx.data_len - 1); + + g_ctx.view_cursor = new; + g_ctx.view_skip_nibble = false; + app_invalidate (); + break; + } + case ACTION_ROW_END: + { + int64_t new = (g_ctx.view_cursor / ROW_SIZE + 1) * ROW_SIZE - 1; + new = MAX (new, g_ctx.data_offset); + new = MIN (new, g_ctx.data_offset + g_ctx.data_len - 1); + + g_ctx.view_cursor = new; + g_ctx.view_skip_nibble = false; + app_invalidate (); + break; + } + case ACTION_FIELD_PREVIOUS: { ssize_t i = app_find_marks (g_ctx.view_cursor); @@ -1543,8 +1566,8 @@ g_default_bindings[] = { "C-l", ACTION_REDRAW, {}}, { "Tab", ACTION_TOGGLE_ENDIANITY, {}}, - { "Home", ACTION_GOTO_TOP, {}}, - { "End", ACTION_GOTO_BOTTOM, {}}, + { "Home", ACTION_ROW_START, {}}, + { "End", ACTION_ROW_END, {}}, { "M-<", ACTION_GOTO_TOP, {}}, { "M->", ACTION_GOTO_BOTTOM, {}}, { "g", ACTION_GOTO_TOP, {}}, -- cgit v1.2.3-70-g09d2