
termon
Installation
The only dependency is libncurses5-dev
. On Debian and Debian-based systems, this should install it:
apt-get install libncurses5-dev
Installing termon
is easy:
goinstall termon.googlecode.com/hg
Usage
``` package main
import ( "termon.googlecode.com/hg" "fmt" )
func main() { // Must! term.Init()
// You may create as many colors as you want (probably).
// Usage: term.NewColor(foreground, background)
// Any color from defs.go, or 0 for default is acceptable.
color := term.NewColor(term.COLOR_RED, 0)
// Every input and output from now and on will have
// red foreground and default background.
color.On()
// Print at the current position (0, 0).
term.Add("Hello.")
// Print at the center of the terminal.
term.AddAt(*term.Cols / 2, *term.Rows / 2, "What do you love? ")
// Every input and output from now and on will have
// the default foreground and background.
color.Off()
// Get user's input. Returns on a line break.
answer := term.GetText()
// Bring our color back.
color.On()
// Disappoint the user because a machine doesn't know what love is.
term.AddAt(0, *term.Rows - 1, fmt.Sprintf("Sorry, \"%s\" is not an answer.", answer))
// Wait for next character.
term.GetChar()
// Reset the terminal.
// It will look as well as before term.Init() was called.
term.End()
}
```
Is it nice with games?
Look at hg/sample_game
directory (here).
Project Information
The project was created on Jul 23, 2011.
- License: Apache License 2.0
- 3 stars
- hg-based source control