Skip to content

Commit

Permalink
leaner syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Nov 1, 2024
1 parent 6cef0bc commit aaaef27
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions rich/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,14 @@
(0x02800, 0x028FF), # Braille
]


def _make_single_cell_set() -> frozenset[str]:
"""Combine ranges of ordinals in to a frozen set of strings.
Returns:
A frozenset of single cell characters.
"""
character_range_lists = [
list(map(chr, range(_start, _end + 1)))
# A set of characters that are a single cell wide
_SINGLE_CELLS = frozenset(
[
character
for _start, _end in _SINGLE_CELL_UNICODE_RANGES
for character in map(chr, range(_start, _end + 1))
]
return frozenset(sum(character_range_lists, start=[]))


# A set of characters that are a single cell wide
_SINGLE_CELLS = _make_single_cell_set()
)

# When called with a string this will return True if all
# characters are single-cell, otherwise False
Expand Down

0 comments on commit aaaef27

Please sign in to comment.