From the course: Code Clinic: C

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Building an interface in ncurses

Building an interface in ncurses - C Tutorial

From the course: Code Clinic: C

Start my 1-month free trial

Building an interface in ncurses

- [Narrator] The ncurses library has been around a long time. It allows you to program full screen and real time keyboard interaction in the Unix terminal environment which includes the Cygwin shell for Windows. Many full screen terminal programs including the popular vi editor are written by using ncurses. In the spirit of text-only C, I chose ncurses as my Theremin program's interface. You can obtain the ncurses library from invisibleisland.net. The main function in my Theremin C code initializes the ncurses screen, color output, and other settings. The screen size is calculated as are increments for the frequency, so this code works no matter how large the terminal window is. An endless while loop monitors input. When the enter key is pressed, the loop breaks. Otherwise, the mouse location is read. The tone function generates a sine wave for port audio. The frequency is calculated based on the mouse's vertical position or mort.y. The horizontal position, mort.x, sets the volume, or…

Contents