From 4cda264746d22ef339542d03b4ffbb5c69049577 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Wed, 11 Feb 2026 21:40:42 -0800 Subject: [PATCH] Display IPs Correctly --- contact/ui/control_ui.py | 13 +++++++++++++ contact/utilities/input_handlers.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/contact/ui/control_ui.py b/contact/ui/control_ui.py index 262652d..235655e 100644 --- a/contact/ui/control_ui.py +++ b/contact/ui/control_ui.py @@ -1,5 +1,6 @@ import base64 import curses +import ipaddress import logging import os import sys @@ -122,6 +123,18 @@ def display_menu() -> tuple[object, object]: full_key = ".".join(transformed_path + [option]) display_name = field_mapping.get(full_key, option) + if full_key.startswith("config.network.ipv4_config.") and option in {"ip", "gateway", "subnet", "dns"}: + if isinstance(current_value, int): + try: + current_value = str(ipaddress.IPv4Address(current_value)) + except ipaddress.AddressValueError: + pass + elif isinstance(current_value, str) and current_value.isdigit(): + try: + current_value = str(ipaddress.IPv4Address(int(current_value))) + except ipaddress.AddressValueError: + pass + display_option = f"{display_name}"[: w // 2 - 2] display_value = f"{current_value}"[: w // 2 - 4] diff --git a/contact/utilities/input_handlers.py b/contact/utilities/input_handlers.py index 3233488..edb9d7c 100644 --- a/contact/utilities/input_handlers.py +++ b/contact/utilities/input_handlers.py @@ -536,7 +536,7 @@ def get_fixed32_input(current_value: int) -> int: curses.napms(1500) user_input = "" - elif key in (curses.KEY_BACKSPACE, 127): + elif key in (curses.KEY_BACKSPACE, curses.KEY_DC, 127, 8, "\b", "\x7f"): user_input = user_input[:-1] else: