Skip to content

Commit f763a5b

Browse files
committed
fixes gdamore#75 Add goreport and fix related issues (a couple more)
1 parent 43f9cc0 commit f763a5b

File tree

3 files changed

+52
-67
lines changed

3 files changed

+52
-67
lines changed

_demos/unicode.go

+23-23
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import (
2828
var row = 0
2929
var style = tcell.StyleDefault
3030

31-
func Putln(s tcell.Screen, str string) {
31+
func putln(s tcell.Screen, str string) {
3232

33-
Puts(s, style, 1, row, str)
33+
puts(s, style, 1, row, str)
3434
row++
3535
}
3636

37-
func Puts(s tcell.Screen, style tcell.Style, x, y int, str string) {
37+
func puts(s tcell.Screen, style tcell.Style, x, y int, str string) {
3838
i := 0
3939
var deferred []rune
4040
dwidth := 0
@@ -94,52 +94,52 @@ func main() {
9494
quit := make(chan struct{})
9595

9696
style = bold
97-
Putln(s, "Press ESC to Exit")
98-
Putln(s, "Character set: "+s.CharacterSet())
97+
putln(s, "Press ESC to Exit")
98+
putln(s, "Character set: "+s.CharacterSet())
9999
style = plain
100100

101-
Putln(s, "English: October")
102-
Putln(s, "Icelandic: október")
103-
Putln(s, "Arabic: أكتوبر")
104-
Putln(s, "Russian: октября")
105-
Putln(s, "Greek: Οκτωβρίου")
106-
Putln(s, "Chinese: 十月 (note, two double wide characters)")
107-
Putln(s, "Combining: A\u030a (should look like Angstrom)")
108-
Putln(s, "Emoticon: \U0001f618 (blowing a kiss)")
109-
Putln(s, "Airplane: \u2708 (fly away)")
110-
Putln(s, "Command: \u2318 (mac clover key)")
111-
Putln(s, "Enclose: !\u20e3 (should be enclosed exclamation)")
112-
Putln(s, "")
113-
Putln(s, "Box:")
114-
Putln(s, string([]rune{
101+
putln(s, "English: October")
102+
putln(s, "Icelandic: október")
103+
putln(s, "Arabic: أكتوبر")
104+
putln(s, "Russian: октября")
105+
putln(s, "Greek: Οκτωβρίου")
106+
putln(s, "Chinese: 十月 (note, two double wide characters)")
107+
putln(s, "Combining: A\u030a (should look like Angstrom)")
108+
putln(s, "Emoticon: \U0001f618 (blowing a kiss)")
109+
putln(s, "Airplane: \u2708 (fly away)")
110+
putln(s, "Command: \u2318 (mac clover key)")
111+
putln(s, "Enclose: !\u20e3 (should be enclosed exclamation)")
112+
putln(s, "")
113+
putln(s, "Box:")
114+
putln(s, string([]rune{
115115
tcell.RuneULCorner,
116116
tcell.RuneHLine,
117117
tcell.RuneTTee,
118118
tcell.RuneHLine,
119119
tcell.RuneURCorner,
120120
}))
121-
Putln(s, string([]rune{
121+
putln(s, string([]rune{
122122
tcell.RuneVLine,
123123
tcell.RuneBullet,
124124
tcell.RuneVLine,
125125
tcell.RuneLantern,
126126
tcell.RuneVLine,
127127
})+" (bullet, lantern/section)")
128-
Putln(s, string([]rune{
128+
putln(s, string([]rune{
129129
tcell.RuneLTee,
130130
tcell.RuneHLine,
131131
tcell.RunePlus,
132132
tcell.RuneHLine,
133133
tcell.RuneRTee,
134134
}))
135-
Putln(s, string([]rune{
135+
putln(s, string([]rune{
136136
tcell.RuneVLine,
137137
tcell.RuneDiamond,
138138
tcell.RuneVLine,
139139
tcell.RuneUArrow,
140140
tcell.RuneVLine,
141141
})+" (diamond, up arrow)")
142-
Putln(s, string([]rune{
142+
putln(s, string([]rune{
143143
tcell.RuneLLCorner,
144144
tcell.RuneHLine,
145145
tcell.RuneBTee,

console_win.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ func (s *cScreen) Init() error {
125125
s.evch = make(chan Event, 10)
126126
s.quit = make(chan struct{})
127127

128-
if in, e := syscall.Open("CONIN$", syscall.O_RDWR, 0); e != nil {
128+
in, e := syscall.Open("CONIN$", syscall.O_RDWR, 0)
129+
if e != nil {
129130
return e
130-
} else {
131-
s.in = in
132131
}
133-
if out, e := syscall.Open("CONOUT$", syscall.O_RDWR, 0); e != nil {
132+
s.in = in
133+
out, e := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
134+
if e != nil {
134135
syscall.Close(s.in)
135136
return e
136-
} else {
137-
s.out = out
138137
}
138+
s.out = out
139139

140140
s.Lock()
141141

termbox/compat.go

+23-38
Original file line numberDiff line numberDiff line change
@@ -83,50 +83,35 @@ const (
8383
AttrReverse
8484
)
8585

86-
func mkStyle(fg, bg Attribute) tcell.Style {
87-
st := tcell.StyleDefault
88-
89-
f := tcell.Color(int(fg)&0x1ff) - 1
90-
b := tcell.Color(int(bg)&0x1ff) - 1
91-
86+
func fixColor(c tcell.Color) tcell.Color {
87+
if c == tcell.ColorDefault {
88+
return c
89+
}
9290
switch outMode {
91+
case OutputNormal:
92+
c %= tcell.Color(16)
9393
case Output256:
94-
if f != tcell.ColorDefault {
95-
f %= tcell.Color(256)
96-
}
97-
if b != tcell.ColorDefault {
98-
b %= tcell.Color(256)
99-
}
100-
break
94+
c %= tcell.Color(256)
10195
case Output216:
102-
if f != tcell.ColorDefault {
103-
f %= tcell.Color(216)
104-
f += tcell.Color(16)
105-
}
106-
if b != tcell.ColorDefault {
107-
b %= tcell.Color(216)
108-
b += tcell.Color(16)
109-
}
96+
c %= tcell.Color(216)
97+
c += tcell.Color(16)
11098
case OutputGrayscale:
111-
if f != tcell.ColorDefault {
112-
f %= tcell.Color(24)
113-
f += tcell.Color(232)
114-
}
115-
if b != tcell.ColorDefault {
116-
b %= tcell.Color(24)
117-
b += tcell.Color(232)
118-
}
119-
case OutputNormal:
120-
if f != tcell.ColorDefault {
121-
f %= tcell.Color(16)
122-
}
123-
if b != tcell.ColorDefault {
124-
b %= tcell.Color(16)
125-
}
99+
c %= tcell.Color(24)
100+
c += tcell.Color(232)
126101
default:
127-
f = tcell.ColorDefault
128-
b = tcell.ColorDefault
102+
c = tcell.ColorDefault
129103
}
104+
return c
105+
}
106+
107+
func mkStyle(fg, bg Attribute) tcell.Style {
108+
st := tcell.StyleDefault
109+
110+
f := tcell.Color(int(fg)&0x1ff) - 1
111+
b := tcell.Color(int(bg)&0x1ff) - 1
112+
113+
f = fixColor(f)
114+
b = fixColor(b)
130115
st = st.Foreground(f).Background(b)
131116
if (fg|bg)&AttrBold != 0 {
132117
st = st.Bold(true)

0 commit comments

Comments
 (0)