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], `„"`) b := strings.Trim(left[i], `„"`)
a = re.ReplaceAllString(a, `$1`) a = re.ReplaceAllString(a, `$1`)
b = re.ReplaceAllString(b, `$1`) b = re.ReplaceAllString(b, `$1`)
if a == "" { if a == "" {
continue continue
} }
if len(a) > ml {
for len(a) > ml {
if i := strings.LastIndex(a[:ml], " "); i > 0 { if i := strings.LastIndex(a[:ml], " "); i > 0 {
fmt.Printf("%*s\n", ml, a[:i]) fmt.Printf("%*s\n", ml, a[:i])
a = a[i:] a = a[i:]
} } else {
} break
if len(b) > ml {
if i := strings.LastIndex(b[:ml], " "); i > 0 {
fmt.Printf("%*s\n", ml, a[:i])
a = a[i:]
} }
} }
// TODO: wrap when len(a) > ml fmt.Printf("%*s → ", ml, a)
fmt.Printf("%*s → %s\n", ml, a, b) 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) panic(errno)
} }
Width = int(ws.Col) Width = int(ws.Col) - 2
} }