Skip to content

Architecture

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.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.

NodeCorresponding code
Wait for terminal input or a Ticktokio::select! in run()
Viewer prepares a ViewEventdispatch_event(), Tick creation and dispatch
Active View.update(event)Action dispatch, BrowseView::update()
Returned ViewUpdateResponse handling in run(), ViewUpdate definition
Viewer executes the requestexecute_effect()
Does the operation exit run?Checking the return value of execute_effect()
Return ViewerOutcome to the callerReturn from run(), Outcome handling in main
Send notifications and transition views as neededNotifications 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 ViewFrameReceiving frame, ViewFrame definition
Viewer renders to the terminalUpdating the Renderer and drawing