### Run Interactive Hello Example Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Runs the interactive 'Hello' example application using .NET. This requires a .NET runtime. ```bash dotnet run --project examples/Hello/Hello.csproj ``` -------------------------------- ### Run Headless Snapshots Example Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Runs the 'Smoke' example application for headless snapshot generation. This example does not require an active terminal. ```bash dotnet run --project examples/Smoke/Smoke.csproj ``` -------------------------------- ### Run Interactive Gallery Example Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Runs the interactive 'Gallery' example application, showcasing various Ratatui widgets like tabs, lists, tables, gauges, and sparklines. This requires a .NET runtime. ```bash dotnet run --project examples/Gallery/Gallery.csproj ``` -------------------------------- ### Install Ratatui.cs Alpha Preview Package Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Installs the latest alpha preview version of the Ratatui.cs package from the 'holo-q' source. This allows testing against ratatui 0.30. ```bash dotnet add package Ratatui.cs --version 0.2.0-alpha.* --source holo-q ``` -------------------------------- ### Run Composite Headless Example Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Runs the 'SmokeFrame' example application for composite headless rendering. This example is useful for generating snapshots without a terminal. ```bash dotnet run --project examples/SmokeFrame/SmokeFrame.csproj ``` -------------------------------- ### Install Ratatui.cs NuGet Package Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Installs a specific version of the Ratatui.cs NuGet package into your project. Ensure the GitHub Packages source has been added. ```bash dotnet add package Ratatui.cs --version ``` -------------------------------- ### Interactive Draw-in-Rect Example Source: https://github.com/holo-q/ratatui.cs/blob/main/src/Ratatui/README.md Demonstrates how to create and draw a paragraph widget within a specified rectangle using the Terminal and Paragraph classes. Ensure to dispose of the Terminal and Paragraph instances. ```csharp using Ratatui; using var term = new Terminal(); term.Clear(); using var para = new Paragraph("Hello from Ratatui.cs!\nThis is Ratatui via Rust FFI.") .Title("Demo"); term.DrawIn(para, new Rect(2, 1, 44, 6)); ``` -------------------------------- ### Get Ratatui FFI Version Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Retrieves the version of the ratatui FFI library. Useful for compatibility checks. ```c int ratatui_ffi_version(int* out_major, int* out_minor, int* out_patch); ``` -------------------------------- ### Get Ratatui FFI Feature Bits Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Retrieves a bitmask indicating the features supported by the ratatui FFI library. Used for feature detection. ```c int ratatui_ffi_feature_bits(); ``` -------------------------------- ### Terminal Cursor Helpers Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/terminal-and-app.md Utilize cursor helper functions to get and set the cursor's position within the terminal viewport. ```csharp GetCursor() SetCursor(x,y) ``` -------------------------------- ### Build Native Library (Release) Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Builds the native Rust cdylib for Ratatui.cs in release mode. Ensure you are in the `native/ratatui_ffi` directory. ```bash cd native/ratatui_ffi && cargo build --release ``` -------------------------------- ### Headless Snapshot Testing for CI Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Illustrates how to generate headless snapshots of UI elements for use in CI pipelines. Requires `Ratatui.cs` and `Ratatui.cs.Testing` packages. ```csharp using Ratatui.Testing; using var table = new Table().Title("T").Headers("A","B").AppendRow("1","2"); var snapshot = Headless.RenderTable(30, 6, table); Console.WriteLine(snapshot); ``` -------------------------------- ### Basic Terminal UI with Paragraph Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Demonstrates creating a simple terminal UI with a paragraph widget and drawing it to the terminal. Requires `Ratatui.cs` package. ```csharp using Ratatui; using var term = new Terminal(); using var p = new Paragraph("Hello from C#").Title("Demo"); var (w,h) = term.Size(); term.Draw(p, new Rect(0,0,w,h)); ``` -------------------------------- ### Headless Rendering for Testing Source: https://github.com/holo-q/ratatui.cs/blob/main/src/Ratatui/README.md Illustrates using headless rendering functions for snapshot testing without a physical console. These methods are designed to be allocation-light and deterministic. ```csharp Headless.Render(...); RenderStylesEx(...); RenderCells(...); ``` -------------------------------- ### Build Native Library (Debug) Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Builds the native Rust cdylib for Ratatui.cs in debug mode. Ensure you are in the `native/ratatui_ffi` directory. ```bash cd native/ratatui_ffi && cargo build ``` -------------------------------- ### Batched Frame Rendering with Multiple Widgets Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Shows how to render multiple widgets efficiently in a single frame using batched draw commands. Requires `Ratatui.cs` package. ```csharp term.DrawFrame( DrawCommand.Paragraph(p, new Rect(0,0,w/2,h)), DrawCommand.Gauge(new Gauge().Ratio(0.42f).Title("Load"), new Rect(w/2,0,w/2,3)) ); ``` -------------------------------- ### Using Native Helpers for RGB and Indexed Colors Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/csharp-ergonomics.md Demonstrates how to obtain native color values for RGB and indexed colors, which can then be plugged into FFI calls. ```csharp var rgb = Interop.Native.RatatuiColorRgb(0x33, 0x66, 0x99); var idx = Interop.Native.RatatuiColorIndexed(123); ``` -------------------------------- ### Run Quick Coverage Check Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ffi-coverage-and-stubs.md Execute the binding coverage tool locally to check parity between C# DllImports and native Rust exports. Ensure the Ratatui.dll is built. ```bash dotnet run --project tools/BindingCoverage/BindingCoverage.csproj -- --assembly src/Ratatui/bin/Debug/net9.0/Ratatui.dll --project-dir src/Ratatui ``` -------------------------------- ### Using BlockAdv for Borders and Padding Source: https://github.com/holo-q/ratatui.cs/blob/main/src/Ratatui/README.md Demonstrates how to use BlockAdv to configure borders, padding, and title alignment for a widget with zero extra allocations. Titles can be set using fast UTF-8 span overloads. ```csharp para.WithBlock(new BlockAdv(Borders.All, BorderType.Plain, Padding.All(1), Alignment.Center)); ``` -------------------------------- ### Add GitHub Packages Source for Alpha Preview Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Adds the GitHub Packages feed for Ratatui.cs alpha previews. Replace placeholders with your GitHub username and token. ```bash dotnet nuget add source https://nuget.pkg.github.com/holo-q/index.json -n holo-q -u -p --store-password-in-clear-text ``` -------------------------------- ### Basic Usage of push-watch.sh Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ci-push-watch.md Execute the script to automatically detect the workflow, push the current branch, and attach to the CI run. This is the simplest way to use the script. ```bash scripts/push-watch.sh ``` -------------------------------- ### Headless Rendering of a Frame with Multiple Widgets Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/csharp-ergonomics.md Performs headless snapshot rendering of a frame containing a paragraph and a table, useful for deterministic testing. ```csharp using Ratatui.Testing; var ascii = Headless.RenderFrame(80, 24, DrawCommand.Paragraph(para, new Rect(0,0,40,5)), DrawCommand.Table(table, new Rect(0,6,80,10)) ); ``` -------------------------------- ### Headless Snapshot Rendering for Tests Source: https://github.com/holo-q/ratatui.cs/blob/main/src/Ratatui/README.md Shows how to render a paragraph widget to an ASCII string for use in automated tests. The Headless.Render method allows for deterministic snapshot testing of UI components. ```csharp using Ratatui; using var para = new Paragraph("Snapshot me").Title("Test"); var ascii = Headless.Render( new Rect(0, 0, 24, 5), DrawCommand.Paragraph(para, new Rect(0, 0, 24, 5)) ); // Assert on `ascii` or save to file for golden tests ``` -------------------------------- ### Add GitHub Packages NuGet Source Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Adds the GitHub Packages feed for Ratatui.cs as a NuGet source. Replace placeholders with your GitHub username and personal access token. ```bash dotnet nuget add source https://nuget.pkg.github.com/holo-q/index.json -n holo-q -u -p --store-password-in-clear-text ``` -------------------------------- ### Batched Frame Rendering with Multiple Widgets Source: https://github.com/holo-q/ratatui.cs/blob/main/src/Ratatui/README.md Illustrates rendering multiple widgets (List and Chart) within a single frame using headless rendering. This approach is efficient for drawing complex UIs by batching draw commands. ```csharp using var list = new List().Title("Items").Items("A", "B", "C"); using var chart = new Chart().Title("Line").Line("L1", new [] { (0.0,1.0), (1.0,2.0) }); var rect = new Rect(0, 0, 60, 12); var left = new Rect(0, 0, 30, rect.Height); var right = new Rect(30, 0, 30, rect.Height); var ascii = Headless.Render( rect, DrawCommand.List(list, left), DrawCommand.Chart(chart, right) ); ``` -------------------------------- ### Key DllImport Declarations for Ratatui FFI Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Provides essential P/Invoke declarations for interacting with the Ratatui FFI library, including terminal initialization, drawing, widget creation, and layout functions. ```csharp static class Native { const string Lib = "ratatui_ffi"; // resolver maps to .dll/.so/.dylib [DllImport(Lib)] public static extern IntPtr ratatui_init_terminal(); [DllImport(Lib)] public static extern void ratatui_terminal_free(IntPtr t); [DllImport(Lib)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool ratatui_terminal_draw_frame(IntPtr t, IntPtr cmds, UIntPtr len); [DllImport(Lib)] public static extern IntPtr ratatui_paragraph_new_empty(); [DllImport(Lib)] public static extern void ratatui_paragraph_free(IntPtr p); [DllImport(Lib)] public static extern void ratatui_paragraph_append_spans(IntPtr p, IntPtr spans, UIntPtr len); [DllImport(Lib)] public static extern void ratatui_paragraph_set_alignment(IntPtr p, uint align); [DllImport(Lib)] public static extern void ratatui_paragraph_set_block_title_alignment(IntPtr p, uint align); [DllImport(Lib)] public static extern void ratatui_layout_split_ex2(ushort w, ushort h, uint dir, IntPtr kinds, IntPtr valsA, IntPtr valsB, UIntPtr len, ushort spacing, ushort ml, ushort mt, ushort mr, ushort mb, IntPtr outRects, UIntPtr cap); [DllImport(Lib)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool ratatui_headless_render_frame_cells(ushort w, ushort h, IntPtr cmds, UIntPtr len, IntPtr outCells, UIntPtr cap); [DllImport(Lib)] public static extern void ratatui_string_free(IntPtr s); } ``` -------------------------------- ### Emit Suggestions for FFI Bindings Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ffi-coverage-and-stubs.md Use the coverage tool to generate a suggestions file listing missing or stale FFI bindings. This file contains human-readable comments and template DllImport stubs. ```bash dotnet run --project tools/BindingCoverage/BindingCoverage.csproj -- --assembly src/Ratatui/bin/Debug/net9.0/Ratatui.dll --project-dir src/Ratatui --emit-suggestions obj/Debug/net9.0/Native.Suggestions.g.cs ``` -------------------------------- ### Batching with FfiSpans Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md Use this helper to pack multiple styled runs into a single buffer and call a native batch API once. It's suitable for general text rendering where you have a collection of spans to send. ```csharp Batching.WithFfiSpans(ReadOnlySpan runs, Action call) ``` -------------------------------- ### Open Run in Browser Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ci-push-watch.md Use the `--open` option to automatically open the GitHub Actions run in your web browser after the script attaches to it. ```bash scripts/push-watch.sh --open ``` -------------------------------- ### Render a List Widget Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/headless-testing.md Renders a list widget to a specified width and height. Use RenderListState for lists with associated state. ```csharp Headless.RenderList(width, height, list) ``` ```csharp Headless.RenderListState(width, height, list, state) ``` -------------------------------- ### Batching with FfiLineSpans Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md This helper is designed for batching multiple lines, where each line itself contains multiple styled runs. It's useful for rendering multi-line text structures efficiently. ```csharp Batching.WithFfiLineSpans(ReadOnlySpan> lines, Action call) ``` -------------------------------- ### Set Native Library Directory Environment Variable Source: https://github.com/holo-q/ratatui.cs/blob/main/README.md Sets the `RATATUI_FFI_DIR` environment variable to point to the directory containing the built native library. Use this if you encounter a `DllNotFoundException`. ```bash export RATATUI_FFI_DIR=$(pwd)/native/ratatui_ffi/target/debug ``` -------------------------------- ### Splitting a Rectangle Vertically using Layout Helpers Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/csharp-ergonomics.md Illustrates using managed layout helpers to split a rectangular area into two vertical sections. ```csharp var parent = new Rect(0, 0, 120, 30); var (left, right) = parent.SplitVertical(60); ``` -------------------------------- ### Emit Compile-Ready FFI Stubs Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ffi-coverage-and-stubs.md Generate minimal, compile-ready interop stubs for FFI bindings. This is useful for immediate compilation on day-zero FFI changes, allowing developers to refine signatures afterward. ```bash dotnet run --project tools/BindingCoverage/BindingCoverage.csproj -- --assembly src/Ratatui/bin/Debug/net9.0/Ratatui.dll --project-dir src/Ratatui --emit-generated obj/Debug/net9.0/Native.Generated.g.cs ``` -------------------------------- ### Render a Frame with Draw Commands Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/headless-testing.md Renders a complete frame using an array of draw commands to a specified width and height. Useful for complex UI rendering tests. ```csharp Headless.RenderFrame(width, height, params DrawCommand[]) ``` -------------------------------- ### Run Asynchronous App Handler with Task Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/terminal-and-app.md Execute an asynchronous application using App.RunAsync with a handler that returns a Task. Supports optional polling interval and cancellation token. ```csharp App.RunAsync(Func handler, TimeSpan? poll = null, CancellationToken ct = default) ``` -------------------------------- ### Run Asynchronous App Handler with Task Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/terminal-and-app.md Run an asynchronous application using App.RunAsync with a handler that returns a Task. Supports optional polling interval and cancellation token. ```csharp App.RunAsync(Func> handler, TimeSpan? poll = null, CancellationToken ct = default) ``` -------------------------------- ### Applying BlockAdv for Widget Borders, Padding, and Title Alignment Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/csharp-ergonomics.md Provides a uniform way to set borders, padding, and title alignment for widgets without extra allocations. Internally calls native *_set_block_adv and *_set_block_title_alignment. ```csharp var adv = new BlockAdv( Borders.All, BorderType.Plain, Padding.All(1), Alignment.Center); para.WithBlock(adv); list.WithBlock(adv); table.WithBlock(adv); tabs.WithBlock(adv); gauge.WithBlock(adv); barchart.WithBlock(adv); sparkline.WithBlock(adv); scrollbar.WithBlock(adv); ``` -------------------------------- ### Batching with FfiRowsCellsLines Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md Use this for batching complex row structures, where each row can contain multiple cells, and each cell can represent a line of styled runs. Ideal for tables or grid-like layouts. ```csharp Batching.WithFfiRowsCellsLines(ReadOnlySpan rows, Action call) ``` -------------------------------- ### Render a Table Widget Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/headless-testing.md Renders a table widget to a specified width and height. Suitable for testing tabular data layouts. ```csharp Headless.RenderTable(width, height, table) ``` -------------------------------- ### Specify Workflow, Remote, and Branch Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ci-push-watch.md Customize the script's behavior by specifying the workflow file to watch, the remote repository, and the branch to push. This provides fine-grained control over the CI monitoring process. ```bash scripts/push-watch.sh -w ci.yml -r origin -b main ``` -------------------------------- ### Run Synchronous App Handler Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/terminal-and-app.md Execute an application with a synchronous event handler using App.Run. Optionally specify a polling interval. ```csharp App.Run(Func handler, TimeSpan? poll = null) ``` -------------------------------- ### Safe Terminal Management Source: https://github.com/holo-q/ratatui.cs/blob/main/src/Ratatui/README.md Shows how to safely manage terminal raw mode and alternate screen toggles using a 'using' statement for automatic disposal. This ensures proper unwinding of terminal states. ```csharp using var term = new Terminal(); term.Raw(true).AltScreen(true); ``` -------------------------------- ### Render a Paragraph Widget Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/headless-testing.md Renders a paragraph widget to a specified width and height. Useful for testing text layout and wrapping. ```csharp Headless.RenderParagraph(width, height, paragraph) ``` -------------------------------- ### Event Handling Loop Source: https://github.com/holo-q/ratatui.cs/blob/main/src/Ratatui/README.md Demonstrates how to asynchronously iterate over terminal events, such as key presses. The loop breaks when the Escape key is pressed. ```csharp await foreach (var evt in term.Events()) { if (evt is KeyEvent k && k.Code == KeyCode.Esc) break; } ``` -------------------------------- ### Render Frame Headless (Text) Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Renders a frame using headless mode to capture text output. Used for snapshot testing. ```c const char* ratatui_headless_render_frame(const char* frame_json); ``` -------------------------------- ### Render Frame Headless (Styles) Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Renders a frame using headless mode to capture extended style information. Used for snapshot testing. ```c const char* ratatui_headless_render_frame_styles_ex(const char* frame_json); ``` -------------------------------- ### Minimal Interop Structs for C# Bindings Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Defines sequential-layout structs used for FFI communication, mirroring C data structures for rectangles, styles, spans, lines, and cell information. ```csharp [StructLayout(LayoutKind.Sequential)] public struct FfiRect { public ushort x, y, width, height; } [StructLayout(LayoutKind.Sequential)] public struct FfiStyle { public uint fg, bg; public ushort mods; } [StructLayout(LayoutKind.Sequential)] public struct FfiSpan { public IntPtr text_utf8; public FfiStyle style; } [StructLayout(LayoutKind.Sequential)] public struct FfiLineSpans { public IntPtr spans; public UIntPtr len; } [StructLayout(LayoutKind.Sequential)] public struct FfiCellInfo { public uint ch, fg, bg; public ushort mods; } ``` -------------------------------- ### Terminal RAII for Raw, AltScreen, and Cursor Toggles Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/csharp-ergonomics.md Manages terminal states like raw mode, alternate screen, and cursor visibility using RAII. The terminal state automatically unwinds on Dispose. ```csharp using var term = new Terminal() .Raw(true) .AltScreen(true) .ShowCursor(false); // draw... var (w, h) = term.Size(); term.Viewport = new Rect(0, 0, w, h); term.SetCursor(0, 0); // terminal state automatically unwinds on Dispose() ``` -------------------------------- ### TypeScript ffi-napi/ref Structures Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Defines the equivalent data structures for Ratatui FFI using TypeScript with ffi-napi and ref-napi, including types for rectangles, styles, and spans. ```typescript import ref from 'ref-napi'; import StructDi from 'ref-struct-di'; const Struct = StructDi(ref); const ushort = ref.types.uint16; const uint = ref.types.uint32; const size_t = ref.types.size_t; const voidPtr = ref.refType(ref.types.void); export const FfiRect = Struct({ x: ushort, y: ushort, width: ushort, height: ushort }); export const FfiStyle = Struct({ fg: uint, bg: uint, mods: ref.types.uint16 }); export const FfiSpan = Struct({ text_utf8: ref.types.CString, style: FfiStyle }); export const FfiLineSpans = Struct({ spans: ref.refType(FfiSpan), len: size_t }); export const FfiCellInfo = Struct({ ch: uint, fg: uint, bg: uint, mods: ref.types.uint16 }); ``` -------------------------------- ### Terminal Batched Draw Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/terminal-and-app.md Implement batched drawing for efficiency using DrawFrame with a ReadOnlySpan or widget-specific draw overloads. ```csharp DrawFrame(ReadOnlySpan) widget.Draw(widget, rect) ``` -------------------------------- ### Render Frame Headless (Cells) Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Renders a frame using headless mode to capture detailed cell information. Used for snapshot testing. ```c const char* ratatui_headless_render_frame_cells(const char* frame_json); ``` -------------------------------- ### TypeScript ffi-napi Function Bindings Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Binds to the Ratatui FFI library using ffi-napi in TypeScript. This includes function signatures for terminal operations, layout, and rendering. ```typescript import ffi from 'ffi-napi'; const lib = ffi.Library(process.platform === 'win32' ? 'ratatui_ffi' : 'libratatui_ffi', { ratatui_init_terminal: [ voidPtr, [] ], ratatui_terminal_free: [ 'void', [ voidPtr ] ], ratatui_paragraph_new_empty: [ voidPtr, [] ], ratatui_paragraph_free: [ 'void', [ voidPtr ] ], ratatui_paragraph_append_spans: [ 'void', [ voidPtr, ref.refType(FfiSpan), size_t ] ], ratatui_paragraph_set_alignment: [ 'void', [ voidPtr, 'uint' ] ], ratatui_paragraph_set_block_title_alignment: [ 'void', [ voidPtr, 'uint' ] ], ratatui_layout_split_ex2: [ 'void', [ 'uint16','uint16','uint', ref.refType('uint'), ref.refType('uint16'), ref.refType('uint16'), size_t, 'uint16','uint16','uint16','uint16','uint16', ref.refType(FfiRect), size_t ] ], ratatui_headless_render_frame_cells: [ 'size_t', [ 'uint16','uint16', voidPtr, size_t, ref.refType(FfiCellInfo), size_t ] ], ratatui_string_free: [ 'void', [ ref.types.CString ] ], }); ``` -------------------------------- ### Optional Git Alias for push-watch.sh Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ci-push-watch.md Configure a git alias for easier use of the push-watch.sh script. This allows you to use `git pushw` instead of `scripts/push-watch.sh -- `. ```bash git config alias.pushw '!scripts/push-watch.sh -- ' ``` -------------------------------- ### Introspect FFI Exports (JSON) Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Generates a JSON output detailing all available FFI exports. Essential for ensuring binding coverage. ```bash cargo run --quiet --bin ffi_introspect -- --json ``` -------------------------------- ### Paragraph Widget: AppendSpans Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md A shortcut for the Paragraph widget to append styled runs. Use this when you need to add text with specific styling to a paragraph. ```csharp AppendSpans ``` -------------------------------- ### List Widget: AppendItems Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md Adds multiple items to a list widget, where each item is a collection of styled runs. Suitable for populating lists with several styled entries at once. ```csharp AppendItems(ReadOnlySpan>) ``` -------------------------------- ### Render Various Chart Widgets Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/headless-testing.md Renders different types of chart widgets including Gauge, Tabs, BarChart, Sparkline, Scrollbar, and Chart to a specified width and height. ```csharp Headless.RenderGauge(width, height, widget) Headless.RenderTabs(width, height, widget) Headless.RenderBarChart(width, height, widget) Headless.RenderSparkline(width, height, widget) Headless.RenderScrollbar(width, height, widget) Headless.RenderChart(width, height, widget) ``` -------------------------------- ### Render Frame Styles Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/headless-testing.md Renders frame styles, either using RenderFrameStyles or the extended RenderFrameStylesEx. Useful for asserting detailed styling. ```csharp Headless.RenderFrameStyles(width, height, ...) ``` ```csharp Headless.RenderFrameStylesEx(...) ``` -------------------------------- ### Render Frame Cells Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/headless-testing.md Renders frame cells, returning an array of CellInfo objects containing character, foreground color, background color, and modifiers. Ideal for detailed cell-level assertions. ```csharp Headless.RenderFrameCells(width, height, ...) → returns CellInfo[] { ch, fg, bg, mods } ``` -------------------------------- ### Python ctypes Structures Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Defines the necessary ctypes Structures for interop with the Ratatui FFI, including rectangles, styles, spans, and cell information. ```python from ctypes import * class FfiRect(Structure): _fields_ = [("x", c_ushort), ("y", c_ushort), ("width", c_ushort), ("height", c_ushort)] class FfiStyle(Structure): _fields_ = [("fg", c_uint), ("bg", c_uint), ("mods", c_ushort)] class FfiSpan(Structure): _fields_ = [("text_utf8", c_char_p), ("style", FfiStyle)] class FfiLineSpans(Structure): _fields_ = [("spans", POINTER(FfiSpan)), ("len", c_size_t)] class FfiCellInfo(Structure): _fields_ = [("ch", c_uint), ("fg", c_uint), ("bg", c_uint), ("mods", c_ushort)] ``` -------------------------------- ### Terminal RAII Toggles Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/terminal-and-app.md Use RAII toggles to manage terminal states like raw mode, alternate screen, and cursor visibility. Ensure safe unwinding in Dispose() for proper terminal cleanup. ```csharp Raw(true) AltScreen(true) ShowCursor(false) ``` -------------------------------- ### Table Widget: AppendRows Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md Appends multiple rows to a table widget, where each row is a collection of styled runs. Efficient for populating tables with several styled rows. ```csharp AppendRows(ReadOnlySpan) ``` -------------------------------- ### Python ctypes Function Prototypes Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Declares function prototypes for interacting with the Ratatui FFI library using ctypes. This includes initialization, cleanup, and specific widget functions. ```python lib = CDLL("libratatui_ffi.so") # resolve per OS lib.ratatui_init_terminal.restype = c_void_p lib.ratatui_terminal_free.argtypes = [c_void_p] lib.ratatui_paragraph_new_empty.restype = c_void_p lib.ratatui_paragraph_free.argtypes = [c_void_p] lib.ratatui_paragraph_append_spans.argtypes = [c_void_p, POINTER(FfiSpan), c_size_t] lib.ratatui_paragraph_set_alignment.argtypes = [c_void_p, c_uint] lib.ratatui_paragraph_set_block_title_alignment.argtypes = [c_void_p, c_uint] lib.ratatui_layout_split_ex2.argtypes = [c_ushort,c_ushort,c_uint, POINTER(c_uint),POINTER(c_ushort),POINTER(c_ushort),c_size_t, c_ushort,c_ushort,c_ushort,c_ushort,c_ushort, POINTER(FfiRect),c_size_t] lib.ratatui_headless_render_frame_cells.argtypes = [c_ushort,c_ushort,c_void_p,c_size_t,POINTER(FfiCellInfo),c_size_t] lib.ratatui_headless_render_frame_cells.restype = c_size_t lib.ratatui_string_free.argtypes = [c_char_p] ``` -------------------------------- ### Table Widget: Headers Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md Defines the header row for a table widget using styled runs. Use this to set the appearance of table column headers. ```csharp Headers(ReadOnlySpan) ``` -------------------------------- ### Rerun Failed Jobs Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ci-push-watch.md If the CI run fails, the `--rerun-failed` option will attempt to rerun only the failed jobs once. This can be useful for transient failures. ```bash scripts/push-watch.sh --rerun-failed ``` -------------------------------- ### Terminal Async Event Loop Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/terminal-and-app.md Process asynchronous terminal events within a loop using await foreach. Specify an interval for event polling. ```csharp await foreach (var ev in term.Events(interval, ct)) { ... } ``` -------------------------------- ### List Widget: AppendItem Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md Adds a single item to a list widget, where the item is composed of styled runs. Useful for creating list entries with custom styling. ```csharp AppendItem(ReadOnlySpan) ``` -------------------------------- ### Tabs Widget: AddTitleSpans Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md Adds styled runs for a single tab title. Use this to define the appearance of individual tab headers. ```csharp AddTitleSpans ``` -------------------------------- ### Paragraph Widget: AppendLineSpans Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md A shortcut for the Paragraph widget to append styled runs for a new line. Use this to add distinct lines of styled text within a paragraph. ```csharp AppendLineSpans ``` -------------------------------- ### Attach to CI Run Without Pushing Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ci-push-watch.md Use the `--no-push` option to only attach to the CI run for the current HEAD commit without performing a git push. This is useful if you have already pushed. ```bash scripts/push-watch.sh --no-push ``` -------------------------------- ### Tabs Widget: SetTitlesSpans Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md Sets multiple tab titles, each defined by styled runs. Use this to configure all tab headers for a Tabs widget. ```csharp SetTitlesSpans(ReadOnlySpan>) ``` -------------------------------- ### Free FFI Allocated String Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Frees a UTF-8 string allocated by the FFI. Crucial for preventing memory leaks. ```c void ratatui_string_free(const char* str); ``` -------------------------------- ### Custom Polling Interval Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/ci-push-watch.md Adjust the polling interval for discovering the GitHub Actions run using the `--poll` option. The default is 3 seconds. ```bash scripts/push-watch.sh --poll 10 ``` -------------------------------- ### Clear Frame Content Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/headless-testing.md Clears the content of a frame to a specified width and height. Useful for resetting the frame buffer in tests. ```csharp Headless.RenderClear(width, height) ``` -------------------------------- ### Free FFI Handle Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/bindings-update-playbook.md Frees a handle (e.g., from a `*_new()` function) allocated by the FFI. Prevents memory leaks. ```c void ratatui_some_handle_free(SomeHandle* handle); ``` -------------------------------- ### Table Widget: AppendRow Source: https://github.com/holo-q/ratatui.cs/blob/main/docs/batching-and-spans.md Appends a single row to a table widget, where the row is defined by styled runs. Use for adding rows with custom text and styling. ```csharp AppendRow(ReadOnlySpan) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.