From a377a0d79e88a5e9587c97763006dd6512e6fb3b Mon Sep 17 00:00:00 2001 From: Olivier Poitrey Date: Sat, 23 Jun 2018 13:15:55 -0700 Subject: [PATCH] Fix iTerm 3.1.6+ compat (fixes #8) --- main.go | 5 ++++- osc/iterm2.go | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index a70529a..7b10283 100644 --- a/main.go +++ b/main.go @@ -149,7 +149,10 @@ func render(dash graph.Dash, rows int) { rows = size.Row } // Use iTerm2 image display feature. - term := &osc.ImageWriter{} + term := &osc.ImageWriter{ + Width: width, + Height: height, + } defer term.Close() if err := dash.Render(term, width, height); err != nil { fatal(fmt.Sprintf("cannot render graph: %v", err.Error())) diff --git a/osc/iterm2.go b/osc/iterm2.go index 337df96..ab162ce 100644 --- a/osc/iterm2.go +++ b/osc/iterm2.go @@ -74,7 +74,9 @@ func Rows() (rows int, err error) { // ImageWriter is a writer that write into iTerm2 terminal the PNG data written // to it. type ImageWriter struct { - Name string + Name string + Width int + Height int once sync.Once b66enc io.WriteCloser @@ -95,6 +97,6 @@ func (w *ImageWriter) Write(p []byte) (n int, err error) { // Close flushes the image to the terminal and close the writer. func (w *ImageWriter) Close() error { w.once.Do(w.init) - fmt.Printf("%s1337;File=preserveAspectRatio=1;inline=1:%s%s", ecsi, w.buf.Bytes(), st) + fmt.Printf("%s1337;File=preserveAspectRatio=1;width=%dpx;height=%dpx;inline=1:%s%s", ecsi, w.Width, w.Height, w.buf.Bytes(), st) return w.b66enc.Close() }