Kite

fmt

std/fmt — laying text out in columns.

There is no format-string language in Kite, and there is not going to be one: \(x) interpolation calls Display.show and has no injection surface and nothing to learn. What interpolation cannot do is align things, which is what this module is for.

pad

pub fn pad(s: str, width: int) -> str

s at least width characters wide, padded on the right.

pad_left

pub fn pad_left(s: str, width: int) -> str

s at least width characters wide, padded on the left.

centre

pub fn centre(s: str, width: int) -> str

s centred in width, with any odd space going to the right.

ellipsis

pub fn ellipsis(s: str, width: int) -> str

s cut to width, with an ellipsis when something was cut.

fixed

pub fn fixed(x: float, places: int) -> str

A float with exactly places digits after the point.

Rounds half away from zero, which is what most people mean, and does the work in integers so the result does not depend on how the host prints a float.

percent

pub fn percent(part: float, whole: float) -> str

A percentage, to one decimal place.

grouped

pub fn grouped(n: int) -> str

An integer with thousands separators.

row

pub fn row(cells: [str], widths: [int]) -> str

A row of columns, each padded to its width.