5 |
5 |
6 from tuikit.core.buffer import Buffer |
6 from tuikit.core.buffer import Buffer |
7 from tuikit.driver.curses import CursesDriver |
7 from tuikit.driver.curses import CursesDriver |
8 |
8 |
9 |
9 |
|
10 colors = ('blue', 'green', 'cyan', 'red', |
|
11 'magenta', 'brown', 'lightgray', 'gray', |
|
12 'lightblue', 'lightgreen', 'lightcyan', 'lightred', |
|
13 'lightmagenta', 'yellow', 'white') |
|
14 |
10 buffer = Buffer(16, 8) |
15 buffer = Buffer(16, 8) |
11 buffer.fill(c='#') |
16 buffer.fill(c='#') |
12 buffer.hline(1, 1, 14, c='-') |
17 buffer.hline(1, 1, 14, c='-') |
13 buffer.hline(1, 6, 14, c='-') |
18 buffer.hline(1, 6, 14, c='-') |
14 buffer.vline(7, 2, 4, c='|') |
19 buffer.vline(7, 2, 4, c='|') |
15 buffer.puts(8, 4, 'Hello!') |
20 buffer.puts(8, 4, 'Hello!') |
16 buffer.frame() |
21 buffer.frame() |
17 |
22 |
|
23 buffer2 = Buffer(30, 10) |
|
24 buffer2.setattr('white on black') |
|
25 buffer2.frame() |
|
26 |
|
27 for idx, color in enumerate(colors): |
|
28 buffer2.setattr(color) |
|
29 buffer2.puts(3 + 12 * (idx // 8), 1 + idx % 8, color) |
|
30 |
|
31 buffer3 = Buffer(30, 10) |
|
32 buffer3.setattr('white on black') |
|
33 buffer3.frame() |
|
34 |
|
35 for idx, color in enumerate(colors[:8]): |
|
36 buffer3.setattr('black on {}'.format(color)) |
|
37 buffer3.puts(2, 1 + idx, ' '+color.ljust(10)) |
|
38 buffer3.setattr('{}, underline, bold'.format(color)) |
|
39 buffer3.puts(15, 1 + idx, ' '+color.ljust(10)) |
|
40 |
|
41 buffer3.setattr('lightgray, blink') |
|
42 buffer3.puts(3, 8, 'blink') |
|
43 |
18 driver = CursesDriver() |
44 driver = CursesDriver() |
19 with driver: |
45 with driver: |
20 driver.draw(buffer) |
46 driver.draw(buffer) |
21 buffer.setattr('red on blue, bold') |
47 driver.draw(buffer2, 20, 00) |
22 buffer.puts(8, 4, 'Hello!') |
48 driver.draw(buffer3, 20, 10) |
23 driver.draw(buffer, 20, 10) |
|
24 driver.flush() |
49 driver.flush() |
25 driver.getevents() |
50 driver.getevents() |
26 |
|