Example #1
0
 def get_style_at(self, x: int, y: int) -> Style:
     try:
         line = self.lines[y]
     except IndexError:
         return Style.null()
     end = 0
     for segment in line:
         end += cell_len(segment.text)
         if x < end:
             return segment.style or Style.null()
     return Style.null()
Example #2
0
def test_set_cell_size_infinite():
    for size in range(38):
        assert (cells.cell_len(
            cells.set_cell_size(
                "เป็นเกมที่ต้องมีความอดทนมากที่สุดตั้งเเต่เคยเล่นมา",
                size)) == size)
Example #3
0
def test_cell_len_single_ascii_char():
    assert cells.cell_len("a") == 1
Example #4
0
def test_cell_len_emoji_presentation_sequence():
    # Handled different from standard emoji - we vary from wcwidth here, which reports width 1.
    assert cells.cell_len("🏵️") == 2
Example #5
0
def test_cell_len_poop_emoji_has_width_2():
    assert cells.cell_len("💩") == 2
Example #6
0
def test_cell_len_empty_string():
    assert cells.cell_len("") == 0
Example #7
0
def test_cell_len_japanese_hiragana():
    assert cells.cell_len("こんにちは") == 10
Example #8
0
def test_cell_len_single_width_non_ascii_character():
    assert cells.cell_len("\u0370") == 1
Example #9
0
def test_cell_len_zero_width_character():
    assert cells.cell_len("\u0483") == 0
Example #10
0
def test_cell_len_ascii_string():
    assert cells.cell_len("hello") == len("hello")
Example #11
0
def test_cell_len_single_ascii_num():
    assert cells.cell_len("5") == 1
Example #12
0
 def cell_length(self):
     assert not self.control
     return cell_len(re.sub(ANSI_ESCAPE, "", self.text))