listpick 0.1.16.13__py3-none-any.whl → 0.1.16.15__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.

Potentially problematic release.


This version of listpick might be problematic. Click here for more details.

listpick/listpick_app.py CHANGED
@@ -24,7 +24,6 @@ import logging
24
24
  import copy
25
25
  import tempfile
26
26
  import queue
27
- from listpick.utils.generate_data_utils import ProcessSafePriorityQueue
28
27
 
29
28
  from listpick.pane.pane_utils import get_file_attributes
30
29
  from listpick.pane.left_pane_functions import *
@@ -163,6 +162,7 @@ class Picker:
163
162
  reset_colours: bool = True,
164
163
  key_remappings: dict = {},
165
164
  keys_dict:dict = picker_keys,
165
+ macros: list = [],
166
166
  display_infobox : bool = False,
167
167
  infobox_items: list[list[str]] = [],
168
168
  infobox_title: str = "",
@@ -316,6 +316,7 @@ class Picker:
316
316
  self.reset_colours = reset_colours
317
317
  self.key_remappings = key_remappings
318
318
  self.keys_dict = keys_dict
319
+ self.macros = macros
319
320
  self.display_infobox = display_infobox
320
321
  self.infobox_items = infobox_items
321
322
  self.infobox_title = infobox_title
@@ -1129,7 +1130,6 @@ class Picker:
1129
1130
  cell_value = truncate_to_display_width(cell_value, min(cell_width, cell_max_width), self.centre_in_cols, self.unicode_char_width)
1130
1131
  if wcswidth(cell_value) + cell_pos > self.term_w:
1131
1132
  cell_value = truncate_to_display_width(cell_value, self.term_w-cell_pos-10, self.centre_in_cols, self.unicode_char_width)
1132
-
1133
1133
  self.stdscr.addstr(y, cell_pos, cell_value, colour)
1134
1134
 
1135
1135
  # Part of the cell is on screen
@@ -1148,6 +1148,7 @@ class Picker:
1148
1148
  pass
1149
1149
 
1150
1150
 
1151
+
1151
1152
  def sort_highlights(highlights):
1152
1153
  """
1153
1154
  Sort highlights into lists based on their display level.
@@ -1585,6 +1586,7 @@ class Picker:
1585
1586
  "id_column": self.id_column,
1586
1587
  "startup_notification": self.startup_notification,
1587
1588
  "keys_dict": self.keys_dict,
1589
+ "macros": self.macros,
1588
1590
  "cancel_is_back": self.cancel_is_back,
1589
1591
  "paginate": self.paginate,
1590
1592
  "leftmost_char": self.leftmost_char,
@@ -2287,6 +2289,19 @@ class Picker:
2287
2289
  return True
2288
2290
  return False
2289
2291
 
2292
+ def check_and_run_macro(self, key: int) -> bool:
2293
+ macro_match = False
2294
+ for macro in self.macros:
2295
+ try:
2296
+ if key in macro["keys"]:
2297
+ macro_match = True
2298
+ macro["function"](self)
2299
+ break
2300
+ except:
2301
+ pass
2302
+ return macro_match
2303
+
2304
+
2290
2305
  def copy_dialogue(self) -> None:
2291
2306
  """ Display dialogue to select how rows/cells should be copied. """
2292
2307
  self.logger.info(f"function: copy_dialogue()")
@@ -2874,6 +2889,7 @@ class Picker:
2874
2889
  self.refreshing_data = False
2875
2890
  self.data_ready = False
2876
2891
 
2892
+
2877
2893
  elif self.check_key("refresh", key, self.keys_dict) or self.remapped_key(key, curses.KEY_F5, self.key_remappings) or (self.auto_refresh and (time.time() - self.initial_time) >= self.timer):
2878
2894
  self.logger.debug(f"Get new data (refresh).")
2879
2895
  try:
@@ -2928,7 +2944,7 @@ class Picker:
2928
2944
  self.stdscr.refresh()
2929
2945
  help_data = {
2930
2946
  # "items": help_lines,
2931
- "items": build_help_rows(self.keys_dict),
2947
+ "items": build_help_rows(self.keys_dict, self.macros),
2932
2948
  "title": f"{self.title} Help",
2933
2949
  "colours_start": self.help_colours_start,
2934
2950
  "colours": help_colours,
@@ -2952,6 +2968,10 @@ class Picker:
2952
2968
  s, o, f = OptionPicker.run()
2953
2969
  self.draw_screen()
2954
2970
 
2971
+ if self.check_and_run_macro(key):
2972
+ self.draw_screen()
2973
+ continue
2974
+
2955
2975
  if self.check_key("info", key, self.keys_dict):
2956
2976
  self.logger.info(f"key_function help")
2957
2977
  self.stdscr.clear()
@@ -3139,29 +3159,29 @@ class Picker:
3139
3159
 
3140
3160
  elif self.check_key("settings_options", key, self.keys_dict):
3141
3161
  options = []
3162
+ options += [["cv", "Centre rows vertically"]]
3163
+ options += [["pc", "Pin cursor to row index during data refresh."]]
3164
+ options += [["ct", "Centre column-set in terminal"]]
3165
+ options += [["cc", "Centre values in cells"]]
3166
+ options += [["!r", "Toggle auto-refresh"]]
3167
+ options += [["th", "Cycle between themes. (accepts th#)"]]
3168
+ options += [["colsel", "Toggle columns."]]
3169
+ options += [["nohl", "Toggle highlights"]]
3170
+ options += [["footer", "Toggle footer"]]
3171
+ options += [["header", "Toggle header"]]
3172
+ options += [["rh", "Toggle row header"]]
3173
+ options += [["modes", "Toggle modes"]]
3174
+ options += [["ft", "Cycle through footer styles (accepts ft#)"]]
3175
+ options += [["file_next", "Go to the next open file."]]
3176
+ options += [["file_prev", "Go to the previous open file."]]
3177
+ options += [["sheet_next", "Go to the next sheet."]]
3178
+ options += [["sheet_prev", "Go to the previous sheet."]]
3179
+ options += [["unicode", "Toggle b/w using len and wcwidth to calculate char width."]]
3180
+ options += [["ara", "Add empty row after cursor."]]
3181
+ options += [["arb", "Add empty row before the cursor."]]
3182
+ options += [["aca", "Add empty column after the selected column."]]
3183
+ options += [["acb", "Add empty column before the selected column."]]
3142
3184
  if len(self.items) > 0:
3143
- options += [["cv", "Centre rows vertically"]]
3144
- options += [["pc", "Pin cursor to row index during data refresh."]]
3145
- options += [["ct", "Centre column-set in terminal"]]
3146
- options += [["cc", "Centre values in cells"]]
3147
- options += [["!r", "Toggle auto-refresh"]]
3148
- options += [["th", "Cycle between themes. (accepts th#)"]]
3149
- options += [["colsel", "Toggle columns."]]
3150
- options += [["nohl", "Toggle highlights"]]
3151
- options += [["footer", "Toggle footer"]]
3152
- options += [["header", "Toggle header"]]
3153
- options += [["rh", "Toggle row header"]]
3154
- options += [["modes", "Toggle modes"]]
3155
- options += [["ft", "Cycle through footer styles (accepts ft#)"]]
3156
- options += [["file_next", "Go to the next open file."]]
3157
- options += [["file_prev", "Go to the previous open file."]]
3158
- options += [["sheet_next", "Go to the next sheet."]]
3159
- options += [["sheet_prev", "Go to the previous sheet."]]
3160
- options += [["unicode", "Toggle b/w using len and wcwidth to calculate char width."]]
3161
- options += [["ara", "Add empty row after cursor."]]
3162
- options += [["arb", "Add empty row before the cursor."]]
3163
- options += [["aca", "Add empty column after the selected column."]]
3164
- options += [["acb", "Add empty column before the selected column."]]
3165
3185
  options += [[f"col{i}", f"Select column {i}"] for i in range(len(self.items[0]))]
3166
3186
  options += [[f"s{i}", f"Sort by column {i}"] for i in range(len(self.items[0]))]
3167
3187
  options += [[f"!{i}", f"Toggle visibility of column {i}"] for i in range(len(self.items[0]))]
@@ -3843,7 +3863,7 @@ class Picker:
3843
3863
  field_prefix=" Command: ",
3844
3864
  x=lambda:2,
3845
3865
  y=lambda: self.get_term_size()[0]-2,
3846
- literal=True,
3866
+ literal=False,
3847
3867
  max_length=field_end_f,
3848
3868
  registers=self.registers,
3849
3869
  refresh_screen_function=lambda: self.draw_screen(),
@@ -4575,6 +4595,13 @@ def main() -> None:
4575
4595
  "refresh_time": 1,
4576
4596
  },
4577
4597
  ]
4598
+ function_data["macros"] = [
4599
+ # {
4600
+ # "keys": [ord('z')],
4601
+ # "description": "Display message via dbus.",
4602
+ # "function": lambda picker_obj: os.system("notify-send 'zkey pressed'")
4603
+ # },
4604
+ ]
4578
4605
  # function_data["require_option"] = [True for _ in function_data["items"]]
4579
4606
 
4580
4607
  stdscr = start_curses()
listpick/ui/build_help.py CHANGED
@@ -14,7 +14,7 @@ from listpick.utils import keycodes
14
14
 
15
15
  logger = logging.getLogger('picker_log')
16
16
 
17
- def build_help_rows(keys_dict: dict, debug: bool = False) -> list[list[str]]:
17
+ def build_help_rows(keys_dict: dict, macros: list, debug: bool = False) -> list[list[str]]:
18
18
  """ Build help rows based on the keys_dict. """
19
19
 
20
20
  logger.info(f"function: build_help_rows() (build_help.py)")
@@ -173,6 +173,8 @@ def build_help_rows(keys_dict: dict, debug: bool = False) -> list[list[str]]:
173
173
  if not found:
174
174
  sections["Misc:"].append(key)
175
175
 
176
+
177
+
176
178
  items = []
177
179
  for section_name, section_operations in sections.items():
178
180
  section_rows = []
@@ -208,6 +210,26 @@ def build_help_rows(keys_dict: dict, debug: bool = False) -> list[list[str]]:
208
210
  items += section_rows
209
211
  items.append(["",""])
210
212
 
213
+ if macros:
214
+ items.append([f" Macros:", ""])
215
+ for macro in macros:
216
+ keys = []
217
+ for key in macro["keys"]:
218
+ if key in special_keys:
219
+ keys.append(special_keys[key])
220
+ else:
221
+ try:
222
+ keys.append(chr(int(key)))
223
+ except Exception as e:
224
+ keys.append(f"keycode={key}")
225
+ if debug: print(f"Error chr({key}): {e}")
226
+
227
+ row = [f" {str(keys)[1:-1]}", macro["description"]]
228
+ items.append(row)
229
+ items.append(["",""])
230
+
231
+
232
+
211
233
  if debug:
212
234
  for operation in keys_dict:
213
235
  if operation not in help_descriptions:
@@ -193,7 +193,6 @@ def input_field(
193
193
  match_word, left_ptr, right_ptr = get_partially_complete_word(usrtxt, cursor, [" ", "/", "="])
194
194
 
195
195
  if match_word in completions:
196
- # os.system(f"notify-send '{completions[0]}'")
197
196
  index = completions.index(match_word)
198
197
  if index == len(completions) - 1: index = -1
199
198
  completions_disp_str = str(completions[index:])[:max_field_length]
listpick/ui/keys.py CHANGED
@@ -52,7 +52,7 @@ picker_keys = {
52
52
  "continue_search_backward": [ord('N')],
53
53
  "cancel": [27], # Escape key
54
54
  "opts_input": [keycodes.META_o],
55
- "opts_select": [ord('o')],
55
+ # "opts_select": [ord('+')],
56
56
  "mode_next": [9], # Tab key
57
57
  "mode_prev": [353], # Shift+Tab key
58
58
  "pipe_input": [ord('|')],
@@ -69,7 +69,7 @@ picker_keys = {
69
69
  "paste": [ord('p')],
70
70
  "save": [19, ord('D')], # Ctrl+s
71
71
  "load": [15], # Ctrl+o
72
- "open": [ord('O')],
72
+ # "open": [ord('O')],
73
73
  "toggle_footer": [ord('_')],
74
74
  "notification_toggle": [ord('z')],
75
75
  "redo": [ord('.')],
@@ -238,8 +238,8 @@ edit_menu_keys = {
238
238
  "continue_search_forward": [ord('n'), ord('i')],
239
239
  "continue_search_backward": [ord('N'), ord('I')],
240
240
  "cancel": [27], # Escape key
241
- "opts_input": [ord(':')],
242
- "opts_select": [ord('o')],
241
+ "opts_input": [keycodes.META_o],
242
+ # "opts_select": [ord('+')],
243
243
  "mode_next": [9], # Tab key
244
244
  "mode_prev": [353], # Shift+Tab key
245
245
  "pipe_input": [ord('|')],
@@ -254,7 +254,7 @@ edit_menu_keys = {
254
254
  "copy": [ord('y')],
255
255
  "save": [19, ord('D')], # Ctrl+s
256
256
  "load": [ord('L'), 15], # Ctrl+o
257
- "open": [ord('O')],
257
+ # "open": [ord('O')],
258
258
  "toggle_footer": [ord('_')],
259
259
  "visual_selection_toggle": [ord('v')],
260
260
  "visual_deselection_toggle": [ord('V')],
listpick/utils/utils.py CHANGED
@@ -103,7 +103,12 @@ def format_row(row: list[str], hidden_columns: list, column_widths: list[int], s
103
103
 
104
104
  def get_column_widths(items: list[list[str]], header: list[str]=[], max_column_width:int=70, number_columns:bool=True, max_total_width=-1, separator = " ", unicode_char_width: bool = True) -> list[int]:
105
105
  """ Calculate maximum width of each column with clipping. """
106
- if len(items) == 0: return [0]
106
+ if len(items) == 0 and len(header) == 0: return [0]
107
+ elif len(items) == 0:
108
+ header_widths = [wcswidth(f"{i}. {str(h)}") if number_columns else wcswidth(str(h)) for i, h in enumerate(header)]
109
+ col_widths = [min(max_column_width, header_widths[i]) for i in range(len(header))]
110
+ return col_widths
111
+
107
112
  assert len(items) > 0
108
113
  widths = [max(wcswidth(str(row[i])) for row in items) for i in range(len(items[0]))]
109
114
  # widths = [max(len(str(row[i])) for row in items) for i in range(len(items[0]))]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: listpick
3
- Version: 0.1.16.13
3
+ Version: 0.1.16.15
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,6 +1,6 @@
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=IECGLycdZb7YDXapnxHzj8wlaVHJJEKZk3m5I675UaM,222093
3
+ listpick/listpick_app.py,sha256=gBHESxkUbEy1-PuFlFW9dem1-dWyazC4LDCUsTQz0fI,222772
4
4
  listpick/pane/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  listpick/pane/get_data.py,sha256=l12mHIb6qoZWIfW5zZZY8K8EqNcyIcRiHgtRaM2CVGs,2735
6
6
  listpick/pane/left_pane_functions.py,sha256=SVIW4Ef8uNPBQRk4hL67mEFL3pfgChSFZSMRz06CVzw,5543
@@ -8,12 +8,12 @@ listpick/pane/pane_functions.py,sha256=_dL9jHpd3sT0enL9H_bMcUsBlMELXdtP9dtKFSC2K
8
8
  listpick/pane/pane_functions_1.py,sha256=_dL9jHpd3sT0enL9H_bMcUsBlMELXdtP9dtKFSC2KPQ,5117
9
9
  listpick/pane/pane_utils.py,sha256=cnuzBH52wdWoKrHR6iMBF4N-uhwpXYpHDnrglk21pqg,2539
10
10
  listpick/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- listpick/ui/build_help.py,sha256=WVxrMaZ94oY32ijb4A3NdxQYDySF_FvygYuqiTHNIsk,11072
11
+ listpick/ui/build_help.py,sha256=wSGeE3tUVWP7D709mb1cDyRU2M0QKVg0mRyTFmcR3fo,11720
12
12
  listpick/ui/draw_screen.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  listpick/ui/footer.py,sha256=NcdH1uO_ma91m0qCczyQZ3zGrexfkiEnwDf5E4tHSMk,15089
14
14
  listpick/ui/help_screen.py,sha256=zbfGIgb-IXtATpl4_Sx7nPbsnRXZ7eiMYlCKGS9EFmw,5608
15
- listpick/ui/input_field.py,sha256=scJjvmSS0QqeDbCky7_0Zgt35Aki7gezRJkrQROlLg4,30034
16
- listpick/ui/keys.py,sha256=PN19jCQeXJCdmaP_FT--3TKFZ_8Iv71Pa_yGFp6H3FA,14062
15
+ listpick/ui/input_field.py,sha256=1GUuzMl7P-uw5ijYUOQONMhAzAKoYXRax0-332OroLE,29971
16
+ listpick/ui/keys.py,sha256=7QpG8xEp7kBH9tObTzL-Cmw7i5HTvN6amA3Dd4FmMpE,14077
17
17
  listpick/ui/picker_colours.py,sha256=PYWtJEbBCsiM-Gbm83vJiFoIwfKuJuP4SGKxpozszKY,15159
18
18
  listpick/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  listpick/utils/clipboard_operations.py,sha256=ORdNm2kgGbfs51xJSvgJPERgoSmBgT11axuMkvSoP9A,3133
@@ -34,10 +34,10 @@ listpick/utils/searching.py,sha256=Xk5UIqamNHL2L90z3ACB_Giqdpi9iRKoAJ6pKaqaD7Q,3
34
34
  listpick/utils/sorting.py,sha256=WZZiVlVA3Zkcpwji3U5SNFlQ14zVEk3cZJtQirBkecQ,5329
35
35
  listpick/utils/table_to_list_of_lists.py,sha256=XBj7eGBDF15BRME-swnoXyOfZWxXCxrXp0pzsBfcJ5g,12224
36
36
  listpick/utils/user_input.py,sha256=L3ylI7nnuFM_TP1XKwpiKpxUSkNb2W5cr7mJjTmv_6E,4582
37
- listpick/utils/utils.py,sha256=jML0lWl1xxrN7olSBiXUWR2ZdcJMrb5FFcweEz7kDiA,13667
38
- listpick-0.1.16.13.dist-info/licenses/LICENSE.txt,sha256=2mP-MRHJptADDNE9VInMNg1tE-C6Qv93Z4CCQKrpg9w,1061
39
- listpick-0.1.16.13.dist-info/METADATA,sha256=6S2mKlbYNClwZJQ-Zz9M3VW6MLe3ZoySrNieroiyKC0,7144
40
- listpick-0.1.16.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
- listpick-0.1.16.13.dist-info/entry_points.txt,sha256=-QCf_BKIkUz35Y9nkYpjZWs2Qg0KfRna2PAs5DnF6BE,43
42
- listpick-0.1.16.13.dist-info/top_level.txt,sha256=5mtsGEz86rz3qQDe0D463gGjAfSp6A3EWg4J4AGYr-Q,9
43
- listpick-0.1.16.13.dist-info/RECORD,,
37
+ listpick/utils/utils.py,sha256=gwonigqPd8nSQBvN6lLDB68kwUzXqWALesZBja-cehU,13956
38
+ listpick-0.1.16.15.dist-info/licenses/LICENSE.txt,sha256=2mP-MRHJptADDNE9VInMNg1tE-C6Qv93Z4CCQKrpg9w,1061
39
+ listpick-0.1.16.15.dist-info/METADATA,sha256=hR5NhX2q8BTGDj-P0r8gaD0Hh75ZtuddbFRAv34HZjI,7144
40
+ listpick-0.1.16.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
+ listpick-0.1.16.15.dist-info/entry_points.txt,sha256=-QCf_BKIkUz35Y9nkYpjZWs2Qg0KfRna2PAs5DnF6BE,43
42
+ listpick-0.1.16.15.dist-info/top_level.txt,sha256=5mtsGEz86rz3qQDe0D463gGjAfSp6A3EWg4J4AGYr-Q,9
43
+ listpick-0.1.16.15.dist-info/RECORD,,