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

[BUG] View Offset/Origin causes weird interactions between cursor and highlight/mouse #118

Closed ekkkkkknoes closed 2 years ago

ekkkkkknoes commented 2 years ago

Describe the bug With a y-origin other than 0 and View.Highlight enabled, the cursor will be above the highlighted line. This means that if the cursor is moved with keybindings, the highlighted line will be off-screen before the cursor reaches the bottom of the screen and the view starts scrolling.

With a y-origin other than 0 and mouse enabled, the cursor will be above the mouse after receiving mouse events, including mouse movements.

These two bugs together cause the highlighted line to always be under the mouse.

To Reproduce

  1. Create a new gui with Gui.Mouse and Gui.Cursor set to true
  2. Create a view with View.Highlight and View.Editable set to true
  3. Set View.Sel[BF]gColor to something more visible
  4. Fill the view with some text
  5. Setup keybinds to move the origin and the cursor
  6. Run it, scroll the view down a bit and move the mouse, cursor, and enter text

For your convenience, here's an example

Expected behavior I expect the highlight from View.Highlight to line up with the cursor, and the cursor to be properly positioned at the mouse location when moved by mouse events.

Screenshots Screenshot

Environment (please complete the following information):

Additional context I've done some testing and can provide a pull request, assuming this is actually a bug and not me misunderstanding some concepts of gocui.