PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 3ms app.codeStats 0ms

/examples/hello/hello.go

https://code.google.com/p/goncurses/
Go | 38 lines | 16 code | 6 blank | 16 comment | 2 complexity | 38b6f1f764869edb815f61c58af7a9fd MD5 | raw file
 1// goncurses - ncurses library for Go.
 2// Copyright 2011 Rob Thornton. All rights reserved.
 3// Use of this source code is governed by a BSD-style
 4// license that can be found in the LICENSE file.
 5
 6/* The classic "Hello, World!" program in Goncurses! */
 7package main
 8
 9import (
10	"code.google.com/p/goncurses"
11	"log"
12)
13
14func main() {
15	// Initialize goncurses. It's essential End() is called to ensure the
16	// terminal isn't altered after the program ends
17	stdscr, err := goncurses.Init()
18	if err != nil {
19		log.Fatal("init", err)
20	}
21	defer goncurses.End()
22
23	// (Go)ncurses draws by cursor position and uses reverse cartisian
24	// coordinate system (y,x). Initially, the cursor is positioned at the
25	// coordinates 0,0 so the first call to Print will output the text at the
26	// top, left position of the screen since stdscr is a window which
27	// represents the terminal's screen size.
28	stdscr.Print("Hello, World!")
29	stdscr.MovePrint(3, 0, "Press any key to continue")
30
31	// Refresh() flushes output to the screen. Internally, it is the same as
32	// calling NoutRefresh() on the window followed by a call to Update()
33	stdscr.Refresh()
34
35	// GetChar will block execution until an input event, like typing a
36	// character on your keyboard, is received
37	stdscr.GetChar()
38}