You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug show_text_box_popup does not properly position cursor when HOME and END keys are pressed. Instead of positioning at the start of the popup input box, HOME sends the cursor to the start of the line (left edge of terminal). END positions the cursor offset from the start of the line instead of the start of the popup box.
To Reproduce
Steps to reproduce the behavior:
Open a popup text box.
Enter text.
Press HOME key and press END key.
Expected behavior
HOME and END should position the cursor within the bounding box of the popup.
Root Cause
Root cause is that _initial_cursor position of the TextBoxImplementation is always set to 0.
# TODO Workaround until upstream py_cui fixes bugroot._popup._initial_cursor=root._popup.get_start_position()[0] +root._popup.get_padding()[0] +2
I believe the fix for this is modifying update_height_width of TextBoxPopup:
defupdate_height_width(self) ->None:
"""Need to update all cursor positions on resize """Popup.update_height_width(self)
padx, pady=self.get_padding()
start_x, start_y=self.get_start_position()
height, width=self.get_absolute_dimensions()
self._cursor_text_pos=0self._cursor_x=start_x+2+padx###################################self._initial_cursor=self._cursor_x###################################self._cursor_max_left=self._cursor_xself._cursor_max_right=start_x+width-1-padyself._cursor_y=start_y+int(height/2) +1self._viewport_width=self._cursor_max_right-self._cursor_max_left
Because the _jump_to_start and _jump_to_end methods in TextBoxImplemenation use the _initial_cursor position to place the cursor, which is currently always set to 0 thus causing the issue.
Describe the bug
show_text_box_popup
does not properly position cursor when HOME and END keys are pressed. Instead of positioning at the start of the popup input box, HOME sends the cursor to the start of the line (left edge of terminal). END positions the cursor offset from the start of the line instead of the start of the popup box.To Reproduce
Steps to reproduce the behavior:
Expected behavior
HOME and END should position the cursor within the bounding box of the popup.
Root Cause
Root cause is that
_initial_cursor
position of theTextBoxImplementation
is always set to0
.py_cui/py_cui/ui.py
Line 485 in f1173ca
As a workaround, I have to use this hack:
I believe the fix for this is modifying
update_height_width
ofTextBoxPopup
:Because the
_jump_to_start
and_jump_to_end
methods inTextBoxImplemenation
use the_initial_cursor
position to place the cursor, which is currently always set to0
thus causing the issue.py_cui/py_cui/ui.py
Lines 625 to 638 in f1173ca
Environment:
The text was updated successfully, but these errors were encountered: