Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
973266ae
提交
973266ae
authored
4月 27, 2016
作者:
Jeromy Johnson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
re-add dep needed for windows builds (#2611)
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
上级
5d25fc1f
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
326 行增加
和
2 行删除
+326
-2
.travis.yml
Godeps/_workspace/src/github.com/olekukonko/ts/.travis.yml
+7
-0
LICENCE
Godeps/_workspace/src/github.com/olekukonko/ts/LICENCE
+20
-0
README.md
Godeps/_workspace/src/github.com/olekukonko/ts/README.md
+28
-0
doc.go
Godeps/_workspace/src/github.com/olekukonko/ts/doc.go
+36
-0
ts.go
Godeps/_workspace/src/github.com/olekukonko/ts/ts.go
+36
-0
ts_darwin.go
Godeps/_workspace/src/github.com/olekukonko/ts/ts_darwin.go
+14
-0
ts_linux.go
Godeps/_workspace/src/github.com/olekukonko/ts/ts_linux.go
+13
-0
ts_other.go
Godeps/_workspace/src/github.com/olekukonko/ts/ts_other.go
+14
-0
ts_test.go
Godeps/_workspace/src/github.com/olekukonko/ts/ts_test.go
+32
-0
ts_unix.go
Godeps/_workspace/src/github.com/olekukonko/ts/ts_unix.go
+14
-0
ts_windows.go
Godeps/_workspace/src/github.com/olekukonko/ts/ts_windows.go
+64
-0
ts_x.go
Godeps/_workspace/src/github.com/olekukonko/ts/ts_x.go
+46
-0
Makefile
Makefile
+2
-2
没有找到文件。
Godeps/_workspace/src/github.com/olekukonko/ts/.travis.yml
0 → 100644
浏览文件 @
973266ae
language
:
go
go
:
-
1.1
-
1.2
-
tip
\ No newline at end of file
Godeps/_workspace/src/github.com/olekukonko/ts/LICENCE
0 → 100644
浏览文件 @
973266ae
Copyright (C) 2014 by Oleku Konko
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.
\ No newline at end of file
Godeps/_workspace/src/github.com/olekukonko/ts/README.md
0 → 100644
浏览文件 @
973266ae
ts (Terminal Size)
==
[

](https://travis-ci.org/olekukonko/ts)
[

](https://sourcegraph.com/github.com/olekukonko/ts)
Simple go Application to get Terminal Size. So Many Implementations do not support windows but
`ts`
has full windows support.
Run
`go get github.com/olekukonko/ts`
to download and install
#### Example
```
go
package
main
import
(
"fmt"
"github.com/olekukonko/ts"
)
func
main
()
{
size
,
_
:=
ts
.
GetSize
()
fmt
.
Println
(
size
.
Col
())
// Get Width
fmt
.
Println
(
size
.
Row
())
// Get Height
fmt
.
Println
(
size
.
PosX
())
// Get X position
fmt
.
Println
(
size
.
PosY
())
// Get Y position
}
```
[
See Documentation
](
http://godoc.org/github.com/olekukonko/ts
)
Godeps/_workspace/src/github.com/olekukonko/ts/doc.go
0 → 100644
浏览文件 @
973266ae
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Terminal API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
/**
Simple go Application to get Terminal Size. So Many Implementations do not support windows but `ts` has full windows support.
Run `go get github.com/olekukonko/ts` to download and install
Installation
Minimum requirements are Go 1.1+ with fill Windows support
Example
package main
import (
"fmt"
"github.com/olekukonko/ts"
)
func main() {
size, _ := ts.GetSize()
fmt.Println(size.Col()) // Get Width
fmt.Println(size.Row()) // Get Height
fmt.Println(size.PosX()) // Get X position
fmt.Println(size.PosY()) // Get Y position
}
**/
package
ts
Godeps/_workspace/src/github.com/olekukonko/ts/ts.go
0 → 100644
浏览文件 @
973266ae
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Terminal API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
ts
// Return System Size
type
Size
struct
{
row
uint16
col
uint16
posX
uint16
posY
uint16
}
// Get Terminal Width
func
(
w
Size
)
Col
()
int
{
return
int
(
w
.
col
)
}
// Get Terminal Height
func
(
w
Size
)
Row
()
int
{
return
int
(
w
.
row
)
}
// Get Position X
func
(
w
Size
)
PosX
()
int
{
return
int
(
w
.
posX
)
}
// Get Position Y
func
(
w
Size
)
PosY
()
int
{
return
int
(
w
.
posY
)
}
Godeps/_workspace/src/github.com/olekukonko/ts/ts_darwin.go
0 → 100644
浏览文件 @
973266ae
// +build darwin
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Terminal API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
ts
const
(
TIOCGWINSZ
=
0x40087468
)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_linux.go
0 → 100644
浏览文件 @
973266ae
// +build linux
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Terminal API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
ts
const
(
TIOCGWINSZ
=
0x5413
)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_other.go
0 → 100644
浏览文件 @
973266ae
// +build !windows,!darwin,!freebsd,!netbsd,!openbsd,!linux
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Terminal API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
ts
const
(
TIOCGWINSZ
=
0
)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_test.go
0 → 100644
浏览文件 @
973266ae
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Terminal API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
ts
import
(
"fmt"
"testing"
)
func
ExampleGetSize
()
{
size
,
_
:=
GetSize
()
fmt
.
Println
(
size
.
Col
())
// Get Width
fmt
.
Println
(
size
.
Row
())
// Get Height
fmt
.
Println
(
size
.
PosX
())
// Get X position
fmt
.
Println
(
size
.
PosY
())
// Get Y position
}
func
TestSize
(
t
*
testing
.
T
)
{
size
,
err
:=
GetSize
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
size
.
Col
()
==
0
||
size
.
Row
()
==
0
{
t
.
Fatalf
(
"Screen Size Failed"
)
}
}
Godeps/_workspace/src/github.com/olekukonko/ts/ts_unix.go
0 → 100644
浏览文件 @
973266ae
// +build freebsd netbsd openbsd
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Terminal API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
ts
const
(
TIOCGWINSZ
=
0x40087468
)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_windows.go
0 → 100644
浏览文件 @
973266ae
// +build windows
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Terminal API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
ts
import
(
"syscall"
"unsafe"
)
var
(
kernel32
=
syscall
.
NewLazyDLL
(
"kernel32.dll"
)
// Retrieves information about the specified console screen buffer.
// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683171(v=vs.85).aspx
screenBufferInfo
=
kernel32
.
NewProc
(
"GetConsoleScreenBufferInfo"
)
)
// Contains information about a console screen buffer.
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type
CONSOLE_SCREEN_BUFFER_INFO
struct
{
DwSize
COORD
DwCursorPosition
COORD
WAttributes
uint16
SrWindow
SMALL_RECT
DwMaximumWindowSize
COORD
}
// Defines the coordinates of a character cell in a console screen buffer.
// The origin of the coordinate system (0,0) is at the top, left cell of the buffer.
// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119(v=vs.85).aspx
type
COORD
struct
{
X
,
Y
uint16
}
// Defines the coordinates of the upper left and lower right corners of a rectangle.
// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686311(v=vs.85).aspx
type
SMALL_RECT
struct
{
Left
,
Top
,
Right
,
Bottom
uint16
}
func
GetSize
()
(
ws
Size
,
err
error
)
{
var
info
CONSOLE_SCREEN_BUFFER_INFO
rc
,
_
,
err
:=
screenBufferInfo
.
Call
(
uintptr
(
syscall
.
Stdout
),
uintptr
(
unsafe
.
Pointer
(
&
info
)))
if
rc
==
0
{
return
ws
,
err
}
ws
=
Size
{
info
.
SrWindow
.
Bottom
,
info
.
SrWindow
.
Right
,
info
.
DwCursorPosition
.
X
,
info
.
DwCursorPosition
.
Y
}
return
ws
,
nil
}
Godeps/_workspace/src/github.com/olekukonko/ts/ts_x.go
0 → 100644
浏览文件 @
973266ae
// +build !windows
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Terminal API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
ts
import
(
"syscall"
"unsafe"
)
// Get Windows Size
func
GetSize
()
(
ws
Size
,
err
error
)
{
_
,
_
,
ec
:=
syscall
.
Syscall
(
syscall
.
SYS_IOCTL
,
uintptr
(
syscall
.
Stdout
),
uintptr
(
TIOCGWINSZ
),
uintptr
(
unsafe
.
Pointer
(
&
ws
)))
err
=
getError
(
ec
)
if
TIOCGWINSZ
==
0
&&
err
!=
nil
{
ws
=
Size
{
80
,
25
,
0
,
0
}
}
return
ws
,
err
}
func
getError
(
ec
interface
{})
(
err
error
)
{
switch
v
:=
ec
.
(
type
)
{
case
syscall
.
Errno
:
// Some implementation return syscall.Errno number
if
v
!=
0
{
err
=
syscall
.
Errno
(
v
)
}
case
error
:
// Some implementation return error
err
=
ec
.
(
error
)
default
:
err
=
nil
}
return
}
Makefile
浏览文件 @
973266ae
...
...
@@ -65,11 +65,11 @@ PHONY += go_check deps vendor install build nofuse clean uninstall
##############################################################
# tests targets
test
:
test_expensive
windows_build_check
test
:
test_expensive
test_short
:
build test_go_short test_sharness_short
test_expensive
:
build test_go_expensive test_sharness_expensive
test_expensive
:
build test_go_expensive test_sharness_expensive
windows_build_check
test_3node
:
cd test
/3nodetest
&&
make
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论