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

Enhanced text editing #121

Closed ghost closed 2 years ago

ghost commented 2 years ago

Describe the feature you'd like Pressing Backspace doesn't let me see what character I'm erasing if the cursor were at the start of a line or somewhere in the middle.

Describe alternatives you've considered Origin position follows cursor position in the above cases.

dankox commented 2 years ago

I'm not quite sure if I understand. When I'm erasing character with backspace the cursor is in front of such character. If it's in the beginning of the line the cursor move the the end of line before which I can see (unless it's not wrapping and the line extends out of the visible screen/terminal).

I can also see the character under the cursor (which the cursor is on top). So I'm not really sure what is required. Could you maybe provide some videos/gifs to better show the problem and maybe the solution which is probably in other terminal applications?

ghost commented 2 years ago

unless it's not wrapping and the line extends out of the visible screen/terminal

This

1 and 3 gifs show current behaviour, 2 and 4 desirable , in my opinion.

The start of line case

PowerShell 2022-06-16 18-52-43

PowerShell 2022-06-16 18-53-47

The middle/end of line case

PowerShell 2022-06-16 18-53-20

PowerShell 2022-06-16 18-54-04

dankox commented 2 years ago

Oh I see what you mean. Yeah, that's a problem. The first one is actually a bug. It should move to that location, but because it's updating the coordinates directly and not using MoveCursor it doesn't update view origin correctly.

The second one is a bit tricky though. I've created a quick fix for now, which you can test by getting gocui from here: https://github.com/dankox/gocui/tree/fix/move-cursor-when-no-wrap

It's working for me, but there is still one thing which I need to resolve and that is when the view's width is 1 character, it doesn't display correctly (or not the same way as before this fix). So I need to address that and then I will create PR. But if you would be able to confirm that this works for you, that would be great.