search: Add keybindings to Notepad open state
Created by: fkling
This commit adds keybindings to the Notepad entry list:
- Arrow up/down selects the next/previous item in the list.
- Shift + Arrow up/down adds or removes the next/previous deselected item to the selection.
- CTRL+a selects all items.
- Delete/Backspace removes all selected items.
- ESC deselects all selected items.
For any of these to work, the list or an element within it must have focus.
I had difficulties getting the the Shift-arrow up/down behavior right until I treated shift+arrow and shift+click as two different user interactions.
I also changed how selected items are being represented from using a list of selected entry IDs to a list of indexes. This requires some additional bookkeeping when items are added or removed.
I removed the background color change on hover to prevent people from thinking that any keybindings (but delete in particular) would interact with hover items.
Demo video from work in progress (ctrl+click to select multiple items, then shift+arrow up/down to extend/shrink selection):
https://user-images.githubusercontent.com/179026/157089346-da093166-17a8-4219-afb7-4a1309423b98.mp4
Test plan
New unit tests and manual testing. In particular:
- Select item and change selection with arrow up/down.
- Expand/shrink selection with shift+arrow up/down.
- Select non-consecutive items with ctrl+click and use shift+arrow up/down to expand selection. Already selected items are skipped.
- Delete/Backspace deletes selected items.
- Adding a new item with select it.
- Select non-consecutive items and click the delete button of a deselected item. The selection is preserved.
- Pressing escape deselects items.