textutil.go
func Ellipsize(str string, maxWidth int) string {
	ln := xs.Len(str)
	if ln <= maxWidth {
		return str
	}

	if maxWidth < 5 {
		return xs.Slice(str, 0, maxWidth)
	}

	left := int((maxWidth - 3) / 2)
	right := maxWidth - left - 3
	return xs.Slice(str, 0, left) + "..." + xs.Slice(str, ln-right, -1)
}
func Ellipsize(str string, maxWidth int) string {
	ln := xs.Len(str)
	if ln <= maxWidth {
		return str
	}

	if maxWidth < 5 {
		return xs.Slice(str, 0, maxWidth)
	}

	left := int((maxWidth - 3) / 2)
	right := maxWidth - left - 3
	return xs.Slice(str, 0, left) + "..." + xs.Slice(str, ln-right, -1)
}
func Ellipsize ( str string , maxWidth int ) string { ln := xs . Len ( str ) if ln <= maxWidth { return str } if maxWidth < 5 { return xs . Slice ( str , 0 , maxWidth ) } left := int ( ( maxWidth - 3 ) / 2 ) right := maxWidth - left - 3 return xs . Slice ( str , 0 , left ) + " " + xs . Slice ( str , ln - right , - 1 ) }
// Ellipsize truncates text to maxWidth by replacing a
// substring in the middle with ellipsis and keeping
// the beginning and ending of the string untouched.
// If maxWidth is less than 5 then no ellipsis is
// added, the text is just truncated from the right.
Ellipsize truncates text to maxWidth by replacing a substring in the middle with ellipsis and keeping the beginning and ending of the string untouched . If maxWidth is less than 5 then no ellipsis is added the text is just truncated from the right .