curses-utils2 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: curses-utils2
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: A curses utils
5
5
  Project-URL: homepage, https://github.com/shamilbi/curses-utils2
6
6
  Author-email: Shamil Bikineyev <shamilbi@gmail.com>
@@ -0,0 +1 @@
1
+ __version__ = '0.3.2'
@@ -0,0 +1,47 @@
1
+ import curses
2
+ from typing import Protocol
3
+
4
+ from curses_utils2.win import win_addstr
5
+
6
+
7
+ class WinProto(Protocol):
8
+ def set_win(self, win: curses.window):
9
+ pass
10
+
11
+ def refresh(self):
12
+ pass
13
+
14
+
15
+ class ListBox:
16
+ '''
17
+ win (box + header) + win (List)
18
+
19
+ -----------------------------
20
+ | header |
21
+ | List |
22
+ | |
23
+ -----------------------------
24
+
25
+ '''
26
+
27
+ def __init__(self, list_: WinProto, header: int = 0):
28
+ self.list_ = list_
29
+ self.header = header
30
+
31
+ def set_win(self, win: curses.window):
32
+ # pylint: disable=attribute-defined-outside-init
33
+ self.win = win
34
+
35
+ # list win
36
+ rows, cols = win.getmaxyx()
37
+ win2 = win.derwin(rows - 2 - self.header, cols - 4, 1 + self.header, 2)
38
+ self.list_.set_win(win2)
39
+
40
+ def refresh(self, header: str = ''):
41
+ self.win.erase()
42
+ if self.header:
43
+ win_addstr(self.win, 1, 2, header)
44
+ self.win.box()
45
+ self.win.refresh()
46
+
47
+ self.list_.refresh()
@@ -1 +0,0 @@
1
- __version__ = '0.3.0'
File without changes
File without changes