xnano.geometry
xnano.geometry
¶
xnano.geometry
Points, sizes and rectangles, measured in cells.
These are plain values; the position of something that moves is an
Expression instead.
Classes:
-
Point–A cell position, counted in columns (
x) and rows (y) from the top-left. -
Rectangle–A rectangle of cells with half-open bounds.
-
Size–A width and a height, counted in cells.
-
SizeRule–How much space one child takes along a layout's main axis.
Point
¶
A cell position, counted in columns (x) and rows (y) from the top-left.
Maps to ratatui::layout::Position.
Parameters:
Attributes:
Examples:
point = Point(2, 3) + Point(1, 1)
assert (point.x, point.y) == (3, 4)
assert point - Point(3, 4) == Point(0, 0)
Create a Point.
Parameters:
-
API Reference
-
xnano
-
xnano -
xnano.buffers
buffersBufferposition -
xnano.canvas
canvasCanvaslocal -
xnano.cursor
cursorCursorposition -
xnano.events
eventsMouseEventposition -
xnano.expressions
expressions -
xnano.geometry
geometry -
xnano.input
inputMouseInputposition -
xnano.operations
operationsClearposition -
xnano.placement
placementPlacementlocal -
xnano.region
regionRegionlocal -
xnano.terminal
terminalTerminallocal -
xnano.widgets
widgets
-
-
xnano_core
-
xnano_core-
MousePosition -
PointerPosition -
Position -
ScreenPosition -
BarChartposition -
Blockposition -
Bufferposition -
BufferExpressionScopeposition -
Calendarposition -
Canvasposition -
Chartposition -
Clearposition -
Cursorposition -
CustomWidgetposition -
FrameSnapshotcursor_position -
Gaugeposition -
ItemListposition -
LineGaugeposition -
Liveposition -
MouseEventposition -
MouseExpressionScopeposition -
Paragraphposition -
Point -
Rectangleposition -
Scrollbarposition -
Sparklineposition -
Tableposition -
Tabsposition -
Widgetposition
-
-
xnano_core._xnano_core
_xnano_core-
MousePosition -
PointerPosition -
Position -
ScreenPosition -
BarChartposition -
Blockposition -
Bufferposition -
BufferExpressionScopeposition -
Calendarposition -
Canvasposition -
Chartposition -
Clearposition -
Cursorposition -
CustomWidgetposition -
FrameSnapshotcursor_position -
Gaugeposition -
ItemListposition -
LineGaugeposition -
Liveposition -
MouseEventposition -
MouseExpressionScopeposition -
Paragraphposition -
Point -
Rectangleposition -
Scrollbarposition -
Sparklineposition -
Tableposition -
Tabsposition -
Widgetposition
-
-
-
xnano
Methods:
-
__add__–Add two positions component by component.
-
__sub__–Subtract two positions component by component.
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
Rectangle
¶
A rectangle of cells with half-open bounds.
The left and top edges are inclusive, and the right and bottom edges are exclusive.
Maps to ratatui::layout::Rect.
Parameters:
-
x(int, default:0) –The left column.
-
y(int, default:0) –The top row.
-
width(int, default:0) –The number of columns.
-
height(int, default:0) –The number of rows.
Attributes:
-
x(int) –The left column.
-
y(int) –The top row.
-
width(int) –The number of columns.
-
height(int) –The number of rows.
-
position(Point) –The top-left corner.
-
size(Size) –The width and height.
-
area(int) –The number of cells,
width * height. -
is_empty(bool) –Whether the rectangle holds no cells.
Examples:
area = Rectangle(2, 1, 10, 4)
assert area.area == 40
assert area.contains(Point(2, 1))
assert not area.contains(Point(12, 1))
Create a Rectangle.
Parameters:
-
x(int, default:0) –int. Defaults to0. -
y(int, default:0) –int. Defaults to0. -
width(int, default:0) –int. Defaults to0. -
height(int, default:0) –int. Defaults to0.
-
API Reference
- xnano
-
xnano_core
-
xnano_core-
Bounds -
BufferRegion -
ScreenBounds -
BarChartbounds -
Blockbounds -
Bufferbounds -
BufferExpressionScoperegion -
Calendarbounds -
Canvasbounds -
Chartbounds -
Clearbounds -
CoreContextbounds -
CustomWidgetbounds -
EventContextbounds -
FrameContext -
Gaugebounds -
HitAreabounds -
ItemListbounds -
LineGaugebounds -
Livebounds -
Paragraphbounds -
Rectangle -
Regionbounds -
Scrollbarbounds -
Sparklinebounds -
Tablebounds -
Tabsbounds -
UpdateContextbounds -
Widgetbounds
-
-
xnano_core._xnano_core
_xnano_core-
Bounds -
BufferRegion -
ScreenBounds -
BarChartbounds -
Blockbounds -
Bufferbounds -
BufferExpressionScoperegion -
Calendarbounds -
Canvasbounds -
Chartbounds -
Clearbounds -
CustomWidgetbounds -
Gaugebounds -
HitAreabounds -
ItemListbounds -
LineGaugebounds -
Livebounds -
Paragraphbounds -
Rectangle -
Regionbounds -
Scrollbarbounds -
Sparklinebounds -
Tablebounds -
Tabsbounds -
Widgetbounds
-
-
xnano_core._xnano_core._core_types
_core_types
-
-
API Reference
- xnano
-
xnano_core
-
xnano_core-
BarChart -
Block -
Buffer -
Calendar -
Canvas -
Chart -
Clear -
CoreContextinvalidate -
CustomWidget -
Dissolvewith_area -
Editor -
Effectwith_area -
EventContextinvalidate -
Fadewith_area -
FrameContextinvalidate -
Gauge -
Glitchwith_area -
InputRouterhit_area -
ItemList -
LineGauge -
Liveregion -
Paragraph -
Rectangle -
Regioninvalidate -
Scrollbar -
Sparkline -
Surfaceinvalidate -
Table -
Tabs -
UpdateContextinvalidate -
Widget
-
-
xnano_core._xnano_core
_xnano_core -
xnano_core._xnano_core._core_types
_core_types
-
Methods:
-
contains–Whether
pointlies inside the rectangle. -
intersects–Whether the two rectangles share at least one cell.
-
intersection–The cells both rectangles share. The result is empty when they do not overlap.
-
union–The smallest rectangle that holds both rectangles.
-
translate–Move the rectangle by a number of columns and rows.
-
inset–Shrink the rectangle by a margin on every side.
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
contains
¶
intersects
¶
intersection
¶
union
¶
translate
¶
Move the rectangle by a number of columns and rows.
Parameters:
-
x(int, default:0) –Columns to move right; negative values move left.
-
y(int, default:0) –Rows to move down; negative values move up.
Examples:
assert Rectangle(0, 0, 4, 2).translate(2, 1) == Rectangle(2, 1, 4, 2)
assert Rectangle(5, 5, 4, 2).translate(x=-1, y=-2) == Rectangle(4, 3, 4, 2)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
inset
¶
Shrink the rectangle by a margin on every side.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
Size
¶
A width and a height, counted in cells.
Maps to ratatui::layout::Size.
Parameters:
Attributes:
Examples:
Create a Size.
Parameters:
-
API Reference
- xnano
-
xnano_core
-
xnano_core-
BufferSize -
ParentSize -
BarChartsize -
Blocksize -
Buffersize -
BufferExpressionScopesize -
Calendarsize -
Canvassize -
Chartsize -
Clearsize -
CustomWidgetsize -
Device -
Eventsize -
FrameSnapshotsize -
Gaugesize -
ItemListsize -
LineGaugesize -
Livesize -
Paragraphsize -
ParentExpressionScopesize -
Rectanglesize -
Scrollbarsize -
Sparklinesize -
Tablesize -
Tabssize -
Widgetsize
-
-
xnano_core._xnano_core
_xnano_core-
BufferSize -
ParentSize -
BarChartsize -
Blocksize -
Buffersize -
BufferExpressionScopesize -
Calendarsize -
Canvassize -
Chartsize -
Clearsize -
CustomWidgetsize -
Device -
Eventsize -
FrameSnapshotsize -
Gaugesize -
ItemListsize -
LineGaugesize -
Livesize -
Paragraphsize -
ParentExpressionScopesize -
Rectanglesize -
Scrollbarsize -
Sparklinesize -
Tablesize -
Tabssize -
Widgetsize
-
-
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
SizeRule
¶
How much space one child takes along a layout's main axis.
Maps to ratatui::layout::Constraint.
Examples:
rules = [SizeRule.cells(4), SizeRule.fill()]
parent = Buffer(width=12, height=3)
first, second = Buffer(), Buffer()
parent.attach(first, geometry='inherit')
parent.attach(second, geometry='inherit')
parent.update(Layout('row', sizes=rules))
assert (first.width, second.width) == (4, 8)
Methods:
-
cells–Take exactly
countcells. -
percent–Take
percentagepercent of the available space. -
fill–Share the remaining space with other fill rules in proportion to
weight. -
fit–Take the size of the child's own content.
-
minimum–Take at least
countcells. -
maximum–Take at most
countcells.
cells
classmethod
¶
Take exactly count cells.
Examples:
percent
classmethod
¶
Take percentage percent of the available space.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
fill
classmethod
¶
Share the remaining space with other fill rules in proportion to weight.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
minimum
classmethod
¶
Take at least count cells.
Examples:
maximum
classmethod
¶
Take at most count cells.
Examples: