From ec7ad5845cf13fdf61af207fa9a06f280bb70ef5 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Mon, 3 Jun 2024 15:05:00 -0500 Subject: [PATCH] 1.0.38 --- package/README.md | 4 +++- package/pyproject.toml | 2 +- package/src/firepup650/__init__.py | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/package/README.md b/package/README.md index 52883bc..e6f93b0 100644 --- a/package/README.md +++ b/package/README.md @@ -1,7 +1,9 @@ # Firepup650 Package containing various shorthand things I use, and a few imports I almost always use ### Change log: -#### v.1.0.37 +#### v.1.0.38: +Mappings for much larger menu sizes, hopefully no one should ever hit that limit. +#### v.1.0.37: Upgrades to gp and gh, they now function as stand-alone prompts, and allow deletion of characters as well (`allowDelete` must be set to `True`) #### v.1.0.36: Fix an old annoying bug with menus having an incorrect size calculation if the width of the menu was an even number diff --git a/package/pyproject.toml b/package/pyproject.toml index c000db4..18fbad5 100644 --- a/package/pyproject.toml +++ b/package/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "firepup650" -version = "1.0.37" +version = "1.0.38" authors = ["Firepup650 "] description = "Package containing various shorthand things I use, and a few imports I almost always use" readme = "README.md" diff --git a/package/src/firepup650/__init__.py b/package/src/firepup650/__init__.py index e79f2ce..2be8763 100644 --- a/package/src/firepup650/__init__.py +++ b/package/src/firepup650/__init__.py @@ -880,6 +880,24 @@ def menu(options: dict, title: str = "") -> object: UP = [fkey.KEYS["UP"], b"w", b"a", fkey.KEYS["LEFT"]] DOWN = [fkey.KEYS["DOWN"], b"s", b"d", fkey.KEYS["RIGHT"]] indicatorSize = len(str(limit)) * 2 + 1 + indicatorOffset = 999 + match indicatorSize: + case 3: # 1-9 options + indicatorOffset = 1 + case 5: # 10-99 options + indicatorOffset = 0 + case 7: # 100-999 options + indicatorOffset = -1 + case 9: # 1000-9999 options + indicatorOffset = -2 + case 11: # 10000-99999 options + indicatorOffset = -3 + case 13: # 100000-999999 options + indicatorOffset = -4 + case _: + raise ValueError( + f"You have more menu options than was ever expected to be used, please notify the package author to add a offset mappting for an indicator size of {indicatorSize}." + ) menuWidth = max( [max([len(choice) for choice in choices]) + 4, indicatorSize * 2 + 7] ) @@ -888,7 +906,7 @@ def menu(options: dict, title: str = "") -> object: flushPrint( (title + "\n" if title else "") + f"╔{'═'*menuWidth}╗\n" - + f"║ {f'{current+1}'}{' '*(len(str(limit))-len(str(current+1)))}/{limit}{' '*int(menuWidth/2-indicatorSize-2.5)}↑{' '*int((menuWidth-indicatorSize)/2-(0 if indicatorSize!=3 else 1)+(1 if menuWidth%2==0 else 0))} ║\n" + + f"║ {f'{current+1}'}{' '*(len(str(limit))-len(str(current+1)))}/{limit}{' '*int(menuWidth/2-indicatorSize-2.5)}↑{' '*int((menuWidth-indicatorSize)/2-indicatorOffset+(1 if menuWidth%2==0 else 0))} ║\n" + f"║←{' '*int(((menuWidth-len(choices[current]))/2)-1)}{choices[current]}{' '*int((menuWidth-len(choices[current]))/2-.5)}→║\n" + f"║{' '*int((menuWidth-1)/2)}↓{' '*int((menuWidth-1)/2+.5)}║\n" + f"╚{'═'*menuWidth}╝\n"