[GH-ISSUE #324] Some characters cause weird behaviours during input and rendering #249

Closed
opened 2026-03-04 01:03:20 +03:00 by kerem · 1 comment
Owner

Originally created by @Bios-Marcel on GitHub (Jul 20, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/324

I just had someone sent in an app using tview. Every tview is displayed as a two-cell character, even though the actual TM is in one cell. Sometimes the second cell is a different color than the rest of the TextView and sometimes it copies the character above it.

I can't figure out when which situation occurs, but here are two screenshots:

copy letter above

empty box behind tm

The latter can be reproduced with:

package main

import "github.com/rivo/tview"

func main() {
	text := tview.NewTextView()
	text.SetText("Terminals are lovely\nAren't ™ they?")

	app := tview.NewApplication()
	app.SetRoot(text, true)
	app.Run()
}

I Also saw this happen with some other characters sometimes. And I tried this on multiple terminals, those being iTerm2(mac OS), termite(vte-based on linux) and alacritity(linux).

The same also happens when for example inputting into an InputField.

Originally created by @Bios-Marcel on GitHub (Jul 20, 2019). Original GitHub issue: https://github.com/rivo/tview/issues/324 I just had someone sent `™` in an app using tview. Every tview is displayed as a two-cell character, even though the actual `TM` is in one cell. Sometimes the second cell is a different color than the rest of the `TextView` and sometimes it copies the character above it. I can't figure out when which situation occurs, but here are two screenshots: ![copy letter above](https://user-images.githubusercontent.com/19377618/61580266-35166f80-ab10-11e9-8298-fe30d8d2d29c.png) ![empty box behind tm](https://user-images.githubusercontent.com/19377618/61580280-5b3c0f80-ab10-11e9-8d97-f51e86e138fe.png) The latter can be reproduced with: ```go package main import "github.com/rivo/tview" func main() { text := tview.NewTextView() text.SetText("Terminals are lovely\nAren't ™ they?") app := tview.NewApplication() app.SetRoot(text, true) app.Run() } ``` I Also saw this happen with some other characters sometimes. And I tried this on multiple terminals, those being iTerm2(mac OS), termite(vte-based on linux) and alacritity(linux). The same also happens when for example inputting into an `InputField`.
kerem closed this issue 2026-03-04 01:03:20 +03:00
Author
Owner

@rivo commented on GitHub (Jul 21, 2019):

Please check out #278. This is very likely a problem with the mattn/go-runewidth package.

package main

import (
	"fmt"

	runewidth "github.com/mattn/go-runewidth"
)

func main() {
	fmt.Println(runewidth.RuneWidth('™')) // Prints "2".
}

tcell also depends on this package so there there will probably artifacts as long as this is not fixed there. You could open an issue over at go-runewidth.

I'm thinking about implementing my own version of go-runewidth (there are multiple issues with it) but haven't gotten around to it yet.

<!-- gh-comment-id:513555073 --> @rivo commented on GitHub (Jul 21, 2019): Please check out #278. This is very likely a problem with the [mattn/go-runewidth](https://github.com/mattn/go-runewidth/) package. ```go package main import ( "fmt" runewidth "github.com/mattn/go-runewidth" ) func main() { fmt.Println(runewidth.RuneWidth('™')) // Prints "2". } ``` `tcell` also depends on this package so there there will probably artifacts as long as this is not fixed there. You could open an issue over at `go-runewidth`. I'm thinking about implementing my own version of `go-runewidth` (there are multiple issues with it) but haven't gotten around to it yet.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#249
No description provided.