IWidgetTranslator
InterfaceCustomizes how virtual DOM nodes become layout Widgets.
Namespace:
RazorConsole.Core.Abstractions.RenderingAssembly:
RazorConsole.CoreDefinition
public interface IWidgetTranslatorRemarks:Register a translator with IServiceCollection). Translators run in registration order, before RazorConsole's built-in translation, for every node that becomes a widget of its own: the root, and every child that a built-in container translates through VNode). Some built-in elements read their content directly into a single widget, so those inner nodes never reach a translator: the text and inline elements (strong, a, code, ...) inside a paragraph or other inline run, headings, list items and nested lists, the code inside a pre, and the parts of built-in components such as chart series. To change those, handle the enclosing element. A translator either handles the node and returns a widget, or returns next(node) to pass it on. Calling next(node) and wrapping the result decorates the default translation. Translate child nodes with VNode), which runs the whole chain again. Never call it for the node being handled: that restarts the chain on the same node and recurses until the stack overflows. Use next(node) for the current node and context.Translate(child) only for its children. A translator must not return null. To show a Spectre.Console IRenderable, return a SpectreWidget; it is laid out as a leaf and painted into the terminal cells like any other widget.
Methods
1| Name | Type | Description |
|---|---|---|
Translate(WidgetTranslationContext, WidgetTranslationDelegate, VNode)() | Widget | Translates node, or passes it to next. |