Getting Started With Ncurses and Ruby

Posted on 19 Dec 2012 by Eric Oestrich

I have been writing an ncurses campfire client hobostove and recently gave a presentation on using Ncurses and Ruby.

Hobostove uses the ncurses-ruby gem. It’s pretty old but so is Ncurses. Here I’ll give the basics of setting up, refreshing, and tearing down. I’ll do a panel usage post later.

Initialization
Ncurses.initscr
Ncurses.cbreak
Ncurses.noecho
  • Ncurses.initscr - sets up Ncurses
  • Ncurses.cbreak - don’t wait for a new line to send characters to Ncurses.getch
  • Ncurses.noecho - don’t echo typed characters to the screen
Update
Ncurses.doupdate
Ncurses.refresh
  • Ncurses.doupdate - compares the virtual screen to the physical screen and updates accordingly
  • Ncurses.refresh - writes to the terminal
Tear down
Ncurses.echo
Ncurses.endwin
  • Ncurses.echo - echos characters back to the screen
  • Ncurses.endwin - stops ncurses

Resources

  1. TLDP Ncurses How To
comments powered by Disqus
Creative Commons License
This site's content is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License unless otherwise specified. Code on this site is licensed under the MIT License unless otherwise specified.