aboutsummaryrefslogtreecommitdiffstats
path: root/log/term
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-20 23:39:36 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-23 18:00:02 +0800
commitec7f81f4bc11c6f8203ec1d3055c9a09a244ff43 (patch)
tree5ec75ddab7749a9d0c47a97d6f638b52e6ebc6bb /log/term
parent29fac7de448c85049a97cbec3dc0819122bd2cb0 (diff)
downloadgo-tangerine-ec7f81f4bc11c6f8203ec1d3055c9a09a244ff43.tar
go-tangerine-ec7f81f4bc11c6f8203ec1d3055c9a09a244ff43.tar.gz
go-tangerine-ec7f81f4bc11c6f8203ec1d3055c9a09a244ff43.tar.bz2
go-tangerine-ec7f81f4bc11c6f8203ec1d3055c9a09a244ff43.tar.lz
go-tangerine-ec7f81f4bc11c6f8203ec1d3055c9a09a244ff43.tar.xz
go-tangerine-ec7f81f4bc11c6f8203ec1d3055c9a09a244ff43.tar.zst
go-tangerine-ec7f81f4bc11c6f8203ec1d3055c9a09a244ff43.zip
log, vendor: vendor in log15 inline into our codebase
Diffstat (limited to 'log/term')
-rw-r--r--log/term/LICENSE21
-rw-r--r--log/term/terminal_appengine.go13
-rw-r--r--log/term/terminal_darwin.go13
-rw-r--r--log/term/terminal_freebsd.go18
-rw-r--r--log/term/terminal_linux.go14
-rw-r--r--log/term/terminal_netbsd.go7
-rw-r--r--log/term/terminal_notwindows.go20
-rw-r--r--log/term/terminal_openbsd.go7
-rw-r--r--log/term/terminal_solaris.go9
-rw-r--r--log/term/terminal_windows.go26
10 files changed, 148 insertions, 0 deletions
diff --git a/log/term/LICENSE b/log/term/LICENSE
new file mode 100644
index 000000000..f090cb42f
--- /dev/null
+++ b/log/term/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Simon Eskildsen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/log/term/terminal_appengine.go b/log/term/terminal_appengine.go
new file mode 100644
index 000000000..c1b5d2a3b
--- /dev/null
+++ b/log/term/terminal_appengine.go
@@ -0,0 +1,13 @@
+// Based on ssh/terminal:
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build appengine
+
+package term
+
+// IsTty always returns false on AppEngine.
+func IsTty(fd uintptr) bool {
+ return false
+}
diff --git a/log/term/terminal_darwin.go b/log/term/terminal_darwin.go
new file mode 100644
index 000000000..d8f351b1b
--- /dev/null
+++ b/log/term/terminal_darwin.go
@@ -0,0 +1,13 @@
+// Based on ssh/terminal:
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+// +build !appengine
+
+package term
+
+import "syscall"
+
+const ioctlReadTermios = syscall.TIOCGETA
+
+type Termios syscall.Termios
diff --git a/log/term/terminal_freebsd.go b/log/term/terminal_freebsd.go
new file mode 100644
index 000000000..cfaceab33
--- /dev/null
+++ b/log/term/terminal_freebsd.go
@@ -0,0 +1,18 @@
+package term
+
+import (
+ "syscall"
+)
+
+const ioctlReadTermios = syscall.TIOCGETA
+
+// Go 1.2 doesn't include Termios for FreeBSD. This should be added in 1.3 and this could be merged with terminal_darwin.
+type Termios struct {
+ Iflag uint32
+ Oflag uint32
+ Cflag uint32
+ Lflag uint32
+ Cc [20]uint8
+ Ispeed uint32
+ Ospeed uint32
+}
diff --git a/log/term/terminal_linux.go b/log/term/terminal_linux.go
new file mode 100644
index 000000000..5290468d6
--- /dev/null
+++ b/log/term/terminal_linux.go
@@ -0,0 +1,14 @@
+// Based on ssh/terminal:
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !appengine
+
+package term
+
+import "syscall"
+
+const ioctlReadTermios = syscall.TCGETS
+
+type Termios syscall.Termios
diff --git a/log/term/terminal_netbsd.go b/log/term/terminal_netbsd.go
new file mode 100644
index 000000000..f9bb9e1c2
--- /dev/null
+++ b/log/term/terminal_netbsd.go
@@ -0,0 +1,7 @@
+package term
+
+import "syscall"
+
+const ioctlReadTermios = syscall.TIOCGETA
+
+type Termios syscall.Termios
diff --git a/log/term/terminal_notwindows.go b/log/term/terminal_notwindows.go
new file mode 100644
index 000000000..c9af534f6
--- /dev/null
+++ b/log/term/terminal_notwindows.go
@@ -0,0 +1,20 @@
+// Based on ssh/terminal:
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux,!appengine darwin freebsd openbsd netbsd
+
+package term
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+// IsTty returns true if the given file descriptor is a terminal.
+func IsTty(fd uintptr) bool {
+ var termios Termios
+ _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
+ return err == 0
+}
diff --git a/log/term/terminal_openbsd.go b/log/term/terminal_openbsd.go
new file mode 100644
index 000000000..f9bb9e1c2
--- /dev/null
+++ b/log/term/terminal_openbsd.go
@@ -0,0 +1,7 @@
+package term
+
+import "syscall"
+
+const ioctlReadTermios = syscall.TIOCGETA
+
+type Termios syscall.Termios
diff --git a/log/term/terminal_solaris.go b/log/term/terminal_solaris.go
new file mode 100644
index 000000000..033c16324
--- /dev/null
+++ b/log/term/terminal_solaris.go
@@ -0,0 +1,9 @@
+package term
+
+import "golang.org/x/sys/unix"
+
+// IsTty returns true if the given file descriptor is a terminal.
+func IsTty(fd uintptr) bool {
+ _, err := unix.IoctlGetTermios(int(fd), unix.TCGETA)
+ return err == nil
+}
diff --git a/log/term/terminal_windows.go b/log/term/terminal_windows.go
new file mode 100644
index 000000000..df3c30c15
--- /dev/null
+++ b/log/term/terminal_windows.go
@@ -0,0 +1,26 @@
+// Based on ssh/terminal:
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+package term
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var kernel32 = syscall.NewLazyDLL("kernel32.dll")
+
+var (
+ procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
+)
+
+// IsTty returns true if the given file descriptor is a terminal.
+func IsTty(fd uintptr) bool {
+ var st uint32
+ r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
+ return r != 0 && e == 0
+}