Instruction file imported from openmarketdata/qpad3 (
.github/instructions/viewer.instructions.md). Copyright stays with the author.
REPL Viewer — src/viewer.mjs
Readonly CodeMirror 6 instance that displays q input/output with gutter markers.
Conventions
- Uses
StateField+StateEffect(addPrompt/clearPrompts) withRangeSetfor per-line gutter markers — follow this pattern for any new marker types. PromptMarkersubclass ofGutterMarkerrendersq)(input) and=>(output) markers.- Auto-trims to last 16
q)calls and 64=>results viatrimToFit(). - Theme is
viewerTheme, defined inline — dark theme consistent with the editor. - Shares
qLanguage+qHighlightStylefromlang-q.mjs.
When Modifying
Adding a new display format
- Extend
viewer.disp()to handle the new prompt type. - Add a new
GutterMarkersubclass following thePromptMarkerpattern. - Register the new marker in the gutter's
StateFieldif needed.
Adding visual panel tabs (future)
- The right pane (
div.two) will host tabs: REPL, Chart, Grid. - Viewer remains the REPL tab; new panels mount alongside in the same container.
- Tab switching should preserve viewer scroll position and state.