API ReferenceGE ExtensionseditorvehicleEditorstaticEditor
Vehicle Editor - Part Text View
Syntax-highlighted, scrollable text view of JBeam source files using AST rendering, with inline editing of string, number, and boolean values.
Syntax-highlighted, scrollable text view of JBeam source files using AST rendering, with inline editing of string, number, and boolean values.
Module Exports
| Export | Type | Description |
|---|---|---|
M.menuEntry | string | "Part Text View" - menu label |
M.open | function | Shows the text view window |
M.onEditorGui | hook | Renders the AST-based text view and edit modal |
M.onEditorInitialized | hook | Registers window and modal |
Key Internals
| Variable | Type | Purpose |
|---|---|---|
clipper | ImGuiListClipper | Virtual scrolling for large files |
maxLineLength | number | Maximum rendered line width (for horizontal scroll) |
lineToScrollTo | number | Target line for auto-scroll (-1 = none) |
editNodeIdx | number/nil | AST node being edited in modal |
scrollToSelection | BoolPtr | Auto-scroll to selected AST nodes |
colorTable | table | Syntax colors for AST node types |
Syntax Colors
| AST Node Type | Color |
|---|---|
string / string_single | Blue (0.31, 0.73, 1) |
comment / comment_multiline | Green (0.42, 0.6, 0.29) |
list_begin / list_end | Yellow (0.95, 0.84, 0.06) |
object_begin / object_end | Pink (0.85, 0.39, 0.63) |
How It Works
- Reads the JBeam file for the selected part via
jbeamIO.getPart() - Renders AST nodes line-by-line using
ImGuiListClipperfor virtual scrolling - Each AST node is rendered with type-appropriate syntax coloring
- Selected nodes (from modifier leak visualizer, etc.) are highlighted with a red overlay
- Double-clicking a node opens an edit modal for strings, numbers, or booleans
- Menu bar provides: Reload, Save, Close, Delete, scroll-to-selection toggle
- File explorer button and file timestamp display
Lua Code Example
-- Open text view
extensions.editor_vehicleEditor_staticEditor_vePartTextView.open()
-- The text view uses virtual scrolling via ImGuiListClipper:
-- im.ImGuiListClipper_Begin(clipper, numLines, fontSize)
-- for lineNo = clipper.DisplayStart+1, clipper.DisplayEnd+1 do
-- -- render AST nodes for this line
-- end
-- AST node rendering with syntax highlighting:
-- local text = jsonAST.stringifyNodes({node})
-- local color = colorTable[node[1]] -- e.g., colorTable['string']
-- if color then im.PushStyleColor2(im.Col_Text, color) end
-- im.TextUnformatted(text)
-- Selected AST nodes (from other tools) highlighted with red overlay:
-- if vEditor.selectedASTNodeMap[nodeIdx] then
-- im.ImDrawList_AddRectFilled(drawList, rMin, rMax, nodeColorHighlightRed)
-- end
-- Double-click editing opens a modal:
-- if nodeType == 'string' then
-- nodeEditTextInput = im.ArrayChar(256, node[2])
-- elseif nodeType == 'number' then
-- nodeEditDoubleInput[0] = node[2]
-- elseif nodeType == 'bool' then
-- node[2] = not node[2] -- immediate toggle
-- end
-- Saving writes modified AST back to file:
-- writeFile(vEditor.astFilename, jsonAST.stringify(vEditor.ast.ast))
-- Auto-scroll to selected nodes:
-- local sumLineNums = 0
-- for nodeIdx in pairs(vEditor.selectedASTNodeMap) do
-- sumLineNums = sumLineNums + vEditor.ast.transient.nodeIdxToLineNum[nodeIdx]
-- end
-- lineToScrollTo = sumLineNums / numSelectedLinesSee Also
- Vehicle Editor - JBeam Beautifier - Related reference
- Vehicle Editor - JBeam Modifier Leaking Visualizer - Related reference
- Vehicle Editor - JBeam Spellchecker - Related reference
- World Editor Guide - Guide
Vehicle Editor - Part Property View
Generic property inspector window for editing individual JBeam table entries (nodes, beams, etc.) selected via the Part Tree view.
Vehicle Editor - Part Tree
Hierarchical tree view of JBeam part data with interactive 3D node/beam picking, selection, visibility toggling, and integration with the AST text view.