@jsvision/ui / DrawContext
Interface: DrawContext
Defined in: ui/src/view/types.ts:38
The stateless, view-local, auto-clipped paint API handed to View.draw(ctx). Coordinates are view-local: (0, 0) is this view's top-left. The context offsets to the view's absolute screen position and clips to the view's rect intersected with its ancestors', silently dropping any write that falls outside — so a widget can draw freely without worrying about overflow.
Properties
caps
readonlycaps:CapabilityProfile
Defined in: ui/src/view/types.ts:61
The resolved terminal capabilities for this frame. Read caps.glyphs/caps.unicode at draw time to pick an ASCII vs. Unicode glyph form (e.g. a progress bar's #/- fallback on a terminal that can't render block characters). This is the same capability profile the renderer encodes with, so your glyph choice and the renderer's fallback always agree.
revealAccelerators
readonlyrevealAccelerators:boolean
Defined in: ui/src/view/types.ts:69
Whether the accelerator (hotkey) overlay is revealed this frame. While true, a widget that draws a ~X~ hotkey should underline the hot glyph so every reachable shortcut lights up at once. The render root toggles it via setRevealAccelerators and clamps it to the active dispatch scope, so a background window behind a modal draws it as false. Default false; widgets that ignore it are unaffected.
size
readonlysize:Size2D
Defined in: ui/src/view/types.ts:54
The view's content size, in cells.
Methods
box()
box(
x,y,w,h,style?,title?):void
Defined in: ui/src/view/types.ts:43
Parameters
x
number
y
number
w
number
h
number
style?
title?
string
Returns
void
color()
color(
role):Style
Defined in: ui/src/view/types.ts:46
Resolve a named theme role to a Style (foreground/background).
Parameters
role
keyof Theme
Returns
fill()
fill(
char,style?):void
Defined in: ui/src/view/types.ts:42
Fill the whole view rect.
Parameters
char
string
style?
Returns
void
fillRect()
fillRect(
x,y,w,h,char,style?):void
Defined in: ui/src/view/types.ts:40
Parameters
x
number
y
number
w
number
h
number
char
string
style?
Returns
void
role()
role<
K>(name):Theme[K]
Defined in: ui/src/view/types.ts:52
Resolve a named theme role to its full role object, including extras that color drops (a desktop background pattern glyph, a window's border/title colors). Chrome widgets use this; the generic K keeps role('window').border type-safe with no cast.
Type Parameters
K
K extends keyof Theme
Parameters
name
K
Returns
Theme[K]
shadow()
shadow(
x,y,w,h,style?):void
Defined in: ui/src/view/types.ts:44
Parameters
x
number
y
number
w
number
h
number
style?
Returns
void
text()
text(
x,y,str,style?):void
Defined in: ui/src/view/types.ts:39
Parameters
x
number
y
number
str
string
style?
Returns
void