Gum Tool Output System Reference
Architecture
IOutputManager (Tools/Gum.Presentation/Managers/MainOutputViewModel.cs):
AddOutput(string)— appends a timestamped lineAddError(string)— appends a timestamped line prefixed with"ERROR: "(two spaces), then raisesErrorAddedErrorAdded— eventMainOutputPluginsubscribes to, selecting the Output tab so an error is seen without a dialog
MainOutputViewModel — implements IOutputManager. Stores all output as a single OutputText string (not a list). Registered as a singleton in DI, aliased as both MainOutputViewModel and IOutputManager.
MainOutputPlugin — PriorityPlugin that creates the Output tab at TabLocation.RightBottom.
How to Write Output
Inject IOutputManager and call AddOutput or AddError directly — this is the standard approach. Callers must already be on the UI thread.
IGuiCommands.PrintOutput is a thin wrapper around AddOutput that marshals to the UI dispatcher — use this when calling from a background thread. There is no PrintError equivalent in IGuiCommands; callers needing AddError from a background thread must dispatch manually.
Non-Obvious Behaviors
- Buffer cap:
OutputTextis capped at 50,000 chars. When exceeded, it is trimmed to the last 25,000 chars — oldest output is silently discarded. - No dispatcher in
IOutputManager:AddOutput/AddErrorwrite directly to theOutputTextproperty with no thread marshaling. Calling from a background thread will throw. - Auto-scroll: The
TextBoxin the view usesTextBoxAutoScroll.AutoScrollToEnd="True"— new output scrolls into view automatically. AddErrorsteals the tab: it selects the Output tab, so it is the wrong call for a routine or repeated message. UseAddOutputunless the user genuinely needs to look now.- No per-line color: severity is carried by the
"ERROR: "text prefix. The view binds oneTextBoxto one concatenatedOutputTextstring, so coloring a single line needs the model changed to a line collection first.
Key Files
| File | Purpose |
|---|---|
Tools/Gum.Presentation/Managers/MainOutputViewModel.cs |
IOutputManager interface + MainOutputViewModel implementation |
Gum/Commands/GuiCommands.cs |
PrintOutput — dispatcher-safe wrapper |
Tools/Gum.Presentation/Commands/IGuiCommands.cs |
PrintOutput declaration |
Gum/Plugins/InternalPlugins/Output/MainOutputPlugin.cs |
Registers the Output tab |
Gum/Plugins/InternalPlugins/Output/MainOutputPluginView.xaml |
Output tab view (TextBox + clear button) |
Gum/Services/Builder.cs |
DI registration of MainOutputViewModel as IOutputManager |