Source File
len.go
Belonging Package
github.com/reeflective/readline/internal/strutil
package strutilimport ()// FormatTabs replaces all '\t' occurrences in a string with 6 spaces each.func ( string) string {return strings.ReplaceAll(, "\t", " ")}// RealLength returns the real length of a string (the number of terminal// columns used to render the line, which may contain special graphemes).// Before computing the width, it replaces tabs with (4) spaces, and strips colors.func ( string) int {:= color.Strip():= strings.ReplaceAll(, "\t", " ")return uniseg.StringWidth()}// LineSpan computes the number of columns and lines that are needed for a given line,// accounting for any ANSI escapes/color codes, and tabulations replaced with 4 spaces.func ( []rune, , int) (, int) {:= term.GetWidth():= RealLength(string())+=:= /:= %// Empty lines are still considered a line.if != 0 {++}return ,}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |