Arrow Navigation
By the end of this guide, you will:
-
Add a
selectedfield to your Model to track which file is highlighted -
Use
model.with(...)to create updated state immutably -
Use pattern matching (
case message) to handle multiple keys -
Combine pattern matching with predicate guards (
in _ if message.up?) -
Handle arrow keys (up/down) and vim keys (j/k) in one UPDATE
-
Scroll through the file list when itβs longer than the screen
-
Return an updated model from UPDATE to change state
-
Write tests that verify state transitions (selected: 0 β selected: 1)
-
Understand when to use pattern matching vs simple if/else
β οΈ This page is a stub. Help us write it! See the Documentation Plan and Style Guide.
User Stories
Story -1: Arrow Key Navigation
As a terminal user
I want to navigate through the file list with arrow keys
So that I can select different files
Acceptance Criteria
-
Up/Down arrow keys change which file is highlighted
-
βjβ/βkβ vim keys also work for navigation
-
Selection wraps at top/bottom of list
-
Visual highlight follows selection
Notes
-
Still using hardcoded file list
-
Adds interactive navigation