bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.25k stars 56 forks source link

[BUG] InputField cursor is in the wrong place #96

Closed ChrisRamsayITV closed 2 years ago

ChrisRamsayITV commented 2 years ago

Describe the bug The input field cursor seems to be offset by the prompt length rather than the supplied value length.

To Reproduce Steps to reproduce the behavior:

Example code

ptg.InputField(
    prompt='Service Name',
    value='',
)

Expected behavior The cursor should be at the start of the input box

Screenshots image

System information

PyTermGUI version 7.2.0

System details:
    Python version: 3.10.6
    $TERM:          xterm
    $COLORTERM:     None
    Color support:  ColorSystem.STANDARD
    OS Platform:    Linux-5.4.0-125-generic-x86_64-with

Possible cause Possibly this line https://github.com/bczsalba/pytermgui/blob/master/pytermgui/widgets/input_field.py#L88

Possible solution should be: self.cursor = cursor or Cursor(0, len(value))