make-selection 1.0.4__tar.gz → 1.0.5__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: 1.0.4
3
+ Version: 1.0.5
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 = "1.0.4"
3
+ version = "1.0.5"
4
4
  authors = [
5
5
  { name="Steven Frazee", email="stevefrazee123@gmail.com" },
6
6
  ]
@@ -145,7 +145,7 @@ class Menu:
145
145
  self.options_current.remove(selected_option)
146
146
  self.options_original.remove(selected_option)
147
147
  self.options_selected.append(selected_option)
148
- self.resetWindow()
148
+ self.resetWindowMultiSelect()
149
149
 
150
150
  def multiSelectGetValues(self, options: list[Option]) -> list[Any]:
151
151
  return [op.value for op in options]
@@ -161,6 +161,33 @@ class Menu:
161
161
  self.selected_index = 0
162
162
  self.window_size_current = min((len(self.options_current), self.window_size_original))
163
163
 
164
+ def resetWindowMultiSelect(self):
165
+ """
166
+ After selecting item and shrinking the list we try would like to keep
167
+ the selected_index and window the same. This visually looks like the
168
+ list is being pulled up and the selected index goes to the next item.
169
+
170
+ First we will try and shift the window up, keeping the selected index
171
+ the same. Visually this looks a bit weird as the selected index looks
172
+ to be moving down the list, but the behavior I think is good because
173
+ the index goes to the next item in the list. If we kept the index static
174
+ on the screen it would be moving to the previous item instead of the next
175
+ which I don't think I want.
176
+
177
+ If we can't keep the list the same or shift the window up, that means the
178
+ list is too small and we will just shrink the window.
179
+ """
180
+ window_bottom_current = self.window_top + self.window_size_current
181
+ if len(self.options_current) < window_bottom_current:
182
+ if 0 < self.window_top:
183
+ self.window_top -= 1
184
+ else:
185
+ self.window_size_current -= 1
186
+ # NOTE: this must be calculated after we change top/size above
187
+ window_bottom_new = self.window_top + self.window_size_current
188
+ if window_bottom_new <= self.selected_index:
189
+ self.selected_index -= 1
190
+
164
191
  def clearMenu(self):
165
192
  """
166
193
  Clears from beginning of current line to end of screen (not end of line).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: make_selection
3
- Version: 1.0.4
3
+ Version: 1.0.5
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