From c6d0304d948f1cba94c040674c8dcde38575da05 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Wed, 9 May 2018 18:57:48 +0200 Subject: menuconfig: Fix rendering of long prefilled edit box string The horizontal scroll (hscroll) wasn't initialized properly when the initial (prefilled) contents of an edit box was longer than the edit box itself (e.g. when saving with a long path in KCONFIG_CONFIG). Things snapped back into place once a key was pressed. Initialize hscroll properly to fix the initial rendering. --- menuconfig.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/menuconfig.py b/menuconfig.py index a391be5..f0e524f 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1080,8 +1080,11 @@ def _input_dialog(title, initial_text, info_text=None): # Cursor position i = len(initial_text) + def edit_width(): + return win.getmaxyx()[1] - 4 + # Horizontal scroll offset - hscroll = 0 + hscroll = max(i - edit_width() + 1, 0) while True: # Draw the "main" display with the menu, etc., so that resizing still @@ -1109,7 +1112,7 @@ def _input_dialog(title, initial_text, info_text=None): _resize_input_dialog(win, title, info_text) else: - s, i, hscroll = _edit_text(c, s, i, hscroll, win.getmaxyx()[1] - 4) + s, i, hscroll = _edit_text(c, s, i, hscroll, edit_width()) def _resize_input_dialog(win, title, info_text): # Resizes the input dialog to a size appropriate for the terminal size -- cgit v1.2.3