aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/peterh/liner/unixmode.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-06 17:39:31 +0800
committerFelix Lange <fjl@twurst.com>2015-03-06 17:39:31 +0800
commit2393de5d6b535a850e8b5d510aa2ae4f940f3d23 (patch)
tree020fdbfeb9046f101b7e2ccab31bfc3c02caf1aa /Godeps/_workspace/src/github.com/peterh/liner/unixmode.go
parent38f6d60e6e699db24b7a850b5999823b9e36d5bb (diff)
downloaddexon-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar
dexon-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.gz
dexon-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.bz2
dexon-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.lz
dexon-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.xz
dexon-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.zst
dexon-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.zip
Godeps: add github.com/peterh/liner
Diffstat (limited to 'Godeps/_workspace/src/github.com/peterh/liner/unixmode.go')
-rw-r--r--Godeps/_workspace/src/github.com/peterh/liner/unixmode.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/peterh/liner/unixmode.go b/Godeps/_workspace/src/github.com/peterh/liner/unixmode.go
new file mode 100644
index 000000000..9838923f5
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/peterh/liner/unixmode.go
@@ -0,0 +1,37 @@
+// +build linux darwin freebsd openbsd netbsd
+
+package liner
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func (mode *termios) ApplyMode() error {
+ _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(syscall.Stdin), setTermios, uintptr(unsafe.Pointer(mode)))
+
+ if errno != 0 {
+ return errno
+ }
+ return nil
+}
+
+// TerminalMode returns the current terminal input mode as an InputModeSetter.
+//
+// This function is provided for convenience, and should
+// not be necessary for most users of liner.
+func TerminalMode() (ModeApplier, error) {
+ mode, errno := getMode(syscall.Stdin)
+
+ if errno != 0 {
+ return nil, errno
+ }
+ return mode, nil
+}
+
+func getMode(handle int) (*termios, syscall.Errno) {
+ var mode termios
+ _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(handle), getTermios, uintptr(unsafe.Pointer(&mode)))
+
+ return &mode, errno
+}