1
0
mirror of https://github.com/gdamore/tcell.git synced 2025-04-24 13:48:51 +08:00

fixes #75 Add goreport and fix related issues (a couple more)

This commit is contained in:
Garrett D'Amore 2015-11-04 17:29:11 -08:00
parent 43f9cc0d07
commit f763a5b1b7
3 changed files with 52 additions and 67 deletions

View File

@ -28,13 +28,13 @@ import (
var row = 0
var style = tcell.StyleDefault
func Putln(s tcell.Screen, str string) {
func putln(s tcell.Screen, str string) {
Puts(s, style, 1, row, str)
puts(s, style, 1, row, str)
row++
}
func Puts(s tcell.Screen, style tcell.Style, x, y int, str string) {
func puts(s tcell.Screen, style tcell.Style, x, y int, str string) {
i := 0
var deferred []rune
dwidth := 0
@ -94,52 +94,52 @@ func main() {
quit := make(chan struct{})
style = bold
Putln(s, "Press ESC to Exit")
Putln(s, "Character set: "+s.CharacterSet())
putln(s, "Press ESC to Exit")
putln(s, "Character set: "+s.CharacterSet())
style = plain
Putln(s, "English: October")
Putln(s, "Icelandic: október")
Putln(s, "Arabic: أكتوبر")
Putln(s, "Russian: октября")
Putln(s, "Greek: Οκτωβρίου")
Putln(s, "Chinese: 十月 (note, two double wide characters)")
Putln(s, "Combining: A\u030a (should look like Angstrom)")
Putln(s, "Emoticon: \U0001f618 (blowing a kiss)")
Putln(s, "Airplane: \u2708 (fly away)")
Putln(s, "Command: \u2318 (mac clover key)")
Putln(s, "Enclose: !\u20e3 (should be enclosed exclamation)")
Putln(s, "")
Putln(s, "Box:")
Putln(s, string([]rune{
putln(s, "English: October")
putln(s, "Icelandic: október")
putln(s, "Arabic: أكتوبر")
putln(s, "Russian: октября")
putln(s, "Greek: Οκτωβρίου")
putln(s, "Chinese: 十月 (note, two double wide characters)")
putln(s, "Combining: A\u030a (should look like Angstrom)")
putln(s, "Emoticon: \U0001f618 (blowing a kiss)")
putln(s, "Airplane: \u2708 (fly away)")
putln(s, "Command: \u2318 (mac clover key)")
putln(s, "Enclose: !\u20e3 (should be enclosed exclamation)")
putln(s, "")
putln(s, "Box:")
putln(s, string([]rune{
tcell.RuneULCorner,
tcell.RuneHLine,
tcell.RuneTTee,
tcell.RuneHLine,
tcell.RuneURCorner,
}))
Putln(s, string([]rune{
putln(s, string([]rune{
tcell.RuneVLine,
tcell.RuneBullet,
tcell.RuneVLine,
tcell.RuneLantern,
tcell.RuneVLine,
})+" (bullet, lantern/section)")
Putln(s, string([]rune{
putln(s, string([]rune{
tcell.RuneLTee,
tcell.RuneHLine,
tcell.RunePlus,
tcell.RuneHLine,
tcell.RuneRTee,
}))
Putln(s, string([]rune{
putln(s, string([]rune{
tcell.RuneVLine,
tcell.RuneDiamond,
tcell.RuneVLine,
tcell.RuneUArrow,
tcell.RuneVLine,
})+" (diamond, up arrow)")
Putln(s, string([]rune{
putln(s, string([]rune{
tcell.RuneLLCorner,
tcell.RuneHLine,
tcell.RuneBTee,

View File

@ -125,17 +125,17 @@ func (s *cScreen) Init() error {
s.evch = make(chan Event, 10)
s.quit = make(chan struct{})
if in, e := syscall.Open("CONIN$", syscall.O_RDWR, 0); e != nil {
in, e := syscall.Open("CONIN$", syscall.O_RDWR, 0)
if e != nil {
return e
} else {
s.in = in
}
if out, e := syscall.Open("CONOUT$", syscall.O_RDWR, 0); e != nil {
s.in = in
out, e := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
if e != nil {
syscall.Close(s.in)
return e
} else {
s.out = out
}
s.out = out
s.Lock()

View File

@ -83,50 +83,35 @@ const (
AttrReverse
)
func fixColor(c tcell.Color) tcell.Color {
if c == tcell.ColorDefault {
return c
}
switch outMode {
case OutputNormal:
c %= tcell.Color(16)
case Output256:
c %= tcell.Color(256)
case Output216:
c %= tcell.Color(216)
c += tcell.Color(16)
case OutputGrayscale:
c %= tcell.Color(24)
c += tcell.Color(232)
default:
c = tcell.ColorDefault
}
return c
}
func mkStyle(fg, bg Attribute) tcell.Style {
st := tcell.StyleDefault
f := tcell.Color(int(fg)&0x1ff) - 1
b := tcell.Color(int(bg)&0x1ff) - 1
switch outMode {
case Output256:
if f != tcell.ColorDefault {
f %= tcell.Color(256)
}
if b != tcell.ColorDefault {
b %= tcell.Color(256)
}
break
case Output216:
if f != tcell.ColorDefault {
f %= tcell.Color(216)
f += tcell.Color(16)
}
if b != tcell.ColorDefault {
b %= tcell.Color(216)
b += tcell.Color(16)
}
case OutputGrayscale:
if f != tcell.ColorDefault {
f %= tcell.Color(24)
f += tcell.Color(232)
}
if b != tcell.ColorDefault {
b %= tcell.Color(24)
b += tcell.Color(232)
}
case OutputNormal:
if f != tcell.ColorDefault {
f %= tcell.Color(16)
}
if b != tcell.ColorDefault {
b %= tcell.Color(16)
}
default:
f = tcell.ColorDefault
b = tcell.ColorDefault
}
f = fixColor(f)
b = fixColor(b)
st = st.Foreground(f).Background(b)
if (fg|bg)&AttrBold != 0 {
st = st.Bold(true)