Codebase list golang-github-go-kit-kit / babed25
Copy gopkg.in/inconshreveable/log15.v2/term to log/term Commit dc7890abeaadcb6a79a9a5ee30bc1897bbf97713 The idea is from @csguy: https://gophers.slack.com/archives/go-kit/p1440085532000869 Tamás Gulácsi 8 years ago
8 changed file(s) with 131 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 The MIT License (MIT)
1
2 Copyright (c) 2014 Simon Eskildsen
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
0 // Based on ssh/terminal:
1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build appengine
6
7 package term
8
9 // IsTty always returns false on AppEngine.
10 func IsTty(fd uintptr) bool {
11 return false
12 }
0 // Based on ssh/terminal:
1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package term
6
7 import "syscall"
8
9 const ioctlReadTermios = syscall.TIOCGETA
10
11 type Termios syscall.Termios
0 package term
1
2 import (
3 "syscall"
4 )
5
6 const ioctlReadTermios = syscall.TIOCGETA
7
8 // Go 1.2 doesn't include Termios for FreeBSD. This should be added in 1.3 and this could be merged with terminal_darwin.
9 type Termios struct {
10 Iflag uint32
11 Oflag uint32
12 Cflag uint32
13 Lflag uint32
14 Cc [20]uint8
15 Ispeed uint32
16 Ospeed uint32
17 }
0 // Based on ssh/terminal:
1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build !appengine
6
7 package term
8
9 import "syscall"
10
11 const ioctlReadTermios = syscall.TCGETS
12
13 type Termios syscall.Termios
0 // Based on ssh/terminal:
1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build linux,!appengine darwin freebsd openbsd
6
7 package term
8
9 import (
10 "syscall"
11 "unsafe"
12 )
13
14 // IsTty returns true if the given file descriptor is a terminal.
15 func IsTty(fd uintptr) bool {
16 var termios Termios
17 _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
18 return err == 0
19 }
0 package term
1
2 import "syscall"
3
4 const ioctlReadTermios = syscall.TIOCGETA
5
6 type Termios syscall.Termios
0 // Based on ssh/terminal:
1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build windows
6
7 package term
8
9 import (
10 "syscall"
11 "unsafe"
12 )
13
14 var kernel32 = syscall.NewLazyDLL("kernel32.dll")
15
16 var (
17 procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
18 )
19
20 // IsTty returns true if the given file descriptor is a terminal.
21 func IsTty(fd uintptr) bool {
22 var st uint32
23 r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
24 return r != 0 && e == 0
25 }