From 4a014d05f508005a4fc63b592e9a552f381cfd51 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 5 Oct 2015 01:27:55 -0700 Subject: [PATCH] fixes #23 Fifo overfull hang --- _demos/unicode.go | 5 ++-- encoding/all.go | 60 +++++++++++++++++++++++------------------------ tscreen.go | 8 +++++-- tscreen_win.go | 1 - 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/_demos/unicode.go b/_demos/unicode.go index 738c16f..ca1f0f8 100644 --- a/_demos/unicode.go +++ b/_demos/unicode.go @@ -70,7 +70,6 @@ func Puts(s tcell.Screen, style tcell.Style, x, y int, str string) { func main() { - s, e := tcell.NewScreen() if e != nil { fmt.Fprintf(os.Stderr, "%v\n", e) @@ -125,7 +124,7 @@ func main() { tcell.RuneVLine, tcell.RuneLantern, tcell.RuneVLine, - }) + " (bullet, lantern/section)") + })+" (bullet, lantern/section)") Putln(s, string([]rune{ tcell.RuneLTee, tcell.RuneHLine, @@ -139,7 +138,7 @@ func main() { tcell.RuneVLine, tcell.RuneUArrow, tcell.RuneVLine, - }) + " (diamond, up arrow)") + })+" (diamond, up arrow)") Putln(s, string([]rune{ tcell.RuneLLCorner, tcell.RuneHLine, diff --git a/encoding/all.go b/encoding/all.go index 6f39614..b2a38cb 100644 --- a/encoding/all.go +++ b/encoding/all.go @@ -27,7 +27,7 @@ import ( ) func Register() { - tcell.RegisterEncoding("ISO8859-1", charmap.ISO8859_15) // alias for now + tcell.RegisterEncoding("ISO8859-1", charmap.ISO8859_15) // alias for now tcell.RegisterEncoding("ISO8859-13", charmap.ISO8859_13) tcell.RegisterEncoding("ISO8859-14", charmap.ISO8859_14) tcell.RegisterEncoding("ISO8859-15", charmap.ISO8859_15) @@ -59,37 +59,37 @@ func Register() { // Common aliaess aliases := map[string]string{ - "8859-1": "ISO8859-1", - "ISO-8859-1": "ISO8859-1", - "8859-13": "ISO8859-13", - "ISO-8859-13": "ISO8859-13", - "8859-14": "ISO8859-14", - "ISO-8859-14": "ISO8859-14", - "8859-15": "ISO8859-15", - "ISO-8859-15": "ISO8859-15", - "8859-16": "ISO8859-16", - "ISO-8859-16": "ISO8859-16", - "8859-2": "ISO8859-2", - "ISO-8859-2": "ISO8859-2", - "8859-3": "ISO8859-3", - "ISO-8859-3": "ISO8859-3", - "8859-4": "ISO8859-4", - "ISO-8859-4": "ISO8859-4", - "8859-5": "ISO8859-5", - "ISO-8859-5": "ISO8859-5", - "8859-6": "ISO8859-6", - "ISO-8859-6": "ISO8859-6", - "8859-7": "ISO8859-7", - "ISO-8859-7": "ISO8859-7", - "8859-8": "ISO8859-8", - "ISO-8859-8": "ISO8859-8", + "8859-1": "ISO8859-1", + "ISO-8859-1": "ISO8859-1", + "8859-13": "ISO8859-13", + "ISO-8859-13": "ISO8859-13", + "8859-14": "ISO8859-14", + "ISO-8859-14": "ISO8859-14", + "8859-15": "ISO8859-15", + "ISO-8859-15": "ISO8859-15", + "8859-16": "ISO8859-16", + "ISO-8859-16": "ISO8859-16", + "8859-2": "ISO8859-2", + "ISO-8859-2": "ISO8859-2", + "8859-3": "ISO8859-3", + "ISO-8859-3": "ISO8859-3", + "8859-4": "ISO8859-4", + "ISO-8859-4": "ISO8859-4", + "8859-5": "ISO8859-5", + "ISO-8859-5": "ISO8859-5", + "8859-6": "ISO8859-6", + "ISO-8859-6": "ISO8859-6", + "8859-7": "ISO8859-7", + "ISO-8859-7": "ISO8859-7", + "8859-8": "ISO8859-8", + "ISO-8859-8": "ISO8859-8", - "SJIS": "Shift_JIS", - "eucJP": "EUC-JP", - "2022-JP": "ISO2022JP", - "ISO-2022-JP": "ISO2022JP", + "SJIS": "Shift_JIS", + "eucJP": "EUC-JP", + "2022-JP": "ISO2022JP", + "ISO-2022-JP": "ISO2022JP", - "eucKR": "EUC-KR", + "eucKR": "EUC-KR", } for n, v := range aliases { tcell.RegisterEncoding(n, tcell.GetEncoding(v)) diff --git a/tscreen.go b/tscreen.go index e9d75ff..f723d86 100644 --- a/tscreen.go +++ b/tscreen.go @@ -86,7 +86,7 @@ type tScreen struct { } func (t *tScreen) Init() error { - t.evch = make(chan Event, 2) + t.evch = make(chan Event, 10) t.indoneq = make(chan struct{}) t.charset = "UTF-8" @@ -597,7 +597,11 @@ func (t *tScreen) buildAcsMap() { } func (t *tScreen) PostEvent(ev Event) { - t.evch <- ev + select { + case t.evch <- ev: + default: + // drop the event on the floor + } } func (t *tScreen) postMouseEvent(x, y, btn int) { diff --git a/tscreen_win.go b/tscreen_win.go index e67c4a1..f285017 100644 --- a/tscreen_win.go +++ b/tscreen_win.go @@ -38,7 +38,6 @@ func (t *tScreen) getWinSize() (int, int, error) { return 0, 0, errors.New("no temrios on Windows") } - func (t *tScreen) getCharset() string { return "UTF-16LE" }