# Regex to match sequence of the most common character ranges
= .
"""Get the number of cells required to display text.
This method always caches, which may use up a lot of memory. It is recommended to use
`cell_len` over this method.
Args:
text (str): Text to display.
Returns:
int: Get the number of cells required to display text.
"""
=
=
return
"""Get the number of cells required to display text.
Args:
text (str): Text to display.
Returns:
int: Get the number of cells required to display text.
"""
return
=
=
return
"""Get the cell size of a character.
Args:
character (str): A single character.
Returns:
int: Number of cells (0, 1 or 2) occupied by that character.
"""
return
"""Get the cell size of a character.
Args:
codepoint (int): Codepoint of a character.
Returns:
int: Number of cells (0, 1 or 2) occupied by that character.
"""
=
= 0
= - 1
= // 2
, , =
= - 1
> :
= + 1
return 0
break
= // 2
return 1
"""Set the length of a string to fit within given number of cells."""
=
return + *
return
return
=
return
return + *
= 0
=
# Binary search until we find the right size
= // 2
=
=
return +
return
=
=
# TODO: This is inefficient
# TODO: This might not work with CWJ type characters
"""Break text in to equal (cell) length strings, returning the characters in reverse
order"""
=
=
=
: =
= .
= .
=
+=
return
# pragma: no cover