Architecture
View transitions
Section titled “View transitions”Opening focus or preview, or opening jaq from the input or focus view, enters a child view. Pressing Esc while browsing returns one level to the calling view, preserving its selection and display state. Rerunning an expression with : inside jaq updates the current view’s results. :print writes a value to standard output and exits vy.
Viewer flow
Section titled “Viewer flow”viewer.rs defines the View trait and the types passed between Viewer and each View.
Viewer::run() in runtime.rs controls input, execution, and rendering.
The diagram shows a typical iteration after the initial render.
flowchart TD
A["Wait for terminal input or a Tick"]
B["Viewer prepares a ViewEvent"]
C["Active View.update(event)"]
D{"Returned ViewUpdate"}
A --> B --> C --> D
D -->|"Ignored / Handled"| A
D -->|"Render"| R
D -->|"Effect(effect)"| E["Viewer executes the request"]
E --> F{"Does the operation exit run?"}
F -->|"Quit, external config edit, or print"| X["Return ViewerOutcome to the caller"]
F -->|"Continue"| N["Send notifications and transition views as needed"]
N --> R["Active View.render(width, height)"]
R --> G["Receive a ViewFrame"]
G --> H["Viewer renders to the terminal"]
H --> A
The following table maps each diagram node to its code. BrowseView is linked as a concrete View implementation.
| Node | Corresponding code |
|---|---|
| Wait for terminal input or a Tick | tokio::select! in run() |
| Viewer prepares a ViewEvent | dispatch_event(), Tick creation and dispatch |
| Active View.update(event) | Action dispatch, BrowseView::update() |
| Returned ViewUpdate | Response handling in run(), ViewUpdate definition |
| Viewer executes the request | execute_effect() |
| Does the operation exit run? | Checking the return value of execute_effect() |
| Return ViewerOutcome to the caller | Return from run(), Outcome handling in main |
| Send notifications and transition views as needed | Notifications and stack push in open_view(), Copy result notification, BrowseView::notify() |
| Active View.render(width, height) | Calling render on the active View, BrowseView::render() |
| Receive a ViewFrame | Receiving frame, ViewFrame definition |
| Viewer renders to the terminal | Updating the Renderer and drawing |
