The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tickit::Utils - utility functions for Tickit

DESCRIPTION

This module provides a number of utility functions used across Tickit.

FUNCTIONS

$cols = textwidth( $str )

Returns the number of screen columns consumed by the given (Unicode) string.

@cols = chars2cols( $text, @chars )

Given a list of increasing character positions, returns a list of column widths of those characters. In scalar context returns the first columns width.

@chars = cols2chars( $text, @cols )

Given a list of increasing column widths, returns a list of character positions at those widths. In scalar context returns the first character position.

$substr = substrwidth $text, $startcol

$substr = substrwidth $text, $startcol, $widthcols

$substr = substrwidth $text, $startcol, $widthcols, $replacement

Similar to substr, but counts start offset and length in screen columns instead of characters

( $before, $alloc, $after ) = align( $value, $total, $alignment )

Returns a list of three integers created by aligning the $value to a position within the $total according to $alignment. The sum of the three returned values will always add to total.

If the value is not larger than the total then the returned allocation will be the entire value, and the remaining space will be divided between before and after according to the given fractional alignment, with more of the remainder being allocated to the $after position in proportion to the alignment.

If the value is larger than the total, then the total is returned as the allocation and the before and after positions will both be given zero.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>