peterh / liner

Pure Go line editor with history, inspired by linenoise
MIT License
1.04k stars 132 forks source link

Full width characters do not work correctly #42

Closed jnjackins closed 9 years ago

jnjackins commented 9 years ago

Input: enter こんにちは after a call to Prompt, then arrow left and right.

Expected behaviour: the cursor moves by the full width of the character it is moving over.

Actual behavior: the cursor moves by a half character width.

peterh commented 9 years ago

I'm not familiar with that language. I can copy-and-paste those glyphs and observe that they are, in fact, twice the width of an ASCII character (on some platforms), but I lack the domain knowledge to fix this myself. I welcome a pull request, if you are up to it.

(Aside: What part of "Fixed Width" do font designers not understand? Sigh.) (Aside: On windows, I just get single (or what you call "half") width "character not found" glyphs, but that's probably a font configuration issue on my machine) (Speaking of "character not found", in xterm � \uFFFD is single width, but in GNOME Terminal on my machine it is double width. So it's not trivial to solve in general)

jnjackins commented 9 years ago

I agree it's not trivial, but it might be simple enough to fix for 95% of cases (namely Korean, Japanese Chinese). I'm looking into it.