From 9f2bfa721303e41b0d724b8bd97dd8bf4a3798b9 Mon Sep 17 00:00:00 2001 From: "Roi Martin (@nibble_ds)" Date: Mon, 3 Feb 2014 02:04:30 +0100 Subject: [PATCH] Add View.Buffer() --- view.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/view.go b/view.go index db3c278..74cf2ca 100644 --- a/view.go +++ b/view.go @@ -241,6 +241,16 @@ func (v *View) addLine(y int) error { return nil } +// Buffer returns a string with the contents of the view's internal +// buffer +func (v *View) Buffer() string { + str := "" + for _, l := range v.lines { + str += string(l) + "\n" + } + return strings.Replace(str, "\x00", " ", -1) +} + // Line returns a string with the line of the view's internal buffer // at the position corresponding to the point (x, y). func (v *View) Line(y int) (string, error) {