Fix multibyte-strings

On Windows 10, WriteConsoleOutputW break compatibility. When writing three
unicode characters, the character is displayed overlayed with 3 cells.
So this change insert spaces after the character for unicode characters.
上级 eeb6cd0a
......@@ -2,6 +2,8 @@ package termbox
import (
"syscall"
"github.com/mattn/go-runewidth"
)
// public API
......@@ -114,13 +116,23 @@ func Flush() error {
update_size_maybe()
prepare_diff_messages()
for _, diff := range diffbuf {
chars := []char_info{}
for _, char := range diff.chars {
chars = append(chars, char)
if runewidth.RuneWidth(rune(char.char)) > 1 {
chars = append(chars, char_info{
char: ' ',
attr: char.attr,
})
}
}
r := small_rect{
left: 0,
top: diff.pos,
right: term_size.x - 1,
bottom: diff.pos + diff.lines - 1,
}
write_console_output(out, diff.chars, r)
write_console_output(out, chars, r)
}
if !is_cursor_hidden(cursor_x, cursor_y) {
move_cursor(cursor_x, cursor_y)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册