diff --git a/invokeai/backend/install/invokeai_configure.py b/invokeai/backend/install/invokeai_configure.py index 3dde014701..a2df24bd8a 100755 --- a/invokeai/backend/install/invokeai_configure.py +++ b/invokeai/backend/install/invokeai_configure.py @@ -44,6 +44,7 @@ from invokeai.frontend.install.widgets import ( CenteredButtonPress, IntTitleSlider, set_min_terminal_size, + CyclingForm, MIN_COLS, MIN_LINES, ) @@ -310,7 +311,7 @@ def get_root(root: str = None) -> str: return str(config.root_path) # ------------------------------------- -class editOptsForm(npyscreen.FormMultiPage): +class editOptsForm(CyclingForm, npyscreen.FormMultiPage): # for responsive resizing - disabled # FIX_MINIMUM_SIZE_WHEN_CREATED = False @@ -548,7 +549,7 @@ class editOptsForm(npyscreen.FormMultiPage): self.editing = False else: self.editing = True - + def validate_field_values(self, opt: Namespace) -> bool: bad_fields = [] if not opt.license_acceptance: @@ -612,6 +613,7 @@ class EditOptApplication(npyscreen.NPSAppManaged): "MAIN", editOptsForm, name="InvokeAI Startup Options", + cycle_widgets=True, ) if not (self.program_opts.skip_sd_weights or self.program_opts.default_only): self.model_select = self.addForm( diff --git a/invokeai/frontend/install/model_install.py b/invokeai/frontend/install/model_install.py index 56d1594bee..f52ed1be05 100644 --- a/invokeai/frontend/install/model_install.py +++ b/invokeai/frontend/install/model_install.py @@ -50,6 +50,7 @@ from invokeai.frontend.install.widgets import ( FileBox, set_min_terminal_size, select_stable_diffusion_config_file, + CyclingForm, MIN_COLS, MIN_LINES, ) @@ -68,7 +69,7 @@ def make_printable(s:str)->str: '''Replace non-printable characters in a string''' return s.translate(NOPRINT_TRANS_TABLE) -class addModelsForm(npyscreen.FormMultiPage): +class addModelsForm(CyclingForm, npyscreen.FormMultiPage): # for responsive resizing - disabled # FIX_MINIMUM_SIZE_WHEN_CREATED = False diff --git a/invokeai/frontend/install/widgets.py b/invokeai/frontend/install/widgets.py index fe12958bb3..f188348c5e 100644 --- a/invokeai/frontend/install/widgets.py +++ b/invokeai/frontend/install/widgets.py @@ -69,11 +69,12 @@ def _set_terminal_size_unix(width: int, height: int): def set_min_terminal_size(min_cols: int, min_lines: int, launch_command: str=None): # make sure there's enough room for the ui term_cols, term_lines = get_terminal_size() + if term_cols >= min_cols and term_lines >= min_lines: + return cols = max(term_cols, min_cols) lines = max(term_lines, min_lines) set_terminal_size(cols, lines, launch_command) - class IntSlider(npyscreen.Slider): def translate_value(self): stri = "%2d / %2d" % (self.value, self.out_of) @@ -81,7 +82,23 @@ class IntSlider(npyscreen.Slider): stri = stri.rjust(l) return stri - +# ------------------------------------- +# fix npyscreen form so that cursor wraps both forward and backward +class CyclingForm(object): + def find_previous_editable(self, *args): + done = False + n = self.editw-1 + while not done: + if self._widgets__[n].editable and not self._widgets__[n].hidden: + self.editw = n + done = True + n -= 1 + if n<0: + if self.cycle_widgets: + n = len(self._widgets__)-1 + else: + done = True + # ------------------------------------- class CenteredTitleText(npyscreen.TitleText): def __init__(self, *args, **keywords):