16 lines
287 B
Go
16 lines
287 B
Go
package glyph
|
|
|
|
import "github.com/mattn/go-runewidth"
|
|
|
|
// Width returns the terminal column width of a rune.
|
|
// Tabs use a fixed width of 8 columns.
|
|
// TODO: handle Unicode marks.
|
|
func Width(r rune) int {
|
|
switch r {
|
|
case '\t':
|
|
return 8
|
|
default:
|
|
return runewidth.RuneWidth(r)
|
|
}
|
|
}
|