@@ -31,8 +31,8 @@ type InputBox struct {
3131 onTextChanged InputBoxOnTextChanged
3232}
3333
34- // draw renders the input box at the bottom line of the screen, showing a
35- // simple prompt and the current text with a reverse attribute cursor .
34+ // draw renders the input box at the bottom line of the screen, showing a simple
35+ // prompt and the current text, with the cursor placed at the insertion point .
3636func (b * InputBox ) draw (screen twin.Screen , keys_help string , prompt string ) {
3737 width , height := screen .Size ()
3838 pos := 0
@@ -59,18 +59,11 @@ func (b *InputBox) draw(screen twin.Screen, keys_help string, prompt string) {
5959 pos += screen .SetCell (pos , height - 1 , twin.StyledRune {Rune : ch , Style : twin .StyleDefault })
6060 }
6161
62- // If cursor is on a rune, invert that rune. If cursor is at the end,
63- // show an inverted blank cell.
64- if b .cursorPos < len (textRunes ) {
65- pos += screen .SetCell (pos , height - 1 , twin.StyledRune {Rune : textRunes [b .cursorPos ], Style : twin .StyleDefault .WithAttr (twin .AttrReverse )})
62+ screen .ShowCursor (pos , height - 1 )
6663
67- // Draw right side after the cursor rune
68- for i := b .cursorPos + 1 ; i < len (textRunes ); i ++ {
69- pos += screen .SetCell (pos , height - 1 , twin.StyledRune {Rune : textRunes [i ], Style : twin .StyleDefault })
70- }
71- } else {
72- // Cursor at end -> reverse blank
73- pos += screen .SetCell (pos , height - 1 , twin.StyledRune {Rune : ' ' , Style : twin .StyleDefault .WithAttr (twin .AttrReverse )})
64+ // Draw right side (cursor position and after)
65+ for i := b .cursorPos ; i < len (textRunes ); i ++ {
66+ pos += screen .SetCell (pos , height - 1 , twin.StyledRune {Rune : textRunes [i ], Style : twin .StyleDefault })
7467 }
7568
7669 afterTextPos := pos
0 commit comments