listpick 0.1.14.2__py3-none-any.whl → 0.1.14.3__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/listpick_app.py CHANGED
@@ -716,6 +716,9 @@ class Picker:
716
716
  self.stdscr.erase()
717
717
 
718
718
  h, w = self.stdscr.getmaxyx()
719
+ # The height of the footer may need to be adjusted if the file changes.
720
+ self.footer.adjust_sizes(h,w)
721
+ self.calculate_section_sizes()
719
722
 
720
723
  # Test if the terminal is of a sufficient size to display the picker
721
724
  if not self.test_screen_size(): return None
@@ -742,7 +745,7 @@ class Picker:
742
745
  visible_columns_total_width = sum(visible_column_widths) + len(self.separator)*(len(visible_column_widths)-1)
743
746
 
744
747
  # Determine the number of items_per_page, top_size and bottom_size
745
- self.calculate_section_sizes()
748
+ # self.calculate_section_sizes()
746
749
 
747
750
  # top_space = self.top_gap
748
751
 
@@ -1225,6 +1228,9 @@ class Picker:
1225
1228
  "top_gap",
1226
1229
  "unicode_char_width",
1227
1230
  "show_row_header",
1231
+ "centre_in_terminal_vertical",
1232
+ "centre_in_cols",
1233
+ "centre_in_terminal",
1228
1234
  ]
1229
1235
 
1230
1236
  for var in variables:
@@ -1430,20 +1436,26 @@ class Picker:
1430
1436
  self.auto_refresh = not self.auto_refresh
1431
1437
  elif setting[1] == "h":
1432
1438
  self.highlights_hide = not self.highlights_hide
1439
+ elif setting.isnumeric():
1440
+ self.cursor_pos = max(0, min(int(setting), len(self.indexed_items)-1))
1441
+ elif setting.startswith("col") and setting[3:].isnumeric():
1442
+ col = int(setting[3:])
1443
+ if 0 <= col < len(self.column_widths):
1444
+ self.selected_column = col
1433
1445
 
1434
1446
  elif setting in ["nhl", "nohl", "nohighlights"]:
1435
1447
  # highlights = [highlight for highlight in highlights if "type" not in highlight or highlight["type"] != "search" ]
1436
1448
 
1437
1449
  self.highlights_hide = not self.highlights_hide
1438
- # elif setting[0] == "s":
1439
- # if 0 <= int(setting[1:]) < len(self.items[0]):
1440
- # self.sort_column = int(setting[1:])
1441
- # if len(self.indexed_items):
1442
- # current_pos = self.indexed_items[self.cursor_pos][0]
1443
- # sort_items(self.indexed_items, sort_method=self.columns_sort_method[self.sort_column], sort_column=self.sort_column, sort_reverse=self.sort_reverse[self.sort_column]) # Re-sort items based on new column
1444
- # if len(self.indexed_items):
1445
- # new_pos = [row[0] for row in self.indexed_items].index(current_pos)
1446
- # self.cursor_pos = new_pos
1450
+ elif setting.startswith("s") and setting[1:].isnumeric():
1451
+ if 0 <= int(setting[1:]) < len(self.items[0]):
1452
+ self.sort_column = int(setting[1:])
1453
+ if len(self.indexed_items):
1454
+ current_pos = self.indexed_items[self.cursor_pos][0]
1455
+ sort_items(self.indexed_items, sort_method=self.columns_sort_method[self.sort_column], sort_column=self.sort_column, sort_reverse=self.sort_reverse[self.sort_column]) # Re-sort items based on new column
1456
+ if len(self.indexed_items):
1457
+ new_pos = [row[0] for row in self.indexed_items].index(current_pos)
1458
+ self.cursor_pos = new_pos
1447
1459
  elif setting == "ct":
1448
1460
  self.centre_in_terminal = not self.centre_in_terminal
1449
1461
  elif setting == "cc":
@@ -1494,6 +1506,8 @@ class Picker:
1494
1506
  elif setting == "file_prev":
1495
1507
  self.command_stack.append(Command("setting", self.user_settings))
1496
1508
  self.switch_file(increment=-1)
1509
+ # self.draw_screen(self.indexed_items, self.highlights)
1510
+ # self.stdscr.refresh()
1497
1511
 
1498
1512
  elif setting == "sheet_next":
1499
1513
  self.command_stack.append(Command("setting", self.user_settings))
@@ -1504,7 +1518,6 @@ class Picker:
1504
1518
 
1505
1519
  elif setting.startswith("ft"):
1506
1520
  if len(setting) > 2 and setting[2:].isnumeric():
1507
-
1508
1521
  num = int(setting[2:])
1509
1522
  self.footer_style = max(len(self.footer_options)-1, num)
1510
1523
  self.footer = self.footer_options[self.footer_style]
@@ -2254,12 +2267,12 @@ class Picker:
2254
2267
  version = metadata.version('listpick')
2255
2268
 
2256
2269
  info_items = [
2257
- [" Listpick info:", "-*"*30],
2270
+ [" Listpick info", "-*"*30],
2258
2271
  ["",""],
2259
2272
  ["listpick version", f"{version}"],
2260
2273
 
2261
2274
  ["",""],
2262
- [" Global:", "-*"*30],
2275
+ [" Global", "-*"*30],
2263
2276
  ["",""],
2264
2277
  ["current_file", self.loaded_file],
2265
2278
  ["loaded_files", repr(self.loaded_files)],
@@ -2272,11 +2285,12 @@ class Picker:
2272
2285
  ["debug level", f"{repr(self.debug_level)}"],
2273
2286
 
2274
2287
  ["",""],
2275
- [" Current File:", "-*"*30],
2288
+ [" Current File", "-*"*30],
2276
2289
  ["",""],
2277
- ["row/row count", f"{self.cursor_pos}/{len(self.indexed_items)}"],
2278
- ["total rows", f"{len(self.items)}"],
2279
- ["selections", f"{self.selected_cells_by_row}"],
2290
+ # ["row/row count", f"{self.cursor_pos}/{len(self.indexed_items)}"],
2291
+ ["Current row", f"{self.cursor_pos}/{len(self.indexed_items)}"],
2292
+ ["Total rows", f"{len(self.items)}"],
2293
+ ["Selection count", f"{self.selected_cells_by_row}"],
2280
2294
  ["current_sheet", self.sheet_name],
2281
2295
  ["sheets", repr(self.sheets)],
2282
2296
  ["current column/column_count", f"{self.selected_column}/{len(self.column_widths)}"],
@@ -2287,7 +2301,7 @@ class Picker:
2287
2301
  ["id_column", f"{self.id_column}"],
2288
2302
 
2289
2303
  ["",""],
2290
- [" Display options:", "-*"*30],
2304
+ [" Display options", "-*"*30],
2291
2305
  ["",""],
2292
2306
  ["show_header", str(self.show_header)],
2293
2307
  ["show_footer", repr(self.show_footer)],
@@ -2319,11 +2333,18 @@ class Picker:
2319
2333
  data["sheet_states"] = f"[...] length = {len(data['sheet_states'])}"
2320
2334
  info_items += [
2321
2335
  ["",""],
2322
- [" get_function_data():", "-*"*30],
2336
+ [" get_function_data()", "-*"*30],
2323
2337
  ["",""],
2324
2338
  ["show_header", str(self.show_header)],
2325
2339
  ]
2326
2340
  info_items += [[key, repr(value)] for key, value in data.items()]
2341
+
2342
+
2343
+ for row in info_items:
2344
+ if row[1] == "-*"*30:
2345
+ continue
2346
+ row[0] = " " + row[0]
2347
+
2327
2348
  info_header = ["Option", "Value"]
2328
2349
  info_data = {
2329
2350
  "items": info_items,
@@ -2427,12 +2448,13 @@ class Picker:
2427
2448
  options += [["sheet_next", "Go to the next sheet."]]
2428
2449
  options += [["sheet_prev", "Go to the previous sheet."]]
2429
2450
  options += [["unicode", "Toggle b/w using len and wcwidth to calculate char width."]]
2430
- options += [[f"s{i}", f"Select col. {i}"] for i in range(len(self.items[0]))]
2431
- options += [[f"!{i}", f"Toggle col. {i}"] for i in range(len(self.items[0]))]
2432
2451
  options += [["ara", "Add empty row after cursor."]]
2433
2452
  options += [["arb", "Add empty row before the cursor."]]
2434
2453
  options += [["aca", "Add empty column after the selected column."]]
2435
2454
  options += [["acb", "Add empty column before the selected column."]]
2455
+ options += [[f"col{i}", f"Select column {i}"] for i in range(len(self.items[0]))]
2456
+ options += [[f"s{i}", f"Sort by column {i}"] for i in range(len(self.items[0]))]
2457
+ options += [[f"!{i}", f"Toggle visibility of column {i}"] for i in range(len(self.items[0]))]
2436
2458
 
2437
2459
 
2438
2460
  settings_options_header = ["Key", "Setting"]
listpick/ui/footer.py CHANGED
@@ -47,42 +47,51 @@ class StandardFooter(Footer):
47
47
  else: self.height = 2
48
48
  except:
49
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
50
 
51
+ self.footer_string_y = 0
52
+ self.picker_info_y = 1
53
+ self.sort_info_y = 2
54
+ self.sheets_y = 3
55
+ self.files_y = 4
56
+ def adjust_sizes(self, h, w):
57
+ state = self.get_state()
54
58
 
55
- sheets_y=-1
59
+ self.sheets_y=-1
56
60
  if state["footer_string"]:
57
-
58
-
59
- footer_string_y = h-1
60
- picker_info_y = h-3
61
- sort_info_y = h-2
61
+ self.footer_string_y = h-1
62
+ self.picker_info_y = h-3
63
+ self.sort_info_y = h-2
62
64
 
63
65
  self.height = 3
64
66
 
65
67
  else:
66
- picker_info_y = h-2
67
- sort_info_y = h-1
68
- footer_string_y = -1
68
+ self.picker_info_y = h-2
69
+ self.sort_info_y = h-1
70
+ self.footer_string_y = -1
69
71
  self.height = 2
70
72
 
71
73
  if len(state["sheets"]) > 1:
72
74
  self.height += 1
73
- picker_info_y -= 1
74
- sort_info_y -= 1
75
- footer_string_y -= 1
76
- sheets_y = h-1
75
+ self.picker_info_y -= 1
76
+ self.sort_info_y -= 1
77
+ self.footer_string_y -= 1
78
+ self.sheets_y = h-1
77
79
 
78
80
  if len(state["loaded_files"]) > 1 and state["loaded_file"] in state["loaded_files"]:
79
81
  self.height += 1
80
- picker_info_y -= 1
81
- sort_info_y -= 1
82
- footer_string_y -= 1
83
- sheets_y -= 1
82
+ self.picker_info_y -= 1
83
+ self.sort_info_y -= 1
84
+ self.footer_string_y -= 1
85
+ self.sheets_y -= 1
86
+
87
+ self.files_y = h-1
88
+
89
+ def draw(self, h, w):
90
+ state = self.get_state()
91
+ # Fill background
92
+
93
+ self.adjust_sizes(h, w)
84
94
 
85
- files_y = h-1
86
95
 
87
96
 
88
97
  for i in range(self.height):
@@ -101,18 +110,18 @@ class StandardFooter(Footer):
101
110
  current_file_x = sum((len(x) for x in files[:idx])) + idx*len(sep)
102
111
  current_file_str = state["loaded_file"].split("/")[-1]
103
112
  current_file_x_end = current_file_x + len(current_file_str) + 2
104
- self.stdscr.addstr(files_y, 0, ' '*(w-1), curses.color_pair(self.colours_start+4))
113
+ self.stdscr.addstr(self.files_y, 0, ' '*(w-1), curses.color_pair(self.colours_start+4))
105
114
  if current_file_x_end < w:
106
115
 
107
- self.stdscr.addstr(files_y, 0, f" {files_str}", curses.color_pair(self.colours_start+4))
116
+ self.stdscr.addstr(self.files_y, 0, f" {files_str}", curses.color_pair(self.colours_start+4))
108
117
 
109
- self.stdscr.addstr(files_y, current_file_x, f" {current_file_str}{sep[0]}", curses.color_pair(self.colours_start+4) | curses.A_REVERSE)
118
+ self.stdscr.addstr(self.files_y, current_file_x, f" {current_file_str}{sep[0]}", curses.color_pair(self.colours_start+4) | curses.A_REVERSE)
110
119
  else:
111
120
  files_str = sep.join(files)
112
121
  files_str = files_str[current_file_x_end-w:current_file_x_end][:w-2]
113
- self.stdscr.addstr(files_y, 0, f" {files_str}", curses.color_pair(self.colours_start+4))
122
+ self.stdscr.addstr(self.files_y, 0, f" {files_str}", curses.color_pair(self.colours_start+4))
114
123
 
115
- self.stdscr.addstr(files_y, w - (len(current_file_str)+3), f" {current_file_str}{sep[0]}", curses.color_pair(self.colours_start+4) | curses.A_REVERSE)
124
+ self.stdscr.addstr(self.files_y, w - (len(current_file_str)+3), f" {current_file_str}{sep[0]}", curses.color_pair(self.colours_start+4) | curses.A_REVERSE)
116
125
 
117
126
  if len(state["sheets"]) > 1:
118
127
 
@@ -127,18 +136,18 @@ class StandardFooter(Footer):
127
136
  current_sheet_x = sum((len(x) for x in sheets[:idx])) + idx*len(sep)
128
137
  current_sheet_str = state["sheet_name"].split("/")[-1]
129
138
  current_sheet_x_end = current_sheet_x + len(current_sheet_str) + 2
130
- self.stdscr.addstr(sheets_y, 0, ' '*(w-1), curses.color_pair(self.colours_start+4))
139
+ self.stdscr.addstr(self.sheets_y, 0, ' '*(w-1), curses.color_pair(self.colours_start+4))
131
140
  if current_sheet_x_end < w:
132
141
 
133
- self.stdscr.addstr(sheets_y, 0, f" {sheets_str}", curses.color_pair(self.colours_start+4))
142
+ self.stdscr.addstr(self.sheets_y, 0, f" {sheets_str}", curses.color_pair(self.colours_start+4))
134
143
 
135
- self.stdscr.addstr(sheets_y, current_sheet_x, f" {current_sheet_str}{sep[0]}", curses.color_pair(self.colours_start+4) | curses.A_REVERSE)
144
+ self.stdscr.addstr(self.sheets_y, current_sheet_x, f" {current_sheet_str}{sep[0]}", curses.color_pair(self.colours_start+4) | curses.A_REVERSE)
136
145
  else:
137
146
  sheets_str = sep.join(sheets)
138
147
  sheets_str = sheets_str[current_sheet_x_end-w:current_sheet_x_end][:w-2]
139
- self.stdscr.addstr(sheets_y, 0, f" {sheets_str}", curses.color_pair(self.colours_start+4))
148
+ self.stdscr.addstr(self.sheets_y, 0, f" {sheets_str}", curses.color_pair(self.colours_start+4))
140
149
 
141
- self.stdscr.addstr(sheets_y, w - (len(current_sheet_str)+3), f" {current_sheet_str}{sep[0]}", curses.color_pair(self.colours_start+4) | curses.A_REVERSE)
150
+ self.stdscr.addstr(self.sheets_y, w - (len(current_sheet_str)+3), f" {current_sheet_str}{sep[0]}", curses.color_pair(self.colours_start+4) | curses.A_REVERSE)
142
151
 
143
152
 
144
153
 
@@ -148,8 +157,8 @@ class StandardFooter(Footer):
148
157
 
149
158
  disp_string = f"{state["footer_string"][:footer_string_width]}"
150
159
  disp_string = f" {disp_string:>{footer_string_width-2}} "
151
- self.stdscr.addstr(footer_string_y, w-footer_string_width-1, " "*footer_string_width, curses.color_pair(self.colours_start+24))
152
- self.stdscr.addstr(footer_string_y, w-footer_string_width-1, f"{disp_string}", curses.color_pair(self.colours_start+24))
160
+ self.stdscr.addstr(self.footer_string_y, w-footer_string_width-1, " "*footer_string_width, curses.color_pair(self.colours_start+24))
161
+ self.stdscr.addstr(self.footer_string_y, w-footer_string_width-1, f"{disp_string}", curses.color_pair(self.colours_start+24))
153
162
 
154
163
 
155
164
 
@@ -177,7 +186,7 @@ class StandardFooter(Footer):
177
186
 
178
187
  # Maximum chars that should be displayed
179
188
  max_chars = min(len(cursor_disp_str)+2, w)
180
- self.stdscr.addstr(picker_info_y, w-max_chars, f"{cursor_disp_str:>{max_chars-2}} ", curses.color_pair(self.colours_start+20))
189
+ self.stdscr.addstr(self.picker_info_y, w-max_chars, f"{cursor_disp_str:>{max_chars-2}} ", curses.color_pair(self.colours_start+20))
181
190
 
182
191
 
183
192
  # Sort info
@@ -187,7 +196,7 @@ class StandardFooter(Footer):
187
196
  sort_order_info = "▼" if state["sort_reverse"][state['sort_column']] else "▲"
188
197
  sort_disp_str = f" Sort: ({sort_column_info}, {sort_method_info}, {sort_order_info}) "
189
198
  max_chars = min(len(sort_disp_str)+2, w)
190
- self.stdscr.addstr(sort_info_y, w-max_chars, f"{sort_disp_str:>{max_chars-1}}", curses.color_pair(self.colours_start+20))
199
+ self.stdscr.addstr(self.sort_info_y, w-max_chars, f"{sort_disp_str:>{max_chars-1}}", curses.color_pair(self.colours_start+20))
191
200
 
192
201
  self.stdscr.refresh()
193
202
 
@@ -205,6 +214,9 @@ class CompactFooter(Footer):
205
214
  self.get_state = get_state_function
206
215
  self.height = 1
207
216
 
217
+ def adjust_sizes(self, h, w):
218
+ pass
219
+
208
220
  def draw(self, h, w):
209
221
  state = self.get_state()
210
222
 
@@ -268,6 +280,10 @@ class NoFooter(Footer):
268
280
  self.colours_start = colours_start
269
281
  self.get_state = get_state_function
270
282
  self.height = 0
283
+
284
+ def adjust_sizes(self, h, w):
285
+ pass
286
+
271
287
  def draw(self, h, w):
272
288
  state = self.get_state()
273
289
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: listpick
3
- Version: 0.1.14.2
3
+ Version: 0.1.14.3
4
4
  Summary: Listpick is a powerful TUI data tool for creating TUI apps or viewing/comparing tabulated data.
5
5
  Home-page: https://github.com/grimandgreedy/listpick
6
6
  Author: Grim
@@ -1,9 +1,9 @@
1
1
  listpick/__init__.py,sha256=ExXc97-bibodH--wlwpQivl0zCNR5D1hvpvrf7OBofU,154
2
2
  listpick/__main__.py,sha256=wkCjDdqw093W27yWwnlC3nG_sMRKaIad7hHHWy0RBgY,193
3
- listpick/listpick_app.py,sha256=lnMa_G6HAWP8hHVhlOiBDvRc7Y38oqTM88ijhtVrlfU,182457
3
+ listpick/listpick_app.py,sha256=APXKgeGp2bDDyXaFUr7HmswokpO6H6g8xt9KdMhM5jc,183558
4
4
  listpick/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  listpick/ui/build_help.py,sha256=8QtsRosIE2IMagRc_remzmwSWpCurFgLenLL7w1ly94,8949
6
- listpick/ui/footer.py,sha256=85sVZ6zvzZXSc0TwgvCHGuzGElp6KwUVzwzF5VQwLyY,14219
6
+ listpick/ui/footer.py,sha256=eaGCJlUMuOyoVfBxbqDFBxF7b3w_FMUuzFO1_xWz7xY,14702
7
7
  listpick/ui/help_screen.py,sha256=zbfGIgb-IXtATpl4_Sx7nPbsnRXZ7eiMYlCKGS9EFmw,5608
8
8
  listpick/ui/input_field.py,sha256=eyoWHoApdZybjfXcp7Eth7xwb-C-856ZVnq5j_Q3Ojs,30412
9
9
  listpick/ui/keys.py,sha256=944-no3lspUzC3oWt96Q_mY33fIrKOharXPskAMou2I,13162
@@ -23,9 +23,9 @@ listpick/utils/searching.py,sha256=Xk5UIqamNHL2L90z3ACB_Giqdpi9iRKoAJ6pKaqaD7Q,3
23
23
  listpick/utils/sorting.py,sha256=WZZiVlVA3Zkcpwji3U5SNFlQ14zVEk3cZJtQirBkecQ,5329
24
24
  listpick/utils/table_to_list_of_lists.py,sha256=Ox_4OWtZcFp5XWcItlMqE6_Q27YiJz7M9w23Y9vfzYQ,7604
25
25
  listpick/utils/utils.py,sha256=McOl9uT3jh7l4TIWeSd8ZGjK_e7r0YZF0Gl20yI6fl0,13873
26
- listpick-0.1.14.2.dist-info/licenses/LICENSE.txt,sha256=2mP-MRHJptADDNE9VInMNg1tE-C6Qv93Z4CCQKrpg9w,1061
27
- listpick-0.1.14.2.dist-info/METADATA,sha256=9tz_0_1IWeRlbFjqChK-Ls-pmm1e_MhsQeRzn57aftE,8090
28
- listpick-0.1.14.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
- listpick-0.1.14.2.dist-info/entry_points.txt,sha256=-QCf_BKIkUz35Y9nkYpjZWs2Qg0KfRna2PAs5DnF6BE,43
30
- listpick-0.1.14.2.dist-info/top_level.txt,sha256=5mtsGEz86rz3qQDe0D463gGjAfSp6A3EWg4J4AGYr-Q,9
31
- listpick-0.1.14.2.dist-info/RECORD,,
26
+ listpick-0.1.14.3.dist-info/licenses/LICENSE.txt,sha256=2mP-MRHJptADDNE9VInMNg1tE-C6Qv93Z4CCQKrpg9w,1061
27
+ listpick-0.1.14.3.dist-info/METADATA,sha256=aCfS3JHtI7fj15zC7bn1iv1PHtAhpx-eP3bkMUZQWfU,8090
28
+ listpick-0.1.14.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
+ listpick-0.1.14.3.dist-info/entry_points.txt,sha256=-QCf_BKIkUz35Y9nkYpjZWs2Qg0KfRna2PAs5DnF6BE,43
30
+ listpick-0.1.14.3.dist-info/top_level.txt,sha256=5mtsGEz86rz3qQDe0D463gGjAfSp6A3EWg4J4AGYr-Q,9
31
+ listpick-0.1.14.3.dist-info/RECORD,,