// StringStripper writes text stripped of colour formatting codes to a string.
// Use the String() method to return the printed string.
421981
func StringStripper() *StringPrinter {
	w := &bytes.Buffer{}
	f := Strip(w)
	return &StringPrinter{f, w}
}
343465
func Sprintf(str string, a ...interface{}) string {
	return fmt.Sprintf(Colorize(str, a...))
}
1364437
func (s *String) StringOr(or string) string {
	switch {
	case s == nil:
		return or
	case !s.Valid:
		return or
	default:
		return s.Chars
	}
}
171259
func StringSlicePos(slice []string, value string) int {
	for p, v := range slice {
		if v == value {
			return p
		}
	}
	return -1
}
1217535
func wrap(s string, indent int) string {
	if indent > 3 {
		indent = 3
	}

	wrapped := text.Wrap(s, maxLine)
	lines := strings.SplitN(wrapped, "\n", 2)
	if len(lines) == 1 {
		return lines[0]
	}

	if (maxLine - indentLen(indent)) <= 0 {
		panic("too much indentation")
	}

	rest := strings.Join(lines[1:], " ")
	wrapped = text.Wrap(rest, maxLine-indentLen(indent))
	return lines[0] + "\n" + text.Indent(wrapped, makeIndent(indent))
}
652186
func JoinStringers(a []fmt.Stringer, sep string) string {
	if len(a) == 0 {
		return ""
	}
	if len(a) == 1 {
		return a[0].String()
	}

	str := make([]string, len(a))
	for i, s := range a {
		str[i] = s.String()
	}

	return strings.Join(str, sep)
}
148149
func stripChart() {
	dumper := NewDumper("xstrip1", 2, 2, 400, 300)
	defer dumper.Close()

	c := chart.StripChart{}

	c.AddData("Sample A", data1, chart.Style{})
	c.AddData("Sample B", data2, chart.Style{})
	c.AddData("Sample C", data3, chart.Style{})
	c.Title = "Sample Strip Chart (no Jitter)"
	c.XRange.Label = "X - Axis"
	c.Key.Pos = "icr"
	dumper.Plot(&c)

	c.Jitter = true
	c.Title = "Sample Strip Chart (with Jitter)"
	dumper.Plot(&c)

	c.Key.Hide = true
	dumper.Plot(&c)

	c.Jitter = false
	c.Title = "Sample Strip Chart (no Jitter)"
	dumper.Plot(&c)
}
502169
func (mmap MarshalMap) StringSliceMap(key string) (map[string][]string, error) {
	return mmap.StringArrayMap(key)
}
618317
func StringSliceReverse(in []string) (out []string) {
	for i := len(in) - 1; i >= 0; i-- {
		out = append(out, in[i])
	}
	return
}
328915
func (t *Term) Println(prefix, str string) {
	if !t.dumb {
		terminalColorEscapeCode := fmt.Sprintf(terminalHighlightEscapeCode, t.conf.SourceListLineColor)
		prefix = fmt.Sprintf("%s%s%s", terminalColorEscapeCode, prefix, terminalResetEscapeCode)
	}
	fmt.Fprintf(t.stdout, "%s%s\n", prefix, str)
}
949856
func (w *Writer) WriteStringSlice(slice []string) {
	setWriterRef(w, nil, nil)
	count := len(slice)
	if count == 0 {
		writeEmptyList(w)
		return
	}
	writeListHeader(w, count)
	stringSliceEncoder(w, slice)
	writeListFooter(w)
}
796987
func NewTruecolorLolWriter() io.Writer {
	colorMode := ColorModeTrueColor
	if noColor {
		colorMode = ColorMode0
	}
	return &Writer{
		Output:    stdout,
		ColorMode: colorMode,
	}
}
732572
func (r *readlineUI) PrintErr(args ...interface{}) {
	text := fmt.Sprint(args...)
	if !strings.HasSuffix(text, "\n") {
		text += "\n"
	}
	if readline.IsTerminal(int(syscall.Stderr)) {
		text = colorize(text)
	}
	fmt.Fprint(r.rl.Stderr(), text)
}
1059297
func WrapString(s string, width int) string {
	if len(s) <= 1 {
		return s
	}

	// Output buffer. Does not include the most recent word.
	var buf bytes.Buffer
	// Trailing word.
	var word bytes.Buffer
	var wordLen int

	spaceLeft := width
	var prev rune

	for _, curr := range s {
		if curr == rune('\n') {
			// Received a newline.
			if word.Len() > spaceLeft {
				spaceLeft = width
				buf.WriteRune(curr)
			} else {
				spaceLeft = width
			}
			word.WriteTo(&buf)
			wordLen = 0
		} else if unicode.IsSpace(prev) && !unicode.IsSpace(curr) {
			// At the start of a new word.
			// Does the last word fit on this line, or the next?
			if wordLen > spaceLeft {
				spaceLeft = width - wordLen
				buf.WriteRune('\n')
			} else {
				spaceLeft -= wordLen
			}
			// fmt.Printf("42: writing %q with %d spaces remaining out of %d\n", word.String(), spaceLeft, width)
			word.WriteTo(&buf)
			wordLen = 0
		}
		word.WriteRune(curr)
		wordLen += runewidth.RuneWidth(curr)

		prev = curr
	}

	// Close out the final word.
	if wordLen > spaceLeft {
		buf.WriteRune('\n')
	}
	word.WriteTo(&buf)

	return buf.String()
}
477945
func colorString(code int, str string) string {
	return fmt.Sprintf("\x1b[%d;1m%s\x1b[39;22m", code, str)
}
203575
func StringPairs(m strpair.Map) []*pb.StringPair {
	ret := make([]*pb.StringPair, 0, len(m))
	for k, vs := range m {
		for _, v := range vs {
			ret = append(ret, &pb.StringPair{Key: k, Value: v})
		}
	}
	SortStringPairs(ret)
	return ret
}
397780
func string_lstrip(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
	if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
		return nil, err
	}
	return String(strings.TrimLeftFunc(string(recv.(String)), unicode.IsSpace)), nil
}