Skip to content

Commit

Permalink
Formatting , Fixed Naming and Build Spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
olekukonko committed Jan 15, 2014
1 parent 4417e82 commit f223bba
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 21 deletions.
24 changes: 13 additions & 11 deletions ts.go
Original file line number Diff line number Diff line change
@@ -1,27 1,29 @@
package ts

// Return System Size
type Size struct {
row uint16
col uint16
xpixel uint16
ypixel uint16
row uint16
col uint16
posX uint16
posY uint16
}

// Get Terminal Width
func (w Size) Col() int {
return int(w.row)
}

// Get Terminal Height
func (w Size) Row() int {
return int(w.row)
}

func (w Size) Xpixel() int {
return int(w.xpixel)
// Get Position X
func (w Size) PosX() int {
return int(w.posX)
}

func (w Size) Ypixel() int {
return int(w.ypixel)
// Get Position Y
func (w Size) PosY() int {
return int(w.posY)
}



1 change: 1 addition & 0 deletions ts_darwin.go
Original file line number Diff line number Diff line change
@@ -1,4 1,5 @@
// build darwin

package ts

const (
Expand Down
1 change: 1 addition & 0 deletions ts_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 1,5 @@
// build linux

package ts

const (
Expand Down
5 changes: 2 additions & 3 deletions ts_other.go
Original file line number Diff line number Diff line change
@@ -1,8 1,7 @@
// build !darwin,!freebsd,!netbsd,!openbsd,!linux
// build !windows,!darwin,!freebsd,!netbsd,!openbsd,!linux

package ts

const (
TIOCGWINSZ = 0
)


13 changes: 11 additions & 2 deletions ts_test.go
Original file line number Diff line number Diff line change
@@ -1,9 1,18 @@
package ts

import "testing"

// TODO Add test
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 := GetSize()
Expand Down
2 changes: 2 additions & 0 deletions ts_unix.go
Original file line number Diff line number Diff line change
@@ -1,5 1,7 @@
// build freebsd netbsd openbsd

package ts

const (
TIOCGWINSZ = 0x40087468
)
5 changes: 3 additions & 2 deletions ts_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 1,6 @@
// build windows


package ts

import (
Expand Down Expand Up @@ -30,13 31,13 @@ type CONSOLE_SCREEN_BUFFER_INFO struct {
// 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 int16
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 int16
Left, Top, Right, Bottom uint16
}

func GetSize() Size {
Expand Down
6 changes: 3 additions & 3 deletions ts_x.go
Original file line number Diff line number Diff line change
@@ -1,5 1,6 @@
// build !windows


package ts

import (
Expand All @@ -15,8 16,7 @@ func GetSize() Size {
uintptr(0),
uintptr(TIOCGWINSZ),
uintptr(unsafe.Pointer(&ws)))

return int(ws.ws_col)
return ws
}
return ws
return Size{}
}

0 comments on commit f223bba

Please sign in to comment.