Example #1
0
func Substr(data string, visible text.RegionSet) string {
	b := bytes.NewBuffer(nil)
	for _, r := range visible.Regions() {
		b.WriteString(data[r.A:r.B])
	}
	return b.String()
}
Example #2
0
func getSelSubstrs(v *View, rs *text.RegionSet) []string {
	var add, s1 string
	s := make([]string, len(rs.Regions()))
	for i, r := range rs.Regions() {
		add = ""
		s1 = v.Buffer().Substr(r)
		if !v.Sel().HasNonEmpty() && !strings.HasSuffix(s1, "\n") {
			add = "\n"
		}
		s[i] = s1 + add
	}
	return s
}