diff --git a/dict.go b/dict.go index 20b109b..11ad959 100644 --- a/dict.go +++ b/dict.go @@ -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) } } diff --git a/winsize_linux.go b/winsize_linux.go index ebb9f67..462598a 100644 --- a/winsize_linux.go +++ b/winsize_linux.go @@ -23,5 +23,5 @@ func init() { panic(errno) } - Width = int(ws.Col) + Width = int(ws.Col) - 2 }