awesome-gocui / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
350 stars 39 forks source link

Fix/move cursor when no wrap #123

Closed dankox closed 2 years ago

dankox commented 2 years ago

Fixes #121

MoveCursor should now move the cursor to the left and leave 2 more characters visible before it if possible. Fixes also problem when merging two lines by hitting backspace in the beginning of the previous line. The position wasn't updated correctly and didn't move the view to the cursor.

dankox commented 2 years ago

@monol33t so in the end I fixed also the problem with small view and created PR. Feel free to try and let us know if it works for you.

ghost commented 2 years ago

@dankox thank you, the solution for the first case works fine.

For the second case, I suggest decreasing origin position by x basis so that it creates illusion of freezing cursor when line length exceeds view width.

dankox commented 2 years ago

@monol33t I'm not sure if I understand. Right now it kinda creates this illusion of cursor freezing and just the line moving. Try the _examples/active.go and v4 (editable) view. Write a long line and when scrolling back with left arrow the cursor should stop 2 characters before the edge (unless there is no more characters in which case it should go to the edge).