From ebc557fb249cf4bb966e3db0bc1bedaee6e2512c Mon Sep 17 00:00:00 2001 From: Alex Levinson Date: Mon, 26 Feb 2018 22:02:41 -0800 Subject: [PATCH] fixing windows incompatibility --- compiler/compiler.go | 3 +-- compiler/printer.go | 13 +++++++++++++ compiler/printer_windows.go | 9 +++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 compiler/printer.go create mode 100644 compiler/printer_windows.go diff --git a/compiler/compiler.go b/compiler/compiler.go index 0c500ea..762353d 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -22,7 +22,6 @@ import ( "strings" "text/template" - "github.com/alecthomas/chroma/quick" "github.com/gen0cide/gscript/engine" "github.com/gen0cide/gscript/logging" "github.com/sirupsen/logrus" @@ -303,7 +302,7 @@ func (c *Compiler) writeSource() { newSource := c.LollerSkateDaStringz([]byte(c.Source)) newSourceB := fmt.Sprintf("%s\n\n%s\n", string(newSource), c.GenerateTangledHairs()) if c.OutputSource { - quick.Highlight(os.Stdout, newSourceB, "go", "terminal", "vim") + PrettyPrintSource(newSourceB) return } err := ioutil.WriteFile(filepath.Join(c.BuildDir, "main.go"), []byte(newSourceB), 0644) diff --git a/compiler/printer.go b/compiler/printer.go new file mode 100644 index 0000000..8632c25 --- /dev/null +++ b/compiler/printer.go @@ -0,0 +1,13 @@ +// +build !windows + +package compiler + +import ( + "os" + + "github.com/alecthomas/chroma/quick" +) + +func PrettyPrintSource(source string) { + quick.Highlight(os.Stdout, source, "go", "terminal", "vim") +} diff --git a/compiler/printer_windows.go b/compiler/printer_windows.go new file mode 100644 index 0000000..1c9ef40 --- /dev/null +++ b/compiler/printer_windows.go @@ -0,0 +1,9 @@ +// +build windows + +package compiler + +import "fmt" + +func PrettyPrintSource(source string) { + fmt.Println(source) +}