diff --git a/openvpncertupdate.py b/openvpncertupdate.py index a91120f..bc7269d 100644 --- a/openvpncertupdate.py +++ b/openvpncertupdate.py @@ -477,6 +477,12 @@ class InputField: try: self._win.addstr(self._y, self._x, visible, curses.color_pair(COLOR_NORMAL) | curses.A_UNDERLINE) + except curses.error: + pass + + def place_cursor(self) -> None: + start = max(0, self._cur - self._width + 1) + try: self._win.move(self._y, self._x + min(self._cur - start, self._width - 1)) except curses.error: pass @@ -588,6 +594,7 @@ def show_cert_form( confirmed=True, ) + curses.curs_set(1) while True: win.clear() draw_box(win, "Certificate Details") @@ -609,6 +616,7 @@ def show_cert_form( else: fields[name].draw() + fields[active[focus]].place_cursor() hint = "Tab=next F5=regen password Ctrl-S=confirm Esc=cancel" try: win.addstr(h - 2, 2, hint[:w - 4], curses.color_pair(COLOR_DISABLED)) @@ -619,8 +627,10 @@ def show_cert_form( key = win.getch() if key == 27: + curses.curs_set(0) return CertFormResult(cn=cn, email="", password="", confirmed=False) if key == 0x13: # Ctrl-S: immediate submit + curses.curs_set(0) return _submit() if key == 9: # Tab focus = (focus + 1) % len(active) @@ -644,6 +654,7 @@ def show_cert_form( if focus < len(active) - 1: focus += 1 continue + curses.curs_set(0) return _submit() fields[active[focus]].handle_key(key)