Skip to content

jonvaldes/termo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

termo

Simple ncurses-style terminal drawing lib in Go.

It tries to be simple to use while being more reliable than go-termbox.

While go-termbox writes each character individually to the terminal, termo keeps an internal "framebuffer", and then flushes the whole framebuffer to the terminal. This is less performant, but more reliable.

API

The steps to use termo in your program are the following:

  • Initialize termo
    termo.Init()
  • Defer the termo shutdown to restore the terminal state:
    defer termo.Stop()
  • Get the terminal size:
    w, h, _ := termo.Size()
  • Create a framebuffer:
    fb := termo.NewFramebuffer(w,h)
  • Draw something to the framebuffer:
    fb.ASCIIRect(3, 3, 20, 20, false, false) // Draw a 20x20 ASCII rectangle
    fb.SetText(4, 4, "I'm now using termo!") // Draw text
    fb.AttribRect(0, 4, w, 1, termo.BoldWhiteOnBlack) // Set character colors/attributes
  • Flush the framebuffer to the terminal:
    fb.Flush()

And that's it!

For more advanced usage, you can check out an example program here: https://github.com/jonvaldes/termo_example

Also, here's the full package documentation: https://godoc.org/github.com/jonvaldes/termo

Note: This project has only been tested in OSX, but should work in any unix, VT100-style terminal. Some advanced features like mouse support might only work in some terminals (for example, the default OSX terminal doesn't support mouse events, while iTerm2 does).

About

Simple ncurses-style terminal drawing lib in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages