Skip to content

Commit a377a0d

Browse files
committed
Fix iTerm 3.1.6+ compat (fixes #8)
1 parent 3b60ff4 commit a377a0d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ func render(dash graph.Dash, rows int) {
149149
rows = size.Row
150150
}
151151
// Use iTerm2 image display feature.
152-
term := &osc.ImageWriter{}
152+
term := &osc.ImageWriter{
153+
Width: width,
154+
Height: height,
155+
}
153156
defer term.Close()
154157
if err := dash.Render(term, width, height); err != nil {
155158
fatal(fmt.Sprintf("cannot render graph: %v", err.Error()))

osc/iterm2.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ func Rows() (rows int, err error) {
7474
// ImageWriter is a writer that write into iTerm2 terminal the PNG data written
7575
// to it.
7676
type ImageWriter struct {
77-
Name string
77+
Name string
78+
Width int
79+
Height int
7880

7981
once sync.Once
8082
b66enc io.WriteCloser
@@ -95,6 +97,6 @@ func (w *ImageWriter) Write(p []byte) (n int, err error) {
9597
// Close flushes the image to the terminal and close the writer.
9698
func (w *ImageWriter) Close() error {
9799
w.once.Do(w.init)
98-
fmt.Printf("%s1337;File=preserveAspectRatio=1;inline=1:%s%s", ecsi, w.buf.Bytes(), st)
100+
fmt.Printf("%s1337;File=preserveAspectRatio=1;width=%dpx;height=%dpx;inline=1:%s%s", ecsi, w.Width, w.Height, w.buf.Bytes(), st)
99101
return w.b66enc.Close()
100102
}

0 commit comments

Comments
 (0)