diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2019-08-02 20:59:47 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2019-08-02 20:59:47 +0100 |
commit | 818f4018d2a2e8a16e2c65c97ecd56c2f583f2c1 (patch) | |
tree | e8965c58720cc2aeb514dce579892841cce76d0f /desktop/local_history.c | |
parent | 1ee32fe96275798c465375cf1d990c11749c63af (diff) | |
download | netsurf-818f4018d2a2e8a16e2c65c97ecd56c2f583f2c1.tar.gz netsurf-818f4018d2a2e8a16e2c65c97ecd56c2f583f2c1.tar.bz2 |
local_history: Handle keys for navigating local history
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'desktop/local_history.c')
-rw-r--r-- | desktop/local_history.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/desktop/local_history.c b/desktop/local_history.c index 4c75a8017..8e52af749 100644 --- a/desktop/local_history.c +++ b/desktop/local_history.c @@ -31,6 +31,7 @@ #include "netsurf/browser_window.h" #include "netsurf/core_window.h" #include "netsurf/plotters.h" +#include "netsurf/keypress.h" #include "desktop/gui_internal.h" #include "desktop/system_colour.h" @@ -438,6 +439,59 @@ local_history_mouse_action(struct local_history_session *session, bool local_history_keypress(struct local_history_session *session, uint32_t key) { + switch (key) { + case NS_KEY_NL: + case NS_KEY_CR: + /* pressed enter */ + if (session->cursor != session->bw->history->current) { + browser_window_history_go(session->bw, session->cursor, + false); + local_history_scroll_to_cursor(session); + session->cw_t->invalidate(session->core_window_handle, NULL); + } + /* We have handled this keypress */ + return true; + case NS_KEY_LEFT: + /* Go to parent */ + if (session->cursor->back) { + session->cursor = session->cursor->back; + local_history_scroll_to_cursor(session); + session->cw_t->invalidate(session->core_window_handle, NULL); + } + /* We have handled this keypress */ + return true; + case NS_KEY_RIGHT: + /* Go to preferred child if there is one */ + if (session->cursor->forward_pref) { + session->cursor = session->cursor->forward_pref; + local_history_scroll_to_cursor(session); + session->cw_t->invalidate(session->core_window_handle, NULL); + } + /* We have handled this keypress */ + return true; + case NS_KEY_DOWN: + /* Go to next sibling down, if there is one */ + if (session->cursor->next) { + session->cursor = session->cursor->next; + local_history_scroll_to_cursor(session); + session->cw_t->invalidate(session->core_window_handle, NULL); + } + /* We have handled this keypress */ + return true; + case NS_KEY_UP: + /* Go to next sibling up, if there is one */ + if (session->cursor->back) { + struct history_entry *ent = session->cursor->back->forward; + while (ent->next != NULL && ent->next != session->cursor) { + ent = ent->next; + } + session->cursor = ent; + local_history_scroll_to_cursor(session); + session->cw_t->invalidate(session->core_window_handle, NULL); + } + /* We have handled this keypress */ + return true; + } return false; } |