Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/1866f3a3d1fa710a84bf1ed9b948075156f10c7b
...commit
http://git.netsurf-browser.org/netsurf.git/commit/1866f3a3d1fa710a84bf1ed9b948075156f10c7b
...tree
http://git.netsurf-browser.org/netsurf.git/tree/1866f3a3d1fa710a84bf1ed9b948075156f10c7b
The branch, master has been updated
via 1866f3a3d1fa710a84bf1ed9b948075156f10c7b (commit)
from a1951f4c49a44783478c7000bd5ac5d349375488 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=1866f3a3d1fa710a84bf1ed9b948075156f10c7b
commit 1866f3a3d1fa710a84bf1ed9b948075156f10c7b
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
local_history: Improve up/down navigation
When pressing up/down on a node when you can't go up/down the
window will now search for a parent node which is a child of
a branching point, and move to that and try again for the up/down
movement. This makes it slightly more intuitive to move through
the tree.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/desktop/local_history.c b/desktop/local_history.c
index ddebbbe..aa70ebb 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -434,6 +434,36 @@ local_history_mouse_action(struct local_history_session
*session,
return NSERROR_OK;
}
+/**
+ * Determine the point on the parent line where this history line branches.
+ *
+ * If `branch_point` gets set then there is a guarantee that (a) `ent` is
+ * a transitive child (forward) of that point. and (b) `branch_point` has a
+ * parent.
+ *
+ * \param[in] ent The entry to work backward from
+ * \param[out] branch_point The entry to set to the branch point if one is
found
+ */
+static void
+_local_history_find_branch_point(struct history_entry *ent,
+ struct history_entry **branch_point)
+{
+ if (ent->back == NULL) {
+ /* We're at the root, nothing to do */
+ return;
+ }
+ /* Start from our immediate parent */
+ ent = ent->back;
+ while (ent->back != NULL) {
+ if (ent->back->forward != ent->back->forward_last) {
+ /* This point is a branch */
+ *branch_point = ent;
+ break;
+ }
+ ent = ent->back;
+ }
+}
+
/* exported interface documented in desktop/local_history.h */
bool
local_history_keypress(struct local_history_session *session, uint32_t key)
@@ -452,7 +482,7 @@ local_history_keypress(struct local_history_session
*session, uint32_t key)
return true;
case NS_KEY_LEFT:
/* Go to parent */
- if (session->cursor->back) {
+ if (session->cursor->back != NULL) {
session->cursor = session->cursor->back;
local_history_scroll_to_cursor(session);
session->cw_t->invalidate(session->core_window_handle,
NULL);
@@ -461,7 +491,7 @@ local_history_keypress(struct local_history_session
*session, uint32_t key)
return true;
case NS_KEY_RIGHT:
/* Go to preferred child if there is one */
- if (session->cursor->forward_pref) {
+ if (session->cursor->forward_pref != NULL) {
session->cursor = session->cursor->forward_pref;
local_history_scroll_to_cursor(session);
session->cw_t->invalidate(session->core_window_handle,
NULL);
@@ -470,25 +500,52 @@ local_history_keypress(struct local_history_session
*session, uint32_t key)
return true;
case NS_KEY_DOWN:
/* Go to next sibling down, if there is one */
- if (session->cursor->next) {
+ if (session->cursor->next != NULL) {
session->cursor = session->cursor->next;
- local_history_scroll_to_cursor(session);
- session->cw_t->invalidate(session->core_window_handle,
NULL);
+ } else {
+ struct history_entry *branch_point = NULL;
+ _local_history_find_branch_point(
+ session->cursor,
+ &branch_point);
+ if (branch_point != NULL) {
+ if (branch_point->next != NULL) {
+ branch_point = branch_point->next;
+ }
+ session->cursor = branch_point;
+ }
}
/* We have handled this keypress */
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle, NULL);
return true;
case NS_KEY_UP:
/* Go to next sibling up, if there is one */
- if (session->cursor->back) {
+ if (session->cursor->back != NULL) {
struct history_entry *ent =
session->cursor->back->forward;
- while (ent->next != NULL && ent->next !=
session->cursor) {
+ while (ent != session->cursor &&
+ 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);
+ if (session->cursor != ent) {
+ session->cursor = ent;
+ } else {
+ struct history_entry *branch_point = NULL;
+ _local_history_find_branch_point(
+ session->cursor,
+ &branch_point);
+ if (branch_point != NULL) {
+ struct history_entry *ent =
branch_point->back->forward;
+ while (ent->next != NULL && ent->next
!= branch_point) {
+ ent = ent->next;
+ }
+ session->cursor = ent;
+ }
+ }
}
/* We have handled this keypress */
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle, NULL);
return true;
}
return false;
-----------------------------------------------------------------------
Summary of changes:
desktop/local_history.c | 77 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 67 insertions(+), 10 deletions(-)
diff --git a/desktop/local_history.c b/desktop/local_history.c
index ddebbbe..aa70ebb 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -434,6 +434,36 @@ local_history_mouse_action(struct local_history_session
*session,
return NSERROR_OK;
}
+/**
+ * Determine the point on the parent line where this history line branches.
+ *
+ * If `branch_point` gets set then there is a guarantee that (a) `ent` is
+ * a transitive child (forward) of that point. and (b) `branch_point` has a
+ * parent.
+ *
+ * \param[in] ent The entry to work backward from
+ * \param[out] branch_point The entry to set to the branch point if one is
found
+ */
+static void
+_local_history_find_branch_point(struct history_entry *ent,
+ struct history_entry **branch_point)
+{
+ if (ent->back == NULL) {
+ /* We're at the root, nothing to do */
+ return;
+ }
+ /* Start from our immediate parent */
+ ent = ent->back;
+ while (ent->back != NULL) {
+ if (ent->back->forward != ent->back->forward_last) {
+ /* This point is a branch */
+ *branch_point = ent;
+ break;
+ }
+ ent = ent->back;
+ }
+}
+
/* exported interface documented in desktop/local_history.h */
bool
local_history_keypress(struct local_history_session *session, uint32_t key)
@@ -452,7 +482,7 @@ local_history_keypress(struct local_history_session
*session, uint32_t key)
return true;
case NS_KEY_LEFT:
/* Go to parent */
- if (session->cursor->back) {
+ if (session->cursor->back != NULL) {
session->cursor = session->cursor->back;
local_history_scroll_to_cursor(session);
session->cw_t->invalidate(session->core_window_handle,
NULL);
@@ -461,7 +491,7 @@ local_history_keypress(struct local_history_session
*session, uint32_t key)
return true;
case NS_KEY_RIGHT:
/* Go to preferred child if there is one */
- if (session->cursor->forward_pref) {
+ if (session->cursor->forward_pref != NULL) {
session->cursor = session->cursor->forward_pref;
local_history_scroll_to_cursor(session);
session->cw_t->invalidate(session->core_window_handle,
NULL);
@@ -470,25 +500,52 @@ local_history_keypress(struct local_history_session
*session, uint32_t key)
return true;
case NS_KEY_DOWN:
/* Go to next sibling down, if there is one */
- if (session->cursor->next) {
+ if (session->cursor->next != NULL) {
session->cursor = session->cursor->next;
- local_history_scroll_to_cursor(session);
- session->cw_t->invalidate(session->core_window_handle,
NULL);
+ } else {
+ struct history_entry *branch_point = NULL;
+ _local_history_find_branch_point(
+ session->cursor,
+ &branch_point);
+ if (branch_point != NULL) {
+ if (branch_point->next != NULL) {
+ branch_point = branch_point->next;
+ }
+ session->cursor = branch_point;
+ }
}
/* We have handled this keypress */
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle, NULL);
return true;
case NS_KEY_UP:
/* Go to next sibling up, if there is one */
- if (session->cursor->back) {
+ if (session->cursor->back != NULL) {
struct history_entry *ent =
session->cursor->back->forward;
- while (ent->next != NULL && ent->next !=
session->cursor) {
+ while (ent != session->cursor &&
+ 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);
+ if (session->cursor != ent) {
+ session->cursor = ent;
+ } else {
+ struct history_entry *branch_point = NULL;
+ _local_history_find_branch_point(
+ session->cursor,
+ &branch_point);
+ if (branch_point != NULL) {
+ struct history_entry *ent =
branch_point->back->forward;
+ while (ent->next != NULL && ent->next
!= branch_point) {
+ ent = ent->next;
+ }
+ session->cursor = ent;
+ }
+ }
}
/* We have handled this keypress */
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle, NULL);
return true;
}
return false;
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org