From e5e328dcc7998366a6b6cc54b31f42fe35d73592 Mon Sep 17 00:00:00 2001 From: chzyer <0@0xdf.com> Date: Thu, 31 Mar 2016 00:15:33 +0800 Subject: [PATCH] remove SplitByMultiLine --- runebuf.go | 10 ---------- utils.go | 23 ----------------------- 2 files changed, 33 deletions(-) diff --git a/runebuf.go b/runebuf.go index 579dae4..11d8491 100644 --- a/runebuf.go +++ b/runebuf.go @@ -30,17 +30,7 @@ type RuneBuffer struct { } func (r *RuneBuffer) OnWidthChange(newWidth int) { - oldWidth := r.width - if newWidth < oldWidth { - sp := SplitByMultiLine( - r.PromptLen(), oldWidth, newWidth, r.buf[:r.idx]) - idxLine := len(sp) - 1 - r.clean(idxLine) - } else { - r.Clean() - } r.width = newWidth - r.print() } func (r *RuneBuffer) Backup() { diff --git a/utils.go b/utils.go index 468ab9b..8ee2f8f 100644 --- a/utils.go +++ b/utils.go @@ -86,29 +86,6 @@ func escapeKey(r rune) rune { return r } -func SplitByMultiLine(start, oldWidth, newWidth int, rs []rune) []string { - var ret []string - buf := bytes.NewBuffer(nil) - currentWidth := start - for _, r := range rs { - w := runes.Width(r) - currentWidth += w - buf.WriteRune(r) - if currentWidth == newWidth { - ret = append(ret, buf.String()) - buf.Reset() - continue - } - if currentWidth >= oldWidth { - ret = append(ret, buf.String()) - buf.Reset() - currentWidth = 0 - } - } - ret = append(ret, buf.String()) - return ret -} - func SplitByLine(start, screenWidth int, rs []rune) []string { var ret []string buf := bytes.NewBuffer(nil)