Table of Contents

Class Renderer

Namespace
SharpConsoleUI
Assembly
SharpConsoleUI.dll

Handles rendering of windows and their content to the console display. Manages window borders, scrollbars, and content rendering with support for overlapping windows.

public class Renderer
Inheritance
Renderer
Inherited Members

Constructors

Renderer(ConsoleWindowSystem)

Initializes a new instance of the Renderer class.

public Renderer(ConsoleWindowSystem consoleWindowSystem)

Parameters

consoleWindowSystem ConsoleWindowSystem

The console window system that owns this renderer.

Methods

ClearArea(int, int, int, int, ITheme, IReadOnlyDictionary<string, Window>)

Clears a rectangular area with the desktop background.

public void ClearArea(int left, int top, int width, int height, ITheme theme, IReadOnlyDictionary<string, Window> windows)

Parameters

left int

The left coordinate.

top int

The top coordinate.

width int

The width of the area.

height int

The height of the area.

theme ITheme

The theme to use for background colors.

windows IReadOnlyDictionary<string, Window>

The collection of windows to invalidate if they overlap.

FillDesktopBackground(ITheme, int, int)

Fills the entire desktop area with the theme's background character and colors. Used for initializing the desktop background.

public void FillDesktopBackground(ITheme theme, int screenWidth, int screenHeight)

Parameters

theme ITheme

The theme to use for desktop colors.

screenWidth int

The width of the screen.

screenHeight int

The height of the screen.

FillRect(int, int, int, int, char, Color?, Color?)

Fills a rectangular area with a specified character and colors.

public void FillRect(int left, int top, int width, int height, char character, Color? backgroundColor, Color? foregroundColor)

Parameters

left int

The left coordinate of the rectangle.

top int

The top coordinate of the rectangle.

width int

The width of the rectangle.

height int

The height of the rectangle.

character char

The character to fill the rectangle with.

backgroundColor Color?

The background color, or null to use the default.

foregroundColor Color?

The foreground color, or null to use the default.

GetOverlappingRegions(Window, Window)

Gets the rectangular regions where two windows overlap.

public List<Rectangle> GetOverlappingRegions(Window window1, Window window2)

Parameters

window1 Window

The first window.

window2 Window

The second window.

Returns

List<Rectangle>

A list of rectangles representing the overlapping areas. Empty if windows do not overlap.

GetOverlappingWindows(Window, HashSet<Window>?)

Gets all windows that overlap with the specified window using iterative BFS. This avoids unbounded recursion and is more efficient than the recursive approach.

public HashSet<Window> GetOverlappingWindows(Window window, HashSet<Window>? visited = null)

Parameters

window Window

The window to check for overlaps.

visited HashSet<Window>

Optional set of already visited windows (ignored, kept for compatibility).

Returns

HashSet<Window>

A set of all windows that form an overlapping chain with the specified window.

IsOverlapping(Window, Window)

Determines whether two windows overlap each other.

public bool IsOverlapping(Window window1, Window window2)

Parameters

window1 Window

The first window.

window2 Window

The second window.

Returns

bool

True if the windows overlap; otherwise, false.

RenderRegion(Window, Rectangle)

Renders a specific region of a window. Used for partial window updates.

public void RenderRegion(Window window, Rectangle region)

Parameters

window Window

The window to render.

region Rectangle

The rectangular region to render.

RenderWindow(Window)

Renders a complete window including borders, content, and scrollbars. Handles visibility calculations for overlapping windows.

public void RenderWindow(Window window)

Parameters

window Window

The window to render.