aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/shiena
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/shiena')
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/.gitignore27
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/LICENSE21
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/README.md100
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor.go20
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor/main.go27
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_ansi.go17
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_test.go25
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows.go351
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows_test.go236
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/example_test.go24
-rw-r--r--Godeps/_workspace/src/github.com/shiena/ansicolor/export_test.go19
11 files changed, 0 insertions, 867 deletions
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/.gitignore b/Godeps/_workspace/src/github.com/shiena/ansicolor/.gitignore
deleted file mode 100644
index 69cec52c4..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/.gitignore
+++ /dev/null
@@ -1,27 +0,0 @@
-# Created by http://www.gitignore.io
-
-### Go ###
-# Compiled Object files, Static and Dynamic libs (Shared Objects)
-*.o
-*.a
-*.so
-
-# Folders
-_obj
-_test
-
-# Architecture specific extensions/prefixes
-*.[568vq]
-[568vq].out
-
-*.cgo1.go
-*.cgo2.c
-_cgo_defun.c
-_cgo_gotypes.go
-_cgo_export.*
-
-_testmain.go
-
-*.exe
-*.test
-
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/LICENSE b/Godeps/_workspace/src/github.com/shiena/ansicolor/LICENSE
deleted file mode 100644
index e58473ed9..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) [2014] [shiena]
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/README.md b/Godeps/_workspace/src/github.com/shiena/ansicolor/README.md
deleted file mode 100644
index 7797a4f18..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/README.md
+++ /dev/null
@@ -1,100 +0,0 @@
-[![GoDoc](https://godoc.org/github.com/shiena/ansicolor?status.svg)](https://godoc.org/github.com/shiena/ansicolor)
-
-# ansicolor
-
-Ansicolor library provides color console in Windows as ANSICON for Golang.
-
-## Features
-
-|Escape sequence|Text attributes|
-|---------------|----|
-|\x1b[0m|All attributes off(color at startup)|
-|\x1b[1m|Bold on(enable foreground intensity)|
-|\x1b[4m|Underline on|
-|\x1b[5m|Blink on(enable background intensity)|
-|\x1b[21m|Bold off(disable foreground intensity)|
-|\x1b[24m|Underline off|
-|\x1b[25m|Blink off(disable background intensity)|
-
-|Escape sequence|Foreground colors|
-|---------------|----|
-|\x1b[30m|Black|
-|\x1b[31m|Red|
-|\x1b[32m|Green|
-|\x1b[33m|Yellow|
-|\x1b[34m|Blue|
-|\x1b[35m|Magenta|
-|\x1b[36m|Cyan|
-|\x1b[37m|White|
-|\x1b[39m|Default(foreground color at startup)|
-|\x1b[90m|Light Gray|
-|\x1b[91m|Light Red|
-|\x1b[92m|Light Green|
-|\x1b[93m|Light Yellow|
-|\x1b[94m|Light Blue|
-|\x1b[95m|Light Magenta|
-|\x1b[96m|Light Cyan|
-|\x1b[97m|Light White|
-
-|Escape sequence|Background colors|
-|---------------|----|
-|\x1b[40m|Black|
-|\x1b[41m|Red|
-|\x1b[42m|Green|
-|\x1b[43m|Yellow|
-|\x1b[44m|Blue|
-|\x1b[45m|Magenta|
-|\x1b[46m|Cyan|
-|\x1b[47m|White|
-|\x1b[49m|Default(background color at startup)|
-|\x1b[100m|Light Gray|
-|\x1b[101m|Light Red|
-|\x1b[102m|Light Green|
-|\x1b[103m|Light Yellow|
-|\x1b[104m|Light Blue|
-|\x1b[105m|Light Magenta|
-|\x1b[106m|Light Cyan|
-|\x1b[107m|Light White|
-
-## Example
-
-```go
-package main
-
-import (
- "fmt"
- "os"
-
- "github.com/shiena/ansicolor"
-)
-
-func main() {
- w := ansicolor.NewAnsiColorWriter(os.Stdout)
- text := "%sforeground %sbold%s %sbackground%s\n"
- fmt.Fprintf(w, text, "\x1b[31m", "\x1b[1m", "\x1b[21m", "\x1b[41;32m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[32m", "\x1b[1m", "\x1b[21m", "\x1b[42;31m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[33m", "\x1b[1m", "\x1b[21m", "\x1b[43;34m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[34m", "\x1b[1m", "\x1b[21m", "\x1b[44;33m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[35m", "\x1b[1m", "\x1b[21m", "\x1b[45;36m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[36m", "\x1b[1m", "\x1b[21m", "\x1b[46;35m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[37m", "\x1b[1m", "\x1b[21m", "\x1b[47;30m", "\x1b[0m")
-}
-```
-
-![screenshot](https://gist.githubusercontent.com/shiena/a1bada24b525314a7d5e/raw/c763aa7cda6e4fefaccf831e2617adc40b6151c7/main.png)
-
-## See also:
-
-- https://github.com/daviddengcn/go-colortext
-- https://github.com/adoxa/ansicon
-- https://github.com/aslakhellesoy/wac
-- https://github.com/wsxiaoys/terminal
-
-## Contributing
-
-1. Fork it
-2. Create your feature branch (`git checkout -b my-new-feature`)
-3. Commit your changes (`git commit -am 'Add some feature'`)
-4. Push to the branch (`git push origin my-new-feature`)
-5. Create new Pull Request
-
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor.go b/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor.go
deleted file mode 100644
index d3ece8fc0..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2014 shiena Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package ansicolor provides color console in Windows as ANSICON.
-package ansicolor
-
-import "io"
-
-// NewAnsiColorWriter creates and initializes a new ansiColorWriter
-// using io.Writer w as its initial contents.
-// In the console of Windows, which change the foreground and background
-// colors of the text by the escape sequence.
-// In the console of other systems, which writes to w all text.
-func NewAnsiColorWriter(w io.Writer) io.Writer {
- if _, ok := w.(*ansiColorWriter); !ok {
- return &ansiColorWriter{w: w}
- }
- return w
-}
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor/main.go b/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor/main.go
deleted file mode 100644
index d86cfc0f3..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor/main.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 shiena Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-/*
-
-The ansicolor command colors a console text by ANSI escape sequence like wac.
-
- $ go get github.com/shiena/ansicolor/ansicolor
-
-See also:
- https://github.com/aslakhellesoy/wac
-
-*/
-package main
-
-import (
- "io"
- "os"
-
- "github.com/shiena/ansicolor"
-)
-
-func main() {
- w := ansicolor.NewAnsiColorWriter(os.Stdout)
- io.Copy(w, os.Stdin)
-}
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_ansi.go b/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_ansi.go
deleted file mode 100644
index 57b4633a7..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_ansi.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2014 shiena Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// +build !windows
-
-package ansicolor
-
-import "io"
-
-type ansiColorWriter struct {
- w io.Writer
-}
-
-func (cw *ansiColorWriter) Write(p []byte) (int, error) {
- return cw.w.Write(p)
-}
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_test.go b/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_test.go
deleted file mode 100644
index 4feeb1de6..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_test.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package ansicolor_test
-
-import (
- "bytes"
- "testing"
-
- "github.com/shiena/ansicolor"
-)
-
-func TestNewAnsiColor1(t *testing.T) {
- inner := bytes.NewBufferString("")
- w := ansicolor.NewAnsiColorWriter(inner)
- if w == inner {
- t.Errorf("Get %#v, want %#v", w, inner)
- }
-}
-
-func TestNewAnsiColor2(t *testing.T) {
- inner := bytes.NewBufferString("")
- w1 := ansicolor.NewAnsiColorWriter(inner)
- w2 := ansicolor.NewAnsiColorWriter(w1)
- if w1 != w2 {
- t.Errorf("Get %#v, want %#v", w1, w2)
- }
-}
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows.go b/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows.go
deleted file mode 100644
index d918ffe91..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows.go
+++ /dev/null
@@ -1,351 +0,0 @@
-// Copyright 2014 shiena Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// +build windows
-
-package ansicolor
-
-import (
- "bytes"
- "io"
- "strings"
- "syscall"
- "unsafe"
-)
-
-type csiState int
-
-const (
- outsideCsiCode csiState = iota
- firstCsiCode
- secondCsiCode
-)
-
-type ansiColorWriter struct {
- w io.Writer
- state csiState
- paramBuf bytes.Buffer
-}
-
-const (
- firstCsiChar byte = '\x1b'
- secondeCsiChar byte = '['
- separatorChar byte = ';'
- sgrCode byte = 'm'
-)
-
-const (
- foregroundBlue = uint16(0x0001)
- foregroundGreen = uint16(0x0002)
- foregroundRed = uint16(0x0004)
- foregroundIntensity = uint16(0x0008)
- backgroundBlue = uint16(0x0010)
- backgroundGreen = uint16(0x0020)
- backgroundRed = uint16(0x0040)
- backgroundIntensity = uint16(0x0080)
- underscore = uint16(0x8000)
-
- foregroundMask = foregroundBlue | foregroundGreen | foregroundRed | foregroundIntensity
- backgroundMask = backgroundBlue | backgroundGreen | backgroundRed | backgroundIntensity
-)
-
-const (
- ansiReset = "0"
- ansiIntensityOn = "1"
- ansiIntensityOff = "21"
- ansiUnderlineOn = "4"
- ansiUnderlineOff = "24"
- ansiBlinkOn = "5"
- ansiBlinkOff = "25"
-
- ansiForegroundBlack = "30"
- ansiForegroundRed = "31"
- ansiForegroundGreen = "32"
- ansiForegroundYellow = "33"
- ansiForegroundBlue = "34"
- ansiForegroundMagenta = "35"
- ansiForegroundCyan = "36"
- ansiForegroundWhite = "37"
- ansiForegroundDefault = "39"
-
- ansiBackgroundBlack = "40"
- ansiBackgroundRed = "41"
- ansiBackgroundGreen = "42"
- ansiBackgroundYellow = "43"
- ansiBackgroundBlue = "44"
- ansiBackgroundMagenta = "45"
- ansiBackgroundCyan = "46"
- ansiBackgroundWhite = "47"
- ansiBackgroundDefault = "49"
-
- ansiLightForegroundGray = "90"
- ansiLightForegroundRed = "91"
- ansiLightForegroundGreen = "92"
- ansiLightForegroundYellow = "93"
- ansiLightForegroundBlue = "94"
- ansiLightForegroundMagenta = "95"
- ansiLightForegroundCyan = "96"
- ansiLightForegroundWhite = "97"
-
- ansiLightBackgroundGray = "100"
- ansiLightBackgroundRed = "101"
- ansiLightBackgroundGreen = "102"
- ansiLightBackgroundYellow = "103"
- ansiLightBackgroundBlue = "104"
- ansiLightBackgroundMagenta = "105"
- ansiLightBackgroundCyan = "106"
- ansiLightBackgroundWhite = "107"
-)
-
-type drawType int
-
-const (
- foreground drawType = iota
- background
-)
-
-type winColor struct {
- code uint16
- drawType drawType
-}
-
-var colorMap = map[string]winColor{
- ansiForegroundBlack: {0, foreground},
- ansiForegroundRed: {foregroundRed, foreground},
- ansiForegroundGreen: {foregroundGreen, foreground},
- ansiForegroundYellow: {foregroundRed | foregroundGreen, foreground},
- ansiForegroundBlue: {foregroundBlue, foreground},
- ansiForegroundMagenta: {foregroundRed | foregroundBlue, foreground},
- ansiForegroundCyan: {foregroundGreen | foregroundBlue, foreground},
- ansiForegroundWhite: {foregroundRed | foregroundGreen | foregroundBlue, foreground},
- ansiForegroundDefault: {foregroundRed | foregroundGreen | foregroundBlue, foreground},
-
- ansiBackgroundBlack: {0, background},
- ansiBackgroundRed: {backgroundRed, background},
- ansiBackgroundGreen: {backgroundGreen, background},
- ansiBackgroundYellow: {backgroundRed | backgroundGreen, background},
- ansiBackgroundBlue: {backgroundBlue, background},
- ansiBackgroundMagenta: {backgroundRed | backgroundBlue, background},
- ansiBackgroundCyan: {backgroundGreen | backgroundBlue, background},
- ansiBackgroundWhite: {backgroundRed | backgroundGreen | backgroundBlue, background},
- ansiBackgroundDefault: {0, background},
-
- ansiLightForegroundGray: {foregroundIntensity, foreground},
- ansiLightForegroundRed: {foregroundIntensity | foregroundRed, foreground},
- ansiLightForegroundGreen: {foregroundIntensity | foregroundGreen, foreground},
- ansiLightForegroundYellow: {foregroundIntensity | foregroundRed | foregroundGreen, foreground},
- ansiLightForegroundBlue: {foregroundIntensity | foregroundBlue, foreground},
- ansiLightForegroundMagenta: {foregroundIntensity | foregroundRed | foregroundBlue, foreground},
- ansiLightForegroundCyan: {foregroundIntensity | foregroundGreen | foregroundBlue, foreground},
- ansiLightForegroundWhite: {foregroundIntensity | foregroundRed | foregroundGreen | foregroundBlue, foreground},
-
- ansiLightBackgroundGray: {backgroundIntensity, background},
- ansiLightBackgroundRed: {backgroundIntensity | backgroundRed, background},
- ansiLightBackgroundGreen: {backgroundIntensity | backgroundGreen, background},
- ansiLightBackgroundYellow: {backgroundIntensity | backgroundRed | backgroundGreen, background},
- ansiLightBackgroundBlue: {backgroundIntensity | backgroundBlue, background},
- ansiLightBackgroundMagenta: {backgroundIntensity | backgroundRed | backgroundBlue, background},
- ansiLightBackgroundCyan: {backgroundIntensity | backgroundGreen | backgroundBlue, background},
- ansiLightBackgroundWhite: {backgroundIntensity | backgroundRed | backgroundGreen | backgroundBlue, background},
-}
-
-var (
- kernel32 = syscall.NewLazyDLL("kernel32.dll")
- procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
- procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
- defaultAttr *textAttributes
-)
-
-func init() {
- screenInfo := getConsoleScreenBufferInfo(uintptr(syscall.Stdout))
- if screenInfo != nil {
- colorMap[ansiForegroundDefault] = winColor{
- screenInfo.WAttributes & (foregroundRed | foregroundGreen | foregroundBlue),
- foreground,
- }
- colorMap[ansiBackgroundDefault] = winColor{
- screenInfo.WAttributes & (backgroundRed | backgroundGreen | backgroundBlue),
- background,
- }
- defaultAttr = convertTextAttr(screenInfo.WAttributes)
- }
-}
-
-type coord struct {
- X, Y int16
-}
-
-type smallRect struct {
- Left, Top, Right, Bottom int16
-}
-
-type consoleScreenBufferInfo struct {
- DwSize coord
- DwCursorPosition coord
- WAttributes uint16
- SrWindow smallRect
- DwMaximumWindowSize coord
-}
-
-func getConsoleScreenBufferInfo(hConsoleOutput uintptr) *consoleScreenBufferInfo {
- var csbi consoleScreenBufferInfo
- ret, _, _ := procGetConsoleScreenBufferInfo.Call(
- hConsoleOutput,
- uintptr(unsafe.Pointer(&csbi)))
- if ret == 0 {
- return nil
- }
- return &csbi
-}
-
-func setConsoleTextAttribute(hConsoleOutput uintptr, wAttributes uint16) bool {
- ret, _, _ := procSetConsoleTextAttribute.Call(
- hConsoleOutput,
- uintptr(wAttributes))
- return ret != 0
-}
-
-type textAttributes struct {
- foregroundColor uint16
- backgroundColor uint16
- foregroundIntensity uint16
- backgroundIntensity uint16
- underscore uint16
- otherAttributes uint16
-}
-
-func convertTextAttr(winAttr uint16) *textAttributes {
- fgColor := winAttr & (foregroundRed | foregroundGreen | foregroundBlue)
- bgColor := winAttr & (backgroundRed | backgroundGreen | backgroundBlue)
- fgIntensity := winAttr & foregroundIntensity
- bgIntensity := winAttr & backgroundIntensity
- underline := winAttr & underscore
- otherAttributes := winAttr &^ (foregroundMask | backgroundMask | underscore)
- return &textAttributes{fgColor, bgColor, fgIntensity, bgIntensity, underline, otherAttributes}
-}
-
-func convertWinAttr(textAttr *textAttributes) uint16 {
- var winAttr uint16 = 0
- winAttr |= textAttr.foregroundColor
- winAttr |= textAttr.backgroundColor
- winAttr |= textAttr.foregroundIntensity
- winAttr |= textAttr.backgroundIntensity
- winAttr |= textAttr.underscore
- winAttr |= textAttr.otherAttributes
- return winAttr
-}
-
-func changeColor(param []byte) {
- if defaultAttr == nil {
- return
- }
-
- screenInfo := getConsoleScreenBufferInfo(uintptr(syscall.Stdout))
- if screenInfo == nil {
- return
- }
-
- winAttr := convertTextAttr(screenInfo.WAttributes)
- strParam := string(param)
- if len(strParam) <= 0 {
- strParam = "0"
- }
- csiParam := strings.Split(strParam, string(separatorChar))
- for _, p := range csiParam {
- c, ok := colorMap[p]
- switch {
- case !ok:
- switch p {
- case ansiReset:
- winAttr.foregroundColor = defaultAttr.foregroundColor
- winAttr.backgroundColor = defaultAttr.backgroundColor
- winAttr.foregroundIntensity = defaultAttr.foregroundIntensity
- winAttr.backgroundIntensity = defaultAttr.backgroundIntensity
- winAttr.underscore = 0
- winAttr.otherAttributes = 0
- case ansiIntensityOn:
- winAttr.foregroundIntensity = foregroundIntensity
- case ansiIntensityOff:
- winAttr.foregroundIntensity = 0
- case ansiUnderlineOn:
- winAttr.underscore = underscore
- case ansiUnderlineOff:
- winAttr.underscore = 0
- case ansiBlinkOn:
- winAttr.backgroundIntensity = backgroundIntensity
- case ansiBlinkOff:
- winAttr.backgroundIntensity = 0
- default:
- // unknown code
- }
- case c.drawType == foreground:
- winAttr.foregroundColor = c.code
- case c.drawType == background:
- winAttr.backgroundColor = c.code
- }
- }
- winTextAttribute := convertWinAttr(winAttr)
- setConsoleTextAttribute(uintptr(syscall.Stdout), winTextAttribute)
-}
-
-func parseEscapeSequence(command byte, param []byte) {
- switch command {
- case sgrCode:
- changeColor(param)
- }
-}
-
-func isParameterChar(b byte) bool {
- return ('0' <= b && b <= '9') || b == separatorChar
-}
-
-func (cw *ansiColorWriter) Write(p []byte) (int, error) {
- r, nw, nc, first, last := 0, 0, 0, 0, 0
- var err error
- for i, ch := range p {
- switch cw.state {
- case outsideCsiCode:
- if ch == firstCsiChar {
- nc++
- cw.state = firstCsiCode
- }
- case firstCsiCode:
- switch ch {
- case firstCsiChar:
- nc++
- break
- case secondeCsiChar:
- nc++
- cw.state = secondCsiCode
- last = i - 1
- default:
- cw.state = outsideCsiCode
- }
- case secondCsiCode:
- nc++
- if isParameterChar(ch) {
- cw.paramBuf.WriteByte(ch)
- } else {
- nw, err = cw.w.Write(p[first:last])
- r += nw
- if err != nil {
- return r, err
- }
- first = i + 1
- param := cw.paramBuf.Bytes()
- cw.paramBuf.Reset()
- parseEscapeSequence(ch, param)
- cw.state = outsideCsiCode
- }
- default:
- cw.state = outsideCsiCode
- }
- }
-
- if cw.state == outsideCsiCode {
- nw, err = cw.w.Write(p[first:len(p)])
- }
-
- return r + nw + nc, err
-}
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows_test.go b/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows_test.go
deleted file mode 100644
index 6c126d517..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows_test.go
+++ /dev/null
@@ -1,236 +0,0 @@
-// Copyright 2014 shiena Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// +build windows
-
-package ansicolor_test
-
-import (
- "bytes"
- "fmt"
- "syscall"
- "testing"
-
- "github.com/shiena/ansicolor"
- . "github.com/shiena/ansicolor"
-)
-
-func TestWritePlanText(t *testing.T) {
- inner := bytes.NewBufferString("")
- w := ansicolor.NewAnsiColorWriter(inner)
- expected := "plain text"
- fmt.Fprintf(w, expected)
- actual := inner.String()
- if actual != expected {
- t.Errorf("Get %s, want %s", actual, expected)
- }
-}
-
-func TestWriteParseText(t *testing.T) {
- inner := bytes.NewBufferString("")
- w := ansicolor.NewAnsiColorWriter(inner)
-
- inputTail := "\x1b[0mtail text"
- expectedTail := "tail text"
- fmt.Fprintf(w, inputTail)
- actualTail := inner.String()
- inner.Reset()
- if actualTail != expectedTail {
- t.Errorf("Get %s, want %s", actualTail, expectedTail)
- }
-
- inputHead := "head text\x1b[0m"
- expectedHead := "head text"
- fmt.Fprintf(w, inputHead)
- actualHead := inner.String()
- inner.Reset()
- if actualHead != expectedHead {
- t.Errorf("Get %s, want %s", actualHead, expectedHead)
- }
-
- inputBothEnds := "both ends \x1b[0m text"
- expectedBothEnds := "both ends text"
- fmt.Fprintf(w, inputBothEnds)
- actualBothEnds := inner.String()
- inner.Reset()
- if actualBothEnds != expectedBothEnds {
- t.Errorf("Get %s, want %s", actualBothEnds, expectedBothEnds)
- }
-
- inputManyEsc := "\x1b\x1b\x1b\x1b[0m many esc"
- expectedManyEsc := "\x1b\x1b\x1b many esc"
- fmt.Fprintf(w, inputManyEsc)
- actualManyEsc := inner.String()
- inner.Reset()
- if actualManyEsc != expectedManyEsc {
- t.Errorf("Get %s, want %s", actualManyEsc, expectedManyEsc)
- }
-
- expectedSplit := "split text"
- for _, ch := range "split \x1b[0m text" {
- fmt.Fprintf(w, string(ch))
- }
- actualSplit := inner.String()
- inner.Reset()
- if actualSplit != expectedSplit {
- t.Errorf("Get %s, want %s", actualSplit, expectedSplit)
- }
-}
-
-type screenNotFoundError struct {
- error
-}
-
-func writeAnsiColor(expectedText, colorCode string) (actualText string, actualAttributes uint16, err error) {
- inner := bytes.NewBufferString("")
- w := ansicolor.NewAnsiColorWriter(inner)
- fmt.Fprintf(w, "\x1b[%sm%s", colorCode, expectedText)
-
- actualText = inner.String()
- screenInfo := GetConsoleScreenBufferInfo(uintptr(syscall.Stdout))
- if screenInfo != nil {
- actualAttributes = screenInfo.WAttributes
- } else {
- err = &screenNotFoundError{}
- }
- return
-}
-
-type testParam struct {
- text string
- attributes uint16
- ansiColor string
-}
-
-func TestWriteAnsiColorText(t *testing.T) {
- screenInfo := GetConsoleScreenBufferInfo(uintptr(syscall.Stdout))
- if screenInfo == nil {
- t.Fatal("Could not get ConsoleScreenBufferInfo")
- }
- defer ChangeColor(screenInfo.WAttributes)
- defaultFgColor := screenInfo.WAttributes & uint16(0x0007)
- defaultBgColor := screenInfo.WAttributes & uint16(0x0070)
- defaultFgIntensity := screenInfo.WAttributes & uint16(0x0008)
- defaultBgIntensity := screenInfo.WAttributes & uint16(0x0080)
-
- fgParam := []testParam{
- {"foreground black ", uint16(0x0000 | 0x0000), "30"},
- {"foreground red ", uint16(0x0004 | 0x0000), "31"},
- {"foreground green ", uint16(0x0002 | 0x0000), "32"},
- {"foreground yellow ", uint16(0x0006 | 0x0000), "33"},
- {"foreground blue ", uint16(0x0001 | 0x0000), "34"},
- {"foreground magenta", uint16(0x0005 | 0x0000), "35"},
- {"foreground cyan ", uint16(0x0003 | 0x0000), "36"},
- {"foreground white ", uint16(0x0007 | 0x0000), "37"},
- {"foreground default", defaultFgColor | 0x0000, "39"},
- {"foreground light gray ", uint16(0x0000 | 0x0008 | 0x0000), "90"},
- {"foreground light red ", uint16(0x0004 | 0x0008 | 0x0000), "91"},
- {"foreground light green ", uint16(0x0002 | 0x0008 | 0x0000), "92"},
- {"foreground light yellow ", uint16(0x0006 | 0x0008 | 0x0000), "93"},
- {"foreground light blue ", uint16(0x0001 | 0x0008 | 0x0000), "94"},
- {"foreground light magenta", uint16(0x0005 | 0x0008 | 0x0000), "95"},
- {"foreground light cyan ", uint16(0x0003 | 0x0008 | 0x0000), "96"},
- {"foreground light white ", uint16(0x0007 | 0x0008 | 0x0000), "97"},
- }
-
- bgParam := []testParam{
- {"background black ", uint16(0x0007 | 0x0000), "40"},
- {"background red ", uint16(0x0007 | 0x0040), "41"},
- {"background green ", uint16(0x0007 | 0x0020), "42"},
- {"background yellow ", uint16(0x0007 | 0x0060), "43"},
- {"background blue ", uint16(0x0007 | 0x0010), "44"},
- {"background magenta", uint16(0x0007 | 0x0050), "45"},
- {"background cyan ", uint16(0x0007 | 0x0030), "46"},
- {"background white ", uint16(0x0007 | 0x0070), "47"},
- {"background default", uint16(0x0007) | defaultBgColor, "49"},
- {"background light gray ", uint16(0x0007 | 0x0000 | 0x0080), "100"},
- {"background light red ", uint16(0x0007 | 0x0040 | 0x0080), "101"},
- {"background light green ", uint16(0x0007 | 0x0020 | 0x0080), "102"},
- {"background light yellow ", uint16(0x0007 | 0x0060 | 0x0080), "103"},
- {"background light blue ", uint16(0x0007 | 0x0010 | 0x0080), "104"},
- {"background light magenta", uint16(0x0007 | 0x0050 | 0x0080), "105"},
- {"background light cyan ", uint16(0x0007 | 0x0030 | 0x0080), "106"},
- {"background light white ", uint16(0x0007 | 0x0070 | 0x0080), "107"},
- }
-
- resetParam := []testParam{
- {"all reset", defaultFgColor | defaultBgColor | defaultFgIntensity | defaultBgIntensity, "0"},
- {"all reset", defaultFgColor | defaultBgColor | defaultFgIntensity | defaultBgIntensity, ""},
- }
-
- boldParam := []testParam{
- {"bold on", uint16(0x0007 | 0x0008), "1"},
- {"bold off", uint16(0x0007), "21"},
- }
-
- underscoreParam := []testParam{
- {"underscore on", uint16(0x0007 | 0x8000), "4"},
- {"underscore off", uint16(0x0007), "24"},
- }
-
- blinkParam := []testParam{
- {"blink on", uint16(0x0007 | 0x0080), "5"},
- {"blink off", uint16(0x0007), "25"},
- }
-
- mixedParam := []testParam{
- {"both black, bold, underline, blink", uint16(0x0000 | 0x0000 | 0x0008 | 0x8000 | 0x0080), "30;40;1;4;5"},
- {"both red, bold, underline, blink", uint16(0x0004 | 0x0040 | 0x0008 | 0x8000 | 0x0080), "31;41;1;4;5"},
- {"both green, bold, underline, blink", uint16(0x0002 | 0x0020 | 0x0008 | 0x8000 | 0x0080), "32;42;1;4;5"},
- {"both yellow, bold, underline, blink", uint16(0x0006 | 0x0060 | 0x0008 | 0x8000 | 0x0080), "33;43;1;4;5"},
- {"both blue, bold, underline, blink", uint16(0x0001 | 0x0010 | 0x0008 | 0x8000 | 0x0080), "34;44;1;4;5"},
- {"both magenta, bold, underline, blink", uint16(0x0005 | 0x0050 | 0x0008 | 0x8000 | 0x0080), "35;45;1;4;5"},
- {"both cyan, bold, underline, blink", uint16(0x0003 | 0x0030 | 0x0008 | 0x8000 | 0x0080), "36;46;1;4;5"},
- {"both white, bold, underline, blink", uint16(0x0007 | 0x0070 | 0x0008 | 0x8000 | 0x0080), "37;47;1;4;5"},
- {"both default, bold, underline, blink", uint16(defaultFgColor | defaultBgColor | 0x0008 | 0x8000 | 0x0080), "39;49;1;4;5"},
- }
-
- assertTextAttribute := func(expectedText string, expectedAttributes uint16, ansiColor string) {
- actualText, actualAttributes, err := writeAnsiColor(expectedText, ansiColor)
- if actualText != expectedText {
- t.Errorf("Get %s, want %s", actualText, expectedText)
- }
- if err != nil {
- t.Fatal("Could not get ConsoleScreenBufferInfo")
- }
- if actualAttributes != expectedAttributes {
- t.Errorf("Text: %s, Get 0x%04x, want 0x%04x", expectedText, actualAttributes, expectedAttributes)
- }
- }
-
- for _, v := range fgParam {
- ResetColor()
- assertTextAttribute(v.text, v.attributes, v.ansiColor)
- }
-
- for _, v := range bgParam {
- ChangeColor(uint16(0x0070 | 0x0007))
- assertTextAttribute(v.text, v.attributes, v.ansiColor)
- }
-
- for _, v := range resetParam {
- ChangeColor(uint16(0x0000 | 0x0070 | 0x0008))
- assertTextAttribute(v.text, v.attributes, v.ansiColor)
- }
-
- ResetColor()
- for _, v := range boldParam {
- assertTextAttribute(v.text, v.attributes, v.ansiColor)
- }
-
- ResetColor()
- for _, v := range underscoreParam {
- assertTextAttribute(v.text, v.attributes, v.ansiColor)
- }
-
- ResetColor()
- for _, v := range blinkParam {
- assertTextAttribute(v.text, v.attributes, v.ansiColor)
- }
-
- for _, v := range mixedParam {
- ResetColor()
- assertTextAttribute(v.text, v.attributes, v.ansiColor)
- }
-}
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/example_test.go b/Godeps/_workspace/src/github.com/shiena/ansicolor/example_test.go
deleted file mode 100644
index f2ac67c17..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/example_test.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2014 shiena Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package ansicolor_test
-
-import (
- "fmt"
- "os"
-
- "github.com/shiena/ansicolor"
-)
-
-func ExampleNewAnsiColorWriter() {
- w := ansicolor.NewAnsiColorWriter(os.Stdout)
- text := "%sforeground %sbold%s %sbackground%s\n"
- fmt.Fprintf(w, text, "\x1b[31m", "\x1b[1m", "\x1b[21m", "\x1b[41;32m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[32m", "\x1b[1m", "\x1b[21m", "\x1b[42;31m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[33m", "\x1b[1m", "\x1b[21m", "\x1b[43;34m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[34m", "\x1b[1m", "\x1b[21m", "\x1b[44;33m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[35m", "\x1b[1m", "\x1b[21m", "\x1b[45;36m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[36m", "\x1b[1m", "\x1b[21m", "\x1b[46;35m", "\x1b[0m")
- fmt.Fprintf(w, text, "\x1b[37m", "\x1b[1m", "\x1b[21m", "\x1b[47;30m", "\x1b[0m")
-}
diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/export_test.go b/Godeps/_workspace/src/github.com/shiena/ansicolor/export_test.go
deleted file mode 100644
index 6d2f7c074..000000000
--- a/Godeps/_workspace/src/github.com/shiena/ansicolor/export_test.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2014 shiena Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// +build windows
-
-package ansicolor
-
-import "syscall"
-
-var GetConsoleScreenBufferInfo = getConsoleScreenBufferInfo
-
-func ChangeColor(color uint16) {
- setConsoleTextAttribute(uintptr(syscall.Stdout), color)
-}
-
-func ResetColor() {
- ChangeColor(uint16(0x0007))
-}