diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-06-24 23:40:18 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-06-24 23:40:18 +0800 |
commit | 1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1 (patch) | |
tree | f7b957645b11bc19ecf7fb29baaa13530557af7a /Godeps/_workspace/src/github.com/gizak/termui/helper.go | |
parent | 92ef33d97a437dce2d7b55f06342de388d95f575 (diff) | |
download | go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar.gz go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar.zst go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.zip |
Godeps: remove mist remnants, add termui deps
Diffstat (limited to 'Godeps/_workspace/src/github.com/gizak/termui/helper.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/gizak/termui/helper.go | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/gizak/termui/helper.go b/Godeps/_workspace/src/github.com/gizak/termui/helper.go new file mode 100644 index 000000000..80d8a0278 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gizak/termui/helper.go @@ -0,0 +1,66 @@ +// Copyright 2015 Zack Guo <gizak@icloud.com>. All rights reserved. +// Use of this source code is governed by a MIT license that can +// be found in the LICENSE file. + +package termui + +import tm "github.com/nsf/termbox-go" +import rw "github.com/mattn/go-runewidth" + +/* ---------------Port from termbox-go --------------------- */ + +// Attribute is printable cell's color and style. +type Attribute uint16 + +const ( + ColorDefault Attribute = iota + ColorBlack + ColorRed + ColorGreen + ColorYellow + ColorBlue + ColorMagenta + ColorCyan + ColorWhite +) + +const NumberofColors = 8 //Have a constant that defines number of colors +const ( + AttrBold Attribute = 1 << (iota + 9) + AttrUnderline + AttrReverse +) + +var ( + dot = "…" + dotw = rw.StringWidth(dot) +) + +/* ----------------------- End ----------------------------- */ + +func toTmAttr(x Attribute) tm.Attribute { + return tm.Attribute(x) +} + +func str2runes(s string) []rune { + return []rune(s) +} + +func trimStr2Runes(s string, w int) []rune { + if w <= 0 { + return []rune{} + } + sw := rw.StringWidth(s) + if sw > w { + return []rune(rw.Truncate(s, w, dot)) + } + return str2runes(s) //[]rune(rw.Truncate(s, w, "")) +} + +func strWidth(s string) int { + return rw.StringWidth(s) +} + +func charWidth(ch rune) int { + return rw.RuneWidth(ch) +} |