File: tui.py

package info (click to toggle)
kitty 0.42.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 28,564 kB
  • sloc: ansic: 82,787; python: 55,191; objc: 5,122; sh: 1,295; xml: 364; makefile: 143; javascript: 78
file content (47 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>


from . import BaseTest


class TestTUI(BaseTest):

    def test_line_edit(self):
        from kittens.tui.line_edit import LineEdit
        le = LineEdit()
        le.on_text('abcd', False)
        self.ae(le.cursor_pos, 4)
        for i in range(5):
            self.assertTrue(le.left()) if i < 4 else self.assertFalse(le.left())
            self.ae(le.cursor_pos, max(0, 3 - i))
        self.ae(le.pending_bell, True)
        le.clear()
        le.on_text('abcd', False), le.home()
        self.ae(le.cursor_pos, 0)
        for i in range(5):
            self.assertTrue(le.right()) if i < 4 else self.assertFalse(le.right())
            self.ae(le.cursor_pos, min(4, i + 1))
        self.ae(le.pending_bell, True)
        le.clear()
        le.on_text('abcd', False)
        self.ae(le.current_input, 'abcd')
        self.ae(le.cursor_pos, 4)
        self.ae(le.split_at_cursor(), ('abcd', ''))
        le.backspace()
        self.ae(le.current_input, 'abc')
        self.ae(le.cursor_pos, 3)
        self.assertFalse(le.pending_bell)
        le.backspace(num=2)
        self.ae(le.current_input, 'a')
        self.ae(le.cursor_pos, 1)
        self.assertFalse(le.pending_bell)
        le.backspace(num=2)
        self.ae(le.current_input, '')
        self.ae(le.cursor_pos, 0)
        le.backspace()
        self.assertTrue(le.pending_bell)

    def test_multiprocessing_spawn(self):
        from kitty.multiprocessing import test_spawn
        test_spawn()