curses-utils2 0.4.1__tar.gz → 0.5.0__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.4.1
3
+ Version: 0.5.0
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.5.0'
@@ -131,7 +131,7 @@ class List3v2(WinProto):
131
131
  self.cur += 1
132
132
  else:
133
133
  self.win.move(0, 0)
134
- for i in range(self.height):
134
+ for _ in range(self.height):
135
135
  self.win.deleteln()
136
136
  self.cur = rows - 1
137
137
  self.addstr(self.cur, next_s, attr=self.current_color)
@@ -0,0 +1,57 @@
1
+ import curses
2
+
3
+ from .list3_v2 import List3v2, ListProto3
4
+
5
+
6
+ class List3mProto(ListProto3):
7
+ def record_move_up(self, i: int) -> bool: # type: ignore[empty-body]
8
+ pass
9
+
10
+ def record_move_down(self, i: int) -> bool: # type: ignore[empty-body]
11
+ pass
12
+
13
+
14
+ class List3m(List3v2):
15
+ 'List + move_up(), move_down()'
16
+
17
+ def __init__(
18
+ self,
19
+ proto: List3mProto,
20
+ **kwargs,
21
+ ):
22
+ super().__init__(proto, **kwargs)
23
+ self.proto: List3mProto = proto
24
+
25
+ def move_up(self, i: int):
26
+ if not self.proto.record_move_up(i):
27
+ return
28
+ if self.idx > 0:
29
+ self.idx -= 1
30
+ if self.cur > 0:
31
+ self.cur -= 1
32
+ self.refresh()
33
+
34
+ def move_down(self, i: int):
35
+ if not self.win:
36
+ return
37
+ if not self.proto.record_move_down(i):
38
+ return
39
+ len_ = self.proto.records_len()
40
+ rows, _ = self.win.getmaxyx()
41
+ rows //= self.height
42
+ if self.idx + 1 < len_:
43
+ self.idx += 1
44
+ if self.cur + 1 < rows:
45
+ self.cur += 1
46
+ self.refresh()
47
+
48
+ def handle_input(self, ch: int) -> bool:
49
+ if super().handle_input(ch):
50
+ return True
51
+ if ch == curses.KEY_SR: # Shift-Up
52
+ self.move_up(self.idx)
53
+ elif ch == curses.KEY_SF: # Shift-Down
54
+ self.move_down(self.idx)
55
+ else:
56
+ return False
57
+ return True
@@ -1 +0,0 @@
1
- __version__ = '0.4.1'
File without changes
File without changes