-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
212 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
language: go | ||
go: | ||
- '1.8' | ||
- '1.9' | ||
- '1.10' | ||
- '1.11' | ||
- '1.12' | ||
- master | ||
matrix: | ||
allow_failures: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build go1.10 | ||
|
||
package osc | ||
package term | ||
|
||
import ( | ||
"os" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package term | ||
|
||
import ( | ||
"bytes" | ||
"encoding/base64" | ||
"fmt" | ||
"io" | ||
"os" | ||
"sync" | ||
) | ||
|
||
func init() { | ||
if os.Getenv("TERM") == "screen" { | ||
ecsi = "\033Ptmux;\033" + ecsi | ||
st += "\033\\" | ||
} | ||
} | ||
|
||
// imageWriter is a writer that write into iTerm2 terminal the PNG data written | ||
type imageWriter struct { | ||
Name string | ||
Width int | ||
Height int | ||
|
||
once sync.Once | ||
b64enc io.WriteCloser | ||
buf *bytes.Buffer | ||
} | ||
|
||
func (w *imageWriter) init() { | ||
w.buf = &bytes.Buffer{} | ||
w.b64enc = base64.NewEncoder(base64.StdEncoding, w.buf) | ||
} | ||
|
||
// Write writes the PNG image data into the imageWriter buffer. | ||
func (w *imageWriter) Write(p []byte) (n int, err error) { | ||
w.once.Do(w.init) | ||
return w.b64enc.Write(p) | ||
} | ||
|
||
// 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;width=%dpx;height=%dpx;inline=1:%s%s", ecsi, w.Width, w.Height, w.buf.Bytes(), st) | ||
return w.b64enc.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build !go1.10 | ||
|
||
package osc | ||
package term | ||
|
||
import ( | ||
"os" | ||
|
Oops, something went wrong.