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] Can not input multibyte properly #22

Open skanehira opened 5 years ago

skanehira commented 5 years ago

Describe the bug Put the cursor on the alphabet and input multi-byte it's not inserted correctly.

To Reproduce Steps to reproduce the behavior:

  1. run _example/demo.go
  2. input or paste multibyte like ゴリラ

Expected behavior Multi-byte can be inserted correctly.

Screenshots bug-gocui

Environment (please complete the following information):

Additional context If nothing there on cursor, it will be inserted correctly

mjarkk commented 5 years ago

This is also an issue in titles: https://github.com/jroimartin/gocui/issues/157 and https://github.com/jroimartin/gocui/issues/134

skanehira commented 5 years ago

When multi-byte inserted then width of string will checked byrunewidth.RuneWidth. It's seems like good work but I don't know cause this bug occured...

I'll read more code and fix this.

https://github.com/awesome-gocui/gocui/blob/master/edit.go#L61

glvr182 commented 5 years ago

See the following issue.

glvr182 commented 5 years ago

Also saw that termbox had an update, see this commit

dankox commented 4 years ago

Was checking this a bit yesterday. The problem is that cursor is moved by runewidth width, but only one cell is inserted (so the next character is placed after another character, not next to the just inserted one).

I might look into it later, after tcell, to see if there needs to be special handling done. When I moved by 1 cell, it seems it worked fine. But there is too much logic around it, so I'm not sure if I didn't miss something. Also I'm not sure which runes could display over the next one when they are 2+ length size. For the characters in this issue, it seems like they did not display over each other and could be in cells next to each other. Other approach would be to insert 1 more space cell.

mjarkk commented 4 years ago

I have re-written the complete text editor with also a fix for this if i can remember correctly here: https://github.com/awesome-gocui/gocui/pull/48
My idea was to merge that together with cell because it also changes some core things.

dankox commented 4 years ago

Oh cool, that looks good.