Category:Curses

From Rosetta Code
Library
This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.

Curses is a library to draw characters on a terminal. Programs can use curses to move the terminal's cursor and display text in any line and column. For input, curses can get individual key presses from the terminal's keyboard. To optimize output, curses delays the screen updates until the program refreshes the screen.

There are at least 4 implementations of curses:

Curses is terminal-independent, and uses termcap or terminfo to send escape sequences to different flavors of terminals. (The exception is PDCurses, which never sends escape sequences, because it uses a DOS console or a graphical interface.)

  • C <lang c>#include <curses.h></lang> Then link the program with -lcurses. (Some old or strange systems might need -lcurses -ltermlib.)
  • Common Lisp <lang lisp>;; After installing the quicklisp library manager

(ql:quickload :croatoan)</lang>

  • Ruby <lang ruby>require 'curses'</lang>
  • Go <lang go>import "github.com/gbin/goncurses"</lang>There are a number of curses bindings for Go. This one is popular.