listpick 0.1.13.55__py3-none-any.whl → 0.1.13.56__py3-none-any.whl

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.
listpick/ui/footer_1.py DELETED
@@ -1,213 +0,0 @@
1
- """
2
- footer.py
3
- Lines to be displayed on the help screen.
4
-
5
- Author: GrimAndGreedy
6
- License: MIT
7
- """
8
-
9
- import curses
10
- import logging
11
-
12
- logger = logging.getLogger('picker_log')
13
-
14
- class Footer:
15
- def __init__(self, stdscr, colours_start, get_state_function):
16
- """
17
- stdscr: curses screen object
18
- colours_start: base colour pair index
19
- get_state_callback: function that returns a dict with all required data for rendering
20
- """
21
- self.stdscr = stdscr
22
- self.colours_start = colours_start
23
- self.get_state = get_state_function
24
- self.height = 0
25
-
26
- def draw(self, h, w):
27
- """
28
- Draw the footer. Must be implemented by subclasses.
29
- """
30
- raise NotImplementedError
31
-
32
- class StandardFooter(Footer):
33
- def __init__(self, stdscr, colours_start, get_state_function):
34
- """
35
- stdscr: curses screen object
36
- colours_start: base colour pair index
37
- get_state_callback: function that returns a dict with all required data for rendering
38
- """
39
- self.stdscr = stdscr
40
- self.colours_start = colours_start
41
- self.get_state = get_state_function
42
-
43
- self.height = 2
44
- try:
45
- state = self.get_state()
46
- if "footer_string" in state and state["footer_string"]: self.height = 3
47
- else: self.height = 2
48
- except:
49
- logger.error("Error encountered when running StandardFooter.get_state")
50
- def draw(self, h, w):
51
- state = self.get_state()
52
- # Fill background
53
- if "footer_string" in state and state["footer_string"]: self.height = 3
54
- else: self.height = 2
55
-
56
- for i in range(self.height):
57
- self.stdscr.addstr(h-self.height+i, 0, ' '*(w-1), curses.color_pair(self.colours_start+20))
58
-
59
- if state["footer_string"]:
60
- footer_string_width = min(w-1, len(state["footer_string"])+2)
61
-
62
- disp_string = f"{state["footer_string"][:footer_string_width]}"
63
- disp_string = f" {disp_string:>{footer_string_width-2}} "
64
- self.stdscr.addstr(h - 1, w-footer_string_width-1, " "*footer_string_width, curses.color_pair(self.colours_start+24))
65
- self.stdscr.addstr(h - 1, w-footer_string_width-1, f"{disp_string}", curses.color_pair(self.colours_start+24))
66
-
67
- picker_info_y = h-3
68
- sort_info_y = h-2
69
- else:
70
- picker_info_y = h-2
71
- sort_info_y = h-1
72
- select_mode = "C"
73
- if state["is_selecting"]: select_mode = "VS"
74
- elif state["is_deselecting"]: select_mode = "VDS"
75
- if state["pin_cursor"]: select_mode = f"{select_mode} "
76
- self.stdscr.addstr(h - 1, w-35, f"{select_mode:>33} ", curses.color_pair(self.colours_start+20))
77
-
78
- if state["filter_query"]:
79
- self.stdscr.addstr(h - 2, 2, f" Filter: {state['filter_query']} "[:w-40], curses.color_pair(self.colours_start+20) | curses.A_BOLD)
80
- if state["search_query"]:
81
- self.stdscr.addstr(h - 3, 2, f" Search: {state['search_query']} [{state['search_index']}/{state['search_count']}] "[:w-3], curses.color_pair(self.colours_start+20) | curses.A_BOLD)
82
- if state["user_opts"]:
83
- self.stdscr.addstr(h - 1, 2, f" Opts: {state['user_opts']} "[:w-3], curses.color_pair(self.colours_start+20) | curses.A_BOLD)
84
-
85
-
86
-
87
- select_mode = "C"
88
- if state["is_selecting"]: select_mode = "VS"
89
- elif state["is_deselecting"]: select_mode = "VDS"
90
- if state["pin_cursor"]: select_mode = f"{select_mode} "
91
- # Cursor & selection info
92
- selected_count = sum(state["selections"].values())
93
- if state["paginate"]:
94
- cursor_disp_str = f" [{selected_count}] {state['cursor_pos']+1}/{len(state['indexed_items'])} Page {state['cursor_pos']//state['items_per_page']}/{len(state['indexed_items'])}"
95
- else:
96
- cursor_disp_str = f" [{selected_count}] {state['cursor_pos']+1}/{len(state['indexed_items'])} | {select_mode}"
97
- self.stdscr.addstr(picker_info_y, w-35, f"{cursor_disp_str:>33} ", curses.color_pair(self.colours_start+20))
98
-
99
-
100
- # Sort info
101
- sort_column_info = f"{state['sort_column'] if state['sort_column'] is not None else 'None'}"
102
- sort_method_info = f"{state['SORT_METHODS'][state['columns_sort_method'][state['sort_column']]]}" if state['sort_column'] is not None else "NA"
103
- sort_order_info = "Desc." if state["sort_reverse"] else "Asc."
104
- sort_order_info = "▼" if state["sort_reverse"][state['sort_column']] else "▲"
105
- sort_disp_str = f" Sort: ({sort_column_info}, {sort_method_info}, {sort_order_info}) "
106
- self.stdscr.addstr(sort_info_y, w-35, f"{sort_disp_str:>34}", curses.color_pair(self.colours_start+20))
107
-
108
- # self.stdscr.refresh()
109
-
110
-
111
-
112
- class CompactFooter(Footer):
113
- def __init__(self, stdscr, colours_start, get_state_function):
114
- """
115
- stdscr: curses screen object
116
- colours_start: base colour pair index
117
- get_state_callback: function that returns a dict with all required data for rendering
118
- """
119
- self.stdscr = stdscr
120
- self.colours_start = colours_start
121
- self.get_state = get_state_function
122
- self.height = 1
123
-
124
- def draw(self, h, w):
125
- state = self.get_state()
126
-
127
- # Fill background
128
- if state["search_query"]: self.height = 3
129
- elif state["filter_query"]: self.height = 2
130
- elif state["user_opts"]: self.height = 1
131
- elif state["footer_string"]: self.height = 2
132
- else: self.height = 1
133
- for i in range(self.height):
134
- self.stdscr.addstr(h-(i+1), 0, ' '*(w-1), curses.color_pair(self.colours_start+20))
135
-
136
- if state["user_opts"]:
137
- self.stdscr.addstr(h - 1, 2, f" Opts: {state['user_opts']} "[:w-3], curses.color_pair(self.colours_start+20) | curses.A_BOLD)
138
- if state["filter_query"]:
139
- self.stdscr.addstr(h - 2, 2, f" Filter: {state['filter_query']} "[:w-40], curses.color_pair(self.colours_start+20) | curses.A_BOLD)
140
- if state["search_query"]:
141
- self.stdscr.addstr(h - 3, 2, f" Search: {state['search_query']} [{state['search_index']}/{state['search_count']}] "[:w-3], curses.color_pair(self.colours_start+20) | curses.A_BOLD)
142
-
143
- right_width = 40
144
- # Sort info
145
- sort_column_info = f"{state['sort_column'] if state['sort_column'] is not None else 'None'}"
146
- sort_method_info = f"{state['SORT_METHODS'][state['columns_sort_method'][state['sort_column']]]}" if state['sort_column'] is not None else "NA"
147
- sort_order_info = "Desc." if state["sort_reverse"][state['sort_column']] else "Asc."
148
- sort_order_info = "▼" if state["sort_reverse"][state['sort_column']] else "▲"
149
- sort_disp_str = f" ({sort_column_info}, {sort_method_info}, {sort_order_info}) "
150
- # self.stdscr.addstr(h - 2, w-right_width, f"{sort_disp_str:>{right_width-1}}", curses.color_pair(self.colours_start+20))
151
-
152
- if state["footer_string"]:
153
- footer_string_width = min(w-1, len(state["footer_string"])+2)
154
-
155
- disp_string = f"{state["footer_string"][:footer_string_width]}"
156
- disp_string = f" {disp_string:>{footer_string_width-2}} "
157
- self.stdscr.addstr(h - 1, w-footer_string_width-1, " "*footer_string_width, curses.color_pair(self.colours_start+24))
158
- self.stdscr.addstr(h - 1, w-footer_string_width-1, f"{disp_string}", curses.color_pair(self.colours_start+24))
159
- selected_count = sum(state["selections"].values())
160
- if state["paginate"]:
161
- cursor_disp_str = f" {state['cursor_pos']+1}/{len(state['indexed_items'])} Page {state['cursor_pos']//state['items_per_page']}/{len(state['indexed_items'])} Selected {selected_count}"
162
- else:
163
- cursor_disp_str = f"{sort_disp_str} [{selected_count}] {state['cursor_pos']+1}/{len(state['indexed_items'])}"
164
- self.stdscr.addstr(h-2, w-right_width, f"{cursor_disp_str:>{right_width-2}}"[:right_width-1], curses.color_pair(self.colours_start+20))
165
- else:
166
- # Cursor & selection info
167
- selected_count = sum(state["selections"].values())
168
- if state["paginate"]:
169
- cursor_disp_str = f" {state['cursor_pos']+1}/{len(state['indexed_items'])} Page {state['cursor_pos']//state['items_per_page']}/{len(state['indexed_items'])} Selected {selected_count}"
170
- else:
171
- cursor_disp_str = f"{sort_disp_str} [{selected_count}] {state['cursor_pos']+1}/{len(state['indexed_items'])}"
172
- self.stdscr.addstr(h - 1, w-right_width, f"{cursor_disp_str:>{right_width-2}}"[:right_width-1], curses.color_pair(self.colours_start+20))
173
-
174
- self.stdscr.refresh()
175
-
176
- class NoFooter(Footer):
177
- def __init__(self, stdscr, colours_start, get_state_function):
178
- """
179
- stdscr: curses screen object
180
- colours_start: base colour pair index
181
- get_state_callback: function that returns a dict with all required data for rendering
182
- """
183
- self.stdscr = stdscr
184
- self.colours_start = colours_start
185
- self.get_state = get_state_function
186
- self.height = 0
187
- def draw(self, h, w):
188
- state = self.get_state()
189
-
190
- if state["search_query"]: self.height = 3
191
- elif state["filter_query"]: self.height = 2
192
- elif state["user_opts"]: self.height = 1
193
- elif state["footer_string"]: self.height = 1
194
- else: self.height = 0
195
-
196
- for i in range(self.height):
197
- self.stdscr.addstr(h-(i+1), 0, ' '*(w-1), curses.color_pair(self.colours_start+20))
198
-
199
- if state["user_opts"]:
200
- self.stdscr.addstr(h - 1, 2, f" Opts: {state['user_opts']} "[:w-3], curses.color_pair(self.colours_start+20) | curses.A_BOLD)
201
- if state["filter_query"]:
202
- self.stdscr.addstr(h - 2, 2, f" Filter: {state['filter_query']} "[:w-40], curses.color_pair(self.colours_start+20) | curses.A_BOLD)
203
- if state["search_query"]:
204
- self.stdscr.addstr(h - 3, 2, f" Search: {state['search_query']} [{state['search_index']}/{state['search_count']}] "[:w-3], curses.color_pair(self.colours_start+20) | curses.A_BOLD)
205
- self.height = 3
206
-
207
-
208
- if state["footer_string"]:
209
- footer_string_width = min(w-1, len(state["footer_string"])+2)
210
- disp_string = f"{state["footer_string"][:footer_string_width]}"
211
- disp_string = f" {disp_string:>{footer_string_width-2}} "
212
- self.stdscr.addstr(h - 1, w-footer_string_width-1, " "*footer_string_width, curses.color_pair(self.colours_start+24))
213
- self.stdscr.addstr(h - 1, w-footer_string_width-1, f"{disp_string}", curses.color_pair(self.colours_start+24))