euporie.core.ft.table
Allow drawing tables as FormattedText
.
Functions
|
Align formatted text at a given width. |
|
Compute the final width of a cell, including padding. |
|
Calculate column widths given the available space. |
|
Cast a value to a type. |
|
Compute the alignment of a cell. |
|
Compute a cell's border line. |
|
Compute the cell's final style for each of a cell's borders. |
|
Compute a cell's border visibility. |
|
Compute the width of a cell's borders. |
|
Wrap the cell's text to a given width. |
|
Compute a cell's padding. |
|
Compute a cell's style string. |
|
Compute a cell's input, converted to |
|
Return the character width of this text fragment list. |
|
Return the character represented by a combination of |
|
Calculate which character to use to divide horizontally adjacent cells. |
|
Calculate which character to use at the intersection of four cells. |
|
Calculate which character to use to divide vertically adjacent cells. |
|
Join a list of lines of formatted text. |
|
Least-recently-used cache decorator. |
|
Calculate the length of the longest line in formatted text. |
|
Return successiver overlapping pairs from an iterable. |
|
Take a single list of (style_str, text) tuples and yield one such list for each line. |
|
Returns a tuple of n independent iterators. |
|
Turn the given object into a Dimension object. |
|
Convert the given value (which can be formatted text) into a list of text fragments. |
|
Turn any kind of formatted text back into plain text. |
|
Wrap formatted text at a given width. |
Classes
|
A table cell. |
|
A column in a table. |
|
A tuple of four bools with directions. |
|
A tuple of four integers with directions. |
|
A description of a cell border: a |
|
A tuple of four strings with directions. |
|
Specified dimension (width/height) of a user control or window. |
|
A dummy column - created to hold cells without an assigned column. |
|
A dummy row - created to hold cells without an assigned column. |
|
A dummy table - created to hold rows and columns without an assigned table. |
|
Alignment of formatted text. |
|
Repreentation of a grid node character. |
|
Define a line style which can be used to draw grids. |
|
A row in a table. |
|
Base class for table rows and columns. |
|
A dummy cell to virtually occupy space when |
|
A table. |
defaultdict(default_factory=None, /, [...]) --> dict with default factory |
|
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
|
zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) --> zip_longest object |
- class euporie.core.ft.table.Cell(text: AnyFormattedText = '', row: Row | None = None, col: Col | None = None, colspan: int = 1, rowspan: int = 1, width: int | None = None, align: FormattedTextAlign | None = None, style: str = '', padding: DiInt | int = 0, border_line: DiLineStyle | LineStyle = LineStyle(Thin), border_style: DiStr | str = '', border_visibility: DiBool | bool | None = True)
Bases:
object
A table cell.
- property border_line: DiLineStyle
The cell’s border line.
- class euporie.core.ft.table.Col(table: Table | None = None, cells: Sequence[Cell] | None = None, align: FormattedTextAlign | None = None, style: str = '', padding: DiInt | int = 0, border_line: DiLineStyle | LineStyle = LineStyle(None), border_style: DiStr | str = '', border_visibility: DiBool | bool | None = None)
Bases:
RowCol
A column in a table.
- property border_line: DiLineStyle
The cell’s border line.
- property cells: list[euporie.core.ft.table.Cell]
List the cells in the row/column.
- class euporie.core.ft.table.DummyCol(table: Table | None = None, cells: Sequence[Cell] | None = None, align: FormattedTextAlign | None = None, style: str = '', padding: DiInt | int = 0, border_line: DiLineStyle | LineStyle = LineStyle(None), border_style: DiStr | str = '', border_visibility: DiBool | bool | None = None)
Bases:
Col
A dummy column - created to hold cells without an assigned column.
- property border_line: DiLineStyle
The cell’s border line.
- property cells: list[euporie.core.ft.table.Cell]
List the cells in the row/column.
- class euporie.core.ft.table.DummyRow(table: Table | None = None, cells: Sequence[Cell] | None = None, align: FormattedTextAlign | None = None, style: str = '', padding: DiInt | int = 0, border_line: DiLineStyle | LineStyle = LineStyle(None), border_style: DiStr | str = '', border_visibility: DiBool | bool | None = None)
Bases:
Row
A dummy row - created to hold cells without an assigned column.
- property border_line: DiLineStyle
The cell’s border line.
- property cells: list[euporie.core.ft.table.Cell]
List the cells in the row/column.
- class euporie.core.ft.table.DummyTable(*args: Any, **kwargs: Any)
Bases:
Table
A dummy table - created to hold rows and columns without an assigned table.
- property border_line: DiLineStyle
The cell’s border line.
- calculate_cell_widths(width: AnyDimension | None = None) dict[Cell, int]
Calculate widths for each table cell, taking colspans into account.
- calculate_col_widths(width: AnyDimension | None = None, min_col_width: int = 4) list[int]
Calculate the table’s column widths.
- property cols: list[euporie.core.ft.table.Col]
A list of columns in the table.
- draw_table_row(row_above: RowCol | None, row_below: RowCol | None, cell_widths: dict[Cell, int], col_widths: list[int], row_edge_visibility: bool, col_edge_visibilities: dict[int, bool]) Iterable[StyleAndTextTuples]
Draw a row in the table.
- render(width: AnyDimension | None = None) StyleAndTextTuples
Draw the table, optionally at a given character width.
- property rows: list[euporie.core.ft.table.Row]
A list of rows in the table.
- class euporie.core.ft.table.Row(table: Table | None = None, cells: Sequence[Cell] | None = None, align: FormattedTextAlign | None = None, style: str = '', padding: DiInt | int = 0, border_line: DiLineStyle | LineStyle = LineStyle(None), border_style: DiStr | str = '', border_visibility: DiBool | bool | None = None)
Bases:
RowCol
A row in a table.
- property border_line: DiLineStyle
The cell’s border line.
- property cells: list[euporie.core.ft.table.Cell]
List the cells in the row/column.
- class euporie.core.ft.table.RowCol(table: Table | None = None, cells: Sequence[Cell] | None = None, align: FormattedTextAlign | None = None, style: str = '', padding: DiInt | int = 0, border_line: DiLineStyle | LineStyle = LineStyle(None), border_style: DiStr | str = '', border_visibility: DiBool | bool | None = None)
Bases:
object
Base class for table rows and columns.
- property border_line: DiLineStyle
The cell’s border line.
- property cells: list[euporie.core.ft.table.Cell]
List the cells in the row/column.
- class euporie.core.ft.table.SpacerCell(expands: Cell, span_row_index: int, span_col_index: int, text: AnyFormattedText = '', row: Row | None = None, col: Col | None = None, colspan: int = 1, rowspan: int = 1, width: int | None = None, align: FormattedTextAlign | None = None, style: str = '', padding: DiInt | int | None = None, border_line: DiLineStyle | LineStyle = LineStyle(None), border_style: DiStr | str = '', border_visibility: DiBool | bool | None = None)
Bases:
Cell
A dummy cell to virtually occupy space when
colspan
orrowspan
are used.- property border_line: DiLineStyle
The cell’s border line.
- class euporie.core.ft.table.Table(rows: Sequence[Row] | None = None, cols: Sequence[Col] | None = None, width: AnyDimension | None = None, expand: bool = False, align: FormattedTextAlign = FormattedTextAlign.LEFT, style: str = '', padding: DiInt | int | None = None, border_line: DiLineStyle | LineStyle = LineStyle(None), border_style: DiStr | str = '', border_visibility: DiBool | bool = False, background_style: str = '')
Bases:
object
A table.
- property border_line: DiLineStyle
The cell’s border line.
- calculate_cell_widths(width: AnyDimension | None = None) dict[Cell, int]
Calculate widths for each table cell, taking colspans into account.
- calculate_col_widths(width: AnyDimension | None = None, min_col_width: int = 4) list[int]
Calculate the table’s column widths.
- property cols: list[euporie.core.ft.table.Col]
A list of columns in the table.
- draw_table_row(row_above: RowCol | None, row_below: RowCol | None, cell_widths: dict[Cell, int], col_widths: list[int], row_edge_visibility: bool, col_edge_visibilities: dict[int, bool]) Iterable[StyleAndTextTuples]
Draw a row in the table.
- render(width: AnyDimension | None = None) StyleAndTextTuples
Draw the table, optionally at a given character width.
- property rows: list[euporie.core.ft.table.Row]
A list of rows in the table.
- euporie.core.ft.table.calculate_cell_width(cell: Cell, render_count: int = 0) int
Compute the final width of a cell, including padding.
- euporie.core.ft.table.calculate_col_widths(cols: tuple[euporie.core.ft.table.Col], width: Dimension, expand_to_width: bool, min_col_width: int = 2, render_count: int = 0) list[int]
Calculate column widths given the available space.
Reduce the widest column until we fit in available width, or expand cells to to fill the available width.
- Parameters:
cols – A list of columns in the table
width – The desired width of the table
expand_to_width – Whether the column should expand to fill the available width
min_col_width – The minimum width allowed for a column
render_count – The number of times the app has been rendered
- Returns:
List of new column widths
- euporie.core.ft.table.compute_align(cell: Cell, render_count: int = 0) FormattedTextAlign
Compute the alignment of a cell.
- euporie.core.ft.table.compute_border_line(cell: Cell, render_count: int = 0) DiLineStyle
Compute a cell’s border line.
- euporie.core.ft.table.compute_border_style(cell: Cell, render_count: int = 0) DiStr
Compute the cell’s final style for each of a cell’s borders.
- euporie.core.ft.table.compute_border_visibility(cell: Cell, render_count: int = 0) DiBool
Compute a cell’s border visibility.
- euporie.core.ft.table.compute_border_width(cell: Cell, render_count: int = 0) DiInt
Compute the width of a cell’s borders.
- euporie.core.ft.table.compute_lines(cell: Cell, width: int, render_count: int = 0) list[StyleAndTextTuples]
Wrap the cell’s text to a given width.
- Parameters:
cell – The cell whose lines to compute
width – The width at which to wrap the cell’s text.
render_count – The number of times the application has been rendered
- Returns:
A list of lines of formatted text
- euporie.core.ft.table.compute_padding(cell: Cell, render_count: int = 0) DiInt
Compute a cell’s padding.
- euporie.core.ft.table.compute_style(cell: Cell, render_count: int = 0) str
Compute a cell’s style string.
- euporie.core.ft.table.compute_text(cell: Cell, render_count: int = 0) StyleAndTextTuples
Compute a cell’s input, converted to
FormattedText
.
- euporie.core.ft.table.get_horizontal_edge(n_bl: DiLineStyle, s_bl: DiLineStyle) str
Calculate which character to use to divide horizontally adjacent cells.
- euporie.core.ft.table.get_node(nw_bl: DiLineStyle, ne_bl: DiLineStyle, se_bl: DiLineStyle, sw_bl: DiLineStyle) str
Calculate which character to use at the intersection of four cells.
- euporie.core.ft.table.get_vertical_edge(w_bl: DiLineStyle, e_bl: DiLineStyle) str
Calculate which character to use to divide vertically adjacent cells.