Get Screen dimensions via goncurses

This commit is contained in:
tkarrass 2016-01-19 16:38:15 +01:00
parent b4251237ba
commit ca3f1947b3
4 changed files with 25 additions and 1 deletions

View File

@ -9,7 +9,7 @@ import (
var cmdGosl = &cobra.Command{ var cmdGosl = &cobra.Command{
Use: "gosl [command]", Use: "gosl [command]",
Short: "Run a gosl instance", Short: "Run a gosl instance",
Long: `Run a gosl server or client." Long: `Run a gosl server or client.
For further instructions run 'gosl help [command]' For further instructions run 'gosl help [command]'
`, `,

View File

@ -4,6 +4,8 @@ import (
"fmt" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"code.bitsetter.de/fun/gosl/data"
) )
var cmdServer = &cobra.Command{ var cmdServer = &cobra.Command{
@ -15,6 +17,7 @@ var cmdServer = &cobra.Command{
func runServer(cmd *cobra.Command, args []string) { func runServer(cmd *cobra.Command, args []string) {
fmt.Println("running server ...") fmt.Println("running server ...")
data.TestNC()
} }
func init() { func init() {

View File

@ -1,6 +1,27 @@
package data // code.bitsetter.de/fun/gosl/data package data // code.bitsetter.de/fun/gosl/data
import (
"fmt"
"log"
"os"
"github.com/rthornton128/goncurses"
)
type Screen struct { type Screen struct {
w, h int w, h int
data []rune data []rune
} }
func TestNC() {
win, err := goncurses.Init()
if err != nil {
log.Fatal(err)
os.Exit(1)
}
win.Clear()
w, h := win.MaxYX()
goncurses.End()
fmt.Printf("screen: %d x %d", w, h)
}

BIN
gosl

Binary file not shown.