aboutsummaryrefslogtreecommitdiff
path: root/hex.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-01-17 16:11:01 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2017-01-17 16:11:01 +0100
commit0f96cc9b9f3d82f80e435d69d95a2ca1798021c7 (patch)
tree0fb7ad558df7c1073bd1ab28d46f5f399029f3ef /hex.c
parente67066d80f46964d1d5af7bcc82a382164552d3d (diff)
downloadhex-0f96cc9b9f3d82f80e435d69d95a2ca1798021c7.tar.gz
hex-0f96cc9b9f3d82f80e435d69d95a2ca1798021c7.tar.xz
hex-0f96cc9b9f3d82f80e435d69d95a2ca1798021c7.zip
Make Home/End handling a bit more intuitive
Diffstat (limited to 'hex.c')
-rw-r--r--hex.c29
1 files 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, {}},