github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/log/term/terminal_windows.go (about)

     1  
     2  //此源码被清华学神尹成大魔王专业翻译分析并修改
     3  //尹成QQ77025077
     4  //尹成微信18510341407
     5  //尹成所在QQ群721929980
     6  //尹成邮箱 yinc13@mails.tsinghua.edu.cn
     7  //尹成毕业于清华大学,微软区块链领域全球最有价值专家
     8  //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
     9  //基于ssh/终端:
    10  //版权所有2011 Go作者。版权所有。
    11  //此源代码的使用受BSD样式的控制
    12  //可以在许可文件中找到的许可证。
    13  
    14  //+构建窗口
    15  
    16  package term
    17  
    18  import (
    19  	"syscall"
    20  	"unsafe"
    21  )
    22  
    23  var kernel32 = syscall.NewLazyDLL("kernel32.dll")
    24  
    25  var (
    26  	procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
    27  )
    28  
    29  //如果给定的文件描述符是终端,则istty返回true。
    30  func IsTty(fd uintptr) bool {
    31  	var st uint32
    32  	r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
    33  	return r != 0 && e == 0
    34  }