make-selection 0.0.2__tar.gz → 1.0.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.1
2
2
  Name: make_selection
3
- Version: 0.0.2
3
+ Version: 1.0.0
4
4
  Summary: Package for interactive command line menu
5
5
  Author-email: Steven Frazee <stevefrazee123@gmail.com>
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "make_selection"
3
- version = "0.0.2"
3
+ version = "1.0.0"
4
4
  authors = [
5
5
  { name="Steven Frazee", email="stevefrazee123@gmail.com" },
6
6
  ]
@@ -14,11 +14,14 @@ enable_ansi_codes = 7
14
14
  kernel32 = ctypes.windll.kernel32
15
15
  kernel32.SetConsoleMode(kernel32.GetStdHandle(stdout), enable_ansi_codes)
16
16
 
17
- ANSI_MOVE_CURSOR = "\x1b[{up}F\r\x1b[{right}C"
18
- ANSI_HIGHLIGHT = "\x1b[30;47m"
19
- ANSI_YELLOW = "\x1b[93m"
20
- ANSI_BLUE = "\x1b[94m"
21
- ANSI_RESET = "\x1b[0m"
17
+ ANSI_MOVE_CURSOR = "\x1b[{up}F\r\x1b[{right}C"
18
+ ANSI_HIGHLIGHT = "\x1b[30;47m"
19
+ ANSI_HIGHLIGHT_SEARCH_STRING = "\x1b[95;47m"
20
+ ANSI_YELLOW = "\x1b[93m"
21
+ ANSI_BLUE = "\x1b[94m"
22
+ ANSI_MAGENTA = "\x1b[95m"
23
+ ANSI_RESET = "\x1b[0m"
24
+
22
25
  SPECIAL_KEY = 224
23
26
  UP_ARROW = 72
24
27
  DOWN_ARROW = 80
@@ -131,10 +134,20 @@ class Menu:
131
134
  self.window_size_current = 1
132
135
  else:
133
136
  for i in range(self.window_top, bottom):
134
- if i == self.selected_index:
135
- print(f"{ANSI_HIGHLIGHT}{self.options_current[i]}{ANSI_RESET}")
136
- else:
137
- print(self.options_current[i])
137
+ option_to_print = str(self.options_current[i])
138
+ if self.search_indices:
139
+ highlight_beg = self.search_indices[i]
140
+ highlight_end = highlight_beg + len(self.search_string)
141
+ opt_beg = option_to_print[0 : highlight_beg]
142
+ opt_mid = option_to_print[highlight_beg : highlight_end]
143
+ opt_end = option_to_print[highlight_end :]
144
+ if i == self.selected_index:
145
+ option_to_print = f"{ANSI_HIGHLIGHT}{opt_beg}{ANSI_HIGHLIGHT_SEARCH_STRING}{opt_mid}{ANSI_HIGHLIGHT}{opt_end}{ANSI_RESET}"
146
+ else:
147
+ option_to_print = f"{opt_beg}{ANSI_MAGENTA}{opt_mid}{ANSI_RESET}{opt_end}"
148
+ elif i == self.selected_index:
149
+ option_to_print = f"{ANSI_HIGHLIGHT}{option_to_print}{ANSI_RESET}"
150
+ print(option_to_print)
138
151
  print(f"{ANSI_YELLOW}{self.help_string}{ANSI_RESET}\n{ANSI_MOVE_CURSOR.format(up=self.window_size_current + 2, right=len(self.label) + len(self.search_string) + 1)}", end="", flush=True)
139
152
 
140
153
  def printSelected(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: make_selection
3
- Version: 0.0.2
3
+ Version: 1.0.0
4
4
  Summary: Package for interactive command line menu
5
5
  Author-email: Steven Frazee <stevefrazee123@gmail.com>
6
6
  Classifier: License :: OSI Approved :: MIT License
File without changes
File without changes
File without changes