Terminal control/Dimensions: Difference between revisions
Content added Content deleted
m (Applesoft BASIC) |
(Go solution) |
||
Line 210: | Line 210: | ||
[then] |
[then] |
||
term-width ! term-height !</lang> |
term-width ! term-height !</lang> |
||
=={{header|Go}}== |
|||
===External command=== |
|||
<lang go>package main |
|||
import ( |
|||
"fmt" |
|||
"os" |
|||
"os/exec" |
|||
) |
|||
func main() { |
|||
var h, w int |
|||
cmd := exec.Command("stty", "size") |
|||
cmd.Stdin = os.Stdin |
|||
d, _ := cmd.Output() |
|||
fmt.Sscan(string(d), &h, &w) |
|||
fmt.Println(h, w) |
|||
}</lang> |
|||
===Ncurses=== |
|||
<lang go>package main |
|||
import ( |
|||
"fmt" |
|||
"log" |
|||
"code.google.com/p/goncurses" |
|||
) |
|||
func main() { |
|||
s, err := goncurses.Init() |
|||
if err != nil { |
|||
log.Fatal("init:", err) |
|||
} |
|||
defer goncurses.End() |
|||
height, width := s.MaxYX() |
|||
fmt.Println(height, width) |
|||
}</lang> |
|||
=={{header|J}}== |
=={{header|J}}== |