Open theodore-norvell opened 7 years ago
Changed escape key to space character since it is easier to type, some keyboards (e.g. for tablets) don't have escape key, and I haven't thought of anything better for space to mean.
Completed.
I'm not perfectly happy with this. Two things bug me and I think they can both be fixed.
On the first focus move, put a pair consisting of the current path and anchor into the selection.
When a focus move would make the selection empty, first try going down by extending the focus path using an item from the saved anchor path. If that is not possible, swap the focus and anchor and update the original anchor path to reflect the swap.
I implemented part of the above. When the size of the selection is 1, the selection will swap anchor and focus to prevent the selection from becoming empty.
But it does not yet climb back down the tree.
Here are some more keyboard shortcuts.
shift-right arrow. Expand the selection to the right. shift-left arrow. Expand the selection to the left. shift-down arrow. Bigger expand the selection to the right. shift-up arrow. Bigger expand the selection to the left. Escape. Select the parent.
Details:
Select the parent:
Change the selection consisting of only the parent of the current selection. If the parent is the root, the edit will fail and there will be no change to the current selection.
Expand the selection to the right:
If the focus is less than the number of children the parent has, expand (or shrink) the current selection by incrementing the focus by 1. Otherwise it's the same as "Select the parent."
Expand the selection to the left:
If the focus is greater than zero, expand (or shrink) the current selection by decrementing the focus by 1. Otherwise it's the same as "Select the parent".
Bigger expand the selection to the right.
Repeat "Expand the selection to the right" at least once (if possible) until either it fails or the parent is a vertically laid out node.
Bigger expand the selection to the left.
Similar, but to the left.