mirror of https://github.com/gizak/termui.git
Comments
This commit is contained in:
parent
20d8f73c36
commit
1e207d561b
3
utils.go
3
utils.go
|
@ -13,6 +13,7 @@ import (
|
||||||
wordwrap "github.com/mitchellh/go-wordwrap"
|
wordwrap "github.com/mitchellh/go-wordwrap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// InterfaceSlice takes an []interface{} represented as an interface{} and converts it
|
||||||
// https://stackoverflow.com/questions/12753805/type-converting-slices-of-interfaces-in-go
|
// https://stackoverflow.com/questions/12753805/type-converting-slices-of-interfaces-in-go
|
||||||
func InterfaceSlice(slice interface{}) []interface{} {
|
func InterfaceSlice(slice interface{}) []interface{} {
|
||||||
s := reflect.ValueOf(slice)
|
s := reflect.ValueOf(slice)
|
||||||
|
@ -43,6 +44,7 @@ func MinInt(x, y int) int {
|
||||||
return y
|
return y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TrimString trims a string to a max length and adds '…' to the end if it was trimmed.
|
||||||
func TrimString(s string, w int) string {
|
func TrimString(s string, w int) string {
|
||||||
if w <= 0 {
|
if w <= 0 {
|
||||||
return ""
|
return ""
|
||||||
|
@ -151,6 +153,7 @@ func MaxFloat64(x, y float64) float64 {
|
||||||
return y
|
return y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WrapCells takes []Cell and inserts Cells containing '\n' wherever a linebreak should go.
|
||||||
func WrapCells(cells []Cell, width uint) []Cell {
|
func WrapCells(cells []Cell, width uint) []Cell {
|
||||||
str := CellsToString(cells)
|
str := CellsToString(cells)
|
||||||
wrapped := wordwrap.WrapString(str, width)
|
wrapped := wordwrap.WrapString(str, width)
|
||||||
|
|
Loading…
Reference in New Issue