From 2c42e54519afaa5426e9c389fa2ee911b0699baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 24 Nov 2015 17:24:43 +0200 Subject: Makefile: add support for iOS cross compilation --- .../src/github.com/nsf/termbox-go/README.md | 2 ++ .../src/github.com/nsf/termbox-go/api.go | 24 ++++++++----- .../src/github.com/nsf/termbox-go/api_windows.go | 4 +++ .../github.com/nsf/termbox-go/syscalls_darwin.go | 39 ++++++++++++++++++++++ .../nsf/termbox-go/syscalls_darwin_386.go | 39 ---------------------- .../src/github.com/nsf/termbox-go/termbox.go | 14 +++++--- .../github.com/nsf/termbox-go/termbox_windows.go | 4 +-- 7 files changed, 73 insertions(+), 53 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/nsf/termbox-go/syscalls_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/nsf/termbox-go/syscalls_darwin_386.go (limited to 'Godeps/_workspace') diff --git a/Godeps/_workspace/src/github.com/nsf/termbox-go/README.md b/Godeps/_workspace/src/github.com/nsf/termbox-go/README.md index 334d75102..5fc1874b1 100644 --- a/Godeps/_workspace/src/github.com/nsf/termbox-go/README.md +++ b/Godeps/_workspace/src/github.com/nsf/termbox-go/README.md @@ -16,6 +16,8 @@ There are also some interesting projects using termbox-go: - [httopd](https://github.com/verdverm/httopd) is top for httpd logs. - [mop](https://github.com/michaeldv/mop) is stock market tracker for hackers. - [termui](https://github.com/gizak/termui) is a terminal dashboard. + - [termloop](https://github.com/JoelOtter/termloop) is a terminal game engine. + - [xterm-color-chart](https://github.com/kutuluk/xterm-color-chart) is a XTerm 256 color chart. ### API reference [godoc.org/github.com/nsf/termbox-go](http://godoc.org/github.com/nsf/termbox-go) diff --git a/Godeps/_workspace/src/github.com/nsf/termbox-go/api.go b/Godeps/_workspace/src/github.com/nsf/termbox-go/api.go index b08bca61a..1e284060e 100644 --- a/Godeps/_workspace/src/github.com/nsf/termbox-go/api.go +++ b/Godeps/_workspace/src/github.com/nsf/termbox-go/api.go @@ -351,7 +351,7 @@ func PollEvent() Event { // terminal's window size in characters). But it doesn't always match the size // of the terminal window, after the terminal size has changed, the internal // back buffer will get in sync only after Clear or Flush function calls. -func Size() (int, int) { +func Size() (width int, height int) { return termw, termh } @@ -380,6 +380,12 @@ func SetInputMode(mode InputMode) InputMode { if mode == InputCurrent { return input_mode } + if mode&(InputEsc|InputAlt) == 0 { + mode |= InputEsc + } + if mode&(InputEsc|InputAlt) == InputEsc|InputAlt { + mode &^= InputAlt + } if mode&InputMouse != 0 { out.WriteString(funcs[t_enter_mouse]) } else { @@ -391,6 +397,7 @@ func SetInputMode(mode InputMode) InputMode { } // Sets the termbox output mode. Termbox has four output options: +// // 1. OutputNormal => [1..8] // This mode provides 8 different colors: // black, red, green, yellow, blue, magenta, cyan, white @@ -402,10 +409,10 @@ func SetInputMode(mode InputMode) InputMode { // // 2. Output256 => [1..256] // In this mode you can leverage the 256 terminal mode: -// 0x00 - 0x07: the 8 colors as in OutputNormal -// 0x08 - 0x0f: Color* | AttrBold -// 0x10 - 0xe7: 216 different colors -// 0xe8 - 0xff: 24 different shades of grey +// 0x01 - 0x08: the 8 colors as in OutputNormal +// 0x09 - 0x10: Color* | AttrBold +// 0x11 - 0xe8: 216 different colors +// 0xe9 - 0x1ff: 24 different shades of grey // // Example usage: // SetCell(x, y, '@', 184, 240); @@ -415,11 +422,12 @@ func SetInputMode(mode InputMode) InputMode { // This mode supports the 3rd range of the 256 mode only. // But you dont need to provide an offset. // -// 4. OutputGrayscale => [1..24] -// This mode supports the 4th range of the 256 mode only. +// 4. OutputGrayscale => [1..26] +// This mode supports the 4th range of the 256 mode +// and black and white colors from 3th range of the 256 mode // But you dont need to provide an offset. // -// In all modes, 0 represents the default color. +// In all modes, 0x00 represents the default color. // // `go run _demos/output.go` to see its impact on your terminal. // diff --git a/Godeps/_workspace/src/github.com/nsf/termbox-go/api_windows.go b/Godeps/_workspace/src/github.com/nsf/termbox-go/api_windows.go index 78d954b36..203544bbf 100644 --- a/Godeps/_workspace/src/github.com/nsf/termbox-go/api_windows.go +++ b/Godeps/_workspace/src/github.com/nsf/termbox-go/api_windows.go @@ -80,6 +80,10 @@ func Close() { // stop event producer cancel_comm <- true set_event(interrupt) + select { + case <-input_comm: + default: + } <-cancel_done_comm set_console_cursor_info(out, &orig_cursor_info) diff --git a/Godeps/_workspace/src/github.com/nsf/termbox-go/syscalls_darwin.go b/Godeps/_workspace/src/github.com/nsf/termbox-go/syscalls_darwin.go new file mode 100644 index 000000000..e03624ebc --- /dev/null +++ b/Godeps/_workspace/src/github.com/nsf/termbox-go/syscalls_darwin.go @@ -0,0 +1,39 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs syscalls.go + +package termbox + +type syscall_Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed uint32 + Ospeed uint32 +} + +const ( + syscall_IGNBRK = 0x1 + syscall_BRKINT = 0x2 + syscall_PARMRK = 0x8 + syscall_ISTRIP = 0x20 + syscall_INLCR = 0x40 + syscall_IGNCR = 0x80 + syscall_ICRNL = 0x100 + syscall_IXON = 0x200 + syscall_OPOST = 0x1 + syscall_ECHO = 0x8 + syscall_ECHONL = 0x10 + syscall_ICANON = 0x100 + syscall_ISIG = 0x80 + syscall_IEXTEN = 0x400 + syscall_CSIZE = 0x300 + syscall_PARENB = 0x1000 + syscall_CS8 = 0x300 + syscall_VMIN = 0x10 + syscall_VTIME = 0x11 + + syscall_TCGETS = 0x402c7413 + syscall_TCSETS = 0x802c7414 +) diff --git a/Godeps/_workspace/src/github.com/nsf/termbox-go/syscalls_darwin_386.go b/Godeps/_workspace/src/github.com/nsf/termbox-go/syscalls_darwin_386.go deleted file mode 100644 index e03624ebc..000000000 --- a/Godeps/_workspace/src/github.com/nsf/termbox-go/syscalls_darwin_386.go +++ /dev/null @@ -1,39 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs syscalls.go - -package termbox - -type syscall_Termios struct { - Iflag uint32 - Oflag uint32 - Cflag uint32 - Lflag uint32 - Cc [20]uint8 - Ispeed uint32 - Ospeed uint32 -} - -const ( - syscall_IGNBRK = 0x1 - syscall_BRKINT = 0x2 - syscall_PARMRK = 0x8 - syscall_ISTRIP = 0x20 - syscall_INLCR = 0x40 - syscall_IGNCR = 0x80 - syscall_ICRNL = 0x100 - syscall_IXON = 0x200 - syscall_OPOST = 0x1 - syscall_ECHO = 0x8 - syscall_ECHONL = 0x10 - syscall_ICANON = 0x100 - syscall_ISIG = 0x80 - syscall_IEXTEN = 0x400 - syscall_CSIZE = 0x300 - syscall_PARENB = 0x1000 - syscall_CS8 = 0x300 - syscall_VMIN = 0x10 - syscall_VTIME = 0x11 - - syscall_TCGETS = 0x402c7413 - syscall_TCSETS = 0x802c7414 -) diff --git a/Godeps/_workspace/src/github.com/nsf/termbox-go/termbox.go b/Godeps/_workspace/src/github.com/nsf/termbox-go/termbox.go index 0aee8aca9..f754880d2 100644 --- a/Godeps/_workspace/src/github.com/nsf/termbox-go/termbox.go +++ b/Godeps/_workspace/src/github.com/nsf/termbox-go/termbox.go @@ -72,6 +72,12 @@ var ( input_comm = make(chan input_event) interrupt_comm = make(chan struct{}) intbuf = make([]byte, 0, 16) + + // grayscale indexes + grayscale = []Attribute{ + 0, 17, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, + 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 232, + } ) func write_cursor(x, y int) { @@ -171,17 +177,17 @@ func send_attr(fg, bg Attribute) { case OutputGrayscale: fgcol = fg & 0x1F bgcol = bg & 0x1F - if fgcol > 24 { + if fgcol > 26 { fgcol = ColorDefault } - if bgcol > 24 { + if bgcol > 26 { bgcol = ColorDefault } if fgcol != ColorDefault { - fgcol += 0xe8 + fgcol = grayscale[fgcol] } if bgcol != ColorDefault { - bgcol += 0xe8 + bgcol = grayscale[bgcol] } default: fgcol = fg & 0x0F diff --git a/Godeps/_workspace/src/github.com/nsf/termbox-go/termbox_windows.go b/Godeps/_workspace/src/github.com/nsf/termbox-go/termbox_windows.go index 17d1bdc84..f345d0eb0 100644 --- a/Godeps/_workspace/src/github.com/nsf/termbox-go/termbox_windows.go +++ b/Godeps/_workspace/src/github.com/nsf/termbox-go/termbox_windows.go @@ -129,7 +129,7 @@ func create_console_screen_buffer() (h syscall.Handle, err error) { err = syscall.EINVAL } } - return syscall.Handle(r0), nil + return syscall.Handle(r0), err } func get_console_screen_buffer_info(h syscall.Handle, info *console_screen_buffer_info) (err error) { @@ -305,7 +305,7 @@ func create_event() (out syscall.Handle, err error) { err = syscall.EINVAL } } - return syscall.Handle(r0), nil + return syscall.Handle(r0), err } func wait_for_multiple_objects(objects []syscall.Handle) (err error) { -- cgit v1.2.3