Make Home/End handling a bit more intuitive

This commit is contained in:
Přemysl Eric Janouch 2017-01-17 16:11:01 +01:00
parent e67066d80f
commit 0f96cc9b9f
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 26 additions and 3 deletions

29
hex.c
View File

@ -1368,7 +1368,7 @@ enum action
ACTION_SCROLL_DOWN, ACTION_GOTO_BOTTOM, ACTION_GOTO_PAGE_NEXT, ACTION_SCROLL_DOWN, ACTION_GOTO_BOTTOM, ACTION_GOTO_PAGE_NEXT,
ACTION_UP, ACTION_DOWN, ACTION_LEFT, ACTION_RIGHT, ACTION_UP, ACTION_DOWN, ACTION_LEFT, ACTION_RIGHT,
ACTION_ROW_START, ACTION_ROW_END,
ACTION_FIELD_PREVIOUS, ACTION_FIELD_NEXT, ACTION_FIELD_PREVIOUS, ACTION_FIELD_NEXT,
ACTION_COUNT ACTION_COUNT
@ -1442,6 +1442,29 @@ app_process_action (enum action action)
app_invalidate (); app_invalidate ();
break; 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: case ACTION_FIELD_PREVIOUS:
{ {
ssize_t i = app_find_marks (g_ctx.view_cursor); ssize_t i = app_find_marks (g_ctx.view_cursor);
@ -1543,8 +1566,8 @@ g_default_bindings[] =
{ "C-l", ACTION_REDRAW, {}}, { "C-l", ACTION_REDRAW, {}},
{ "Tab", ACTION_TOGGLE_ENDIANITY, {}}, { "Tab", ACTION_TOGGLE_ENDIANITY, {}},
{ "Home", ACTION_GOTO_TOP, {}}, { "Home", ACTION_ROW_START, {}},
{ "End", ACTION_GOTO_BOTTOM, {}}, { "End", ACTION_ROW_END, {}},
{ "M-<", ACTION_GOTO_TOP, {}}, { "M-<", ACTION_GOTO_TOP, {}},
{ "M->", ACTION_GOTO_BOTTOM, {}}, { "M->", ACTION_GOTO_BOTTOM, {}},
{ "g", ACTION_GOTO_TOP, {}}, { "g", ACTION_GOTO_TOP, {}},