From c172ba91228a8d4f5275f3e5a24e3462b906b2bc Mon Sep 17 00:00:00 2001 From: Sergey Grebenshchikov Date: Sat, 31 Mar 2018 19:03:23 +0200 Subject: Add full-escape canvas type --- pkg/draw/full.go | 4 +++- pkg/draw/full_escape.go | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 pkg/draw/full_escape.go (limited to 'pkg') diff --git a/pkg/draw/full.go b/pkg/draw/full.go index 6f234b0..dccdd9f 100644 --- a/pkg/draw/full.go +++ b/pkg/draw/full.go @@ -2,10 +2,12 @@ package draw var _ Pixels = &Full{} +const fullBlock = '█' + type Full struct{ *Buffer } func (b *Full) Size() Box { return b.Box } -func (b *Full) Set(y, x int) { b.Buffer.Set(y, x, '█') } +func (b *Full) Set(y, x int) { b.Buffer.Set(y, x, fullBlock) } func (b *Full) Clear() { b.Fill(' ') } diff --git a/pkg/draw/full_escape.go b/pkg/draw/full_escape.go new file mode 100644 index 0000000..e6a68de --- /dev/null +++ b/pkg/draw/full_escape.go @@ -0,0 +1,9 @@ +package draw + +import "strings" + +const invertedSpace = "\033[7m \033[27m" + +func FullEscape(full string) string { + return strings.Replace(full, string(fullBlock), invertedSpace, -1) +} -- cgit v1.2.3