Skip to content

Commit

Permalink
use sets
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Oct 31, 2024
1 parent afcc5c5 commit 9e7f363
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions rich/cells.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
from __future__ import annotations

import re
from functools import lru_cache
from typing import Callable

from ._cell_widths import CELL_WIDTHS

# Regex to match sequence of the most common character ranges
_is_single_cell_widths = re.compile(
"^[\u0020-\u007e\u00a0-\u02ff\u0370-\u0482\u2500-\u25FF]*$"
).match
_SINGLE_CELLS = frozenset(
[
*map(chr, range(0x20, 0x7E + 1)),
*map(chr, range(0xA0, 0x02FF + 1)),
*map(chr, range(0x0370, 0x0482 + 1)),
*map(chr, range(0x2500, 0x25FF + 1)),
]
)
_is_single_cell_widths = _SINGLE_CELLS.issuperset


@lru_cache(4096)
Expand Down

0 comments on commit 9e7f363

Please sign in to comment.