Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering of multi-byte strings #231

Merged
merged 1 commit into from
Jan 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions api_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,28 @@ func Interrupt() {
interrupt_comm <- struct{}{}
}

// https://docs.microsoft.com/en-us/windows/console/char-info-str
const (
common_lvb_leading_byte = 0x0100
common_lvb_trailing_byte = 0x0200
)

// Synchronizes the internal back buffer with the terminal.
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 {
char.attr |= common_lvb_leading_byte
chars = append(chars, char)
chars = append(chars, char_info{
char: ' ',
attr: char.attr,
char: char.char,
attr: char.attr | common_lvb_trailing_byte,
})
} else {
chars = append(chars, char)
}
}
r := small_rect{
Expand Down