wrap now also on right half

This commit is contained in:
Özgür Kesim 2015-07-28 17:48:14 +02:00
parent 3121760c3a
commit 1e0b98a116
2 changed files with 17 additions and 10 deletions

25
dict.go
View File

@ -80,23 +80,30 @@ func main() {
b := strings.Trim(left[i], `„"`)
a = re.ReplaceAllString(a, `$1`)
b = re.ReplaceAllString(b, `$1`)
if a == "" {
continue
}
if len(a) > ml {
for len(a) > ml {
if i := strings.LastIndex(a[:ml], " "); i > 0 {
fmt.Printf("%*s\n", ml, a[:i])
a = a[i:]
}
}
if len(b) > ml {
if i := strings.LastIndex(b[:ml], " "); i > 0 {
fmt.Printf("%*s\n", ml, a[:i])
a = a[i:]
} else {
break
}
}
// TODO: wrap when len(a) > ml
fmt.Printf("%*s → %s\n", ml, a, b)
fmt.Printf("%*s → ", ml, a)
for len(b) > ml {
if i := strings.LastIndex(b[:ml], " "); i > 0 {
fmt.Println(b[:i])
fmt.Printf("%*s ", ml, "")
b = b[i:]
} else {
break
}
}
fmt.Println(b)
}
}

View File

@ -23,5 +23,5 @@ func init() {
panic(errno)
}
Width = int(ws.Col)
Width = int(ws.Col) - 2
}