ZOIS *
Technical Notes
ZOIS Technical Note TN-1991-01-01.
Author and Audience
This TN is intended for persons interested in the curses(3)
library and its use in C programs for UNIX systems. UNIX systems'
and C programming skills are assumed. Written by Martin
Sullivan[1], ZOIS Limited,
Cockermouth.
Abstract
A program which displays the time in analogue form on a character
based terminal is presented, both as an exemplar and as an amusement.
Introduction
The curses(3) library allows programmers to write text-based
user interfaces on terminals with a directly addressable cursor
(such as the DEC VT100). Cleverly, the library allows for the
independent use of a wide variety of such terminals and optimises
output to reduce the amount of traffic between the central computer
and terminal by only writing portions of the screen that need
rewriting. Lately this library has been upgraded and extended as
'ncurses'[2] and in this format is most widely
known and distributed. This TN introduces a program, written in C,
which can run on a variety of UNIX platforms to display a clock
using curses.
Materials and Platform
The code is written in K&R C, and thus can be compiled on quite
ancient kit (as well as more modern OS). It works fine on Linux with
a GCC compiler. The clock may be displayed using xterm(1).
Method
The code for the clock is found in the downloads area as a compressed (with gzip(1)) tar(1) archive[3]. In most cases it will need adaption to the environment of the site you are running on. Since we are publishing this as an exemplar, then figuring out the compilation should be considered as part of the exercise. The following should be sufficient for most UNIX systems:
make clock |
Once made the clock provides the following options:
Any text given on the command line is taken as a 'title' and displayed on the clock face in deference to the default.
As a bonus, the tar-ball also contains some other cursor based
toys, including one, bubbles which was inspired by
the rain demo and in turn inspired at least one book.
Conclusion
The somewhat elderly curses clock has been described and is
available for download. The download includes a number of other
curses based demonstrations. A man(1) page and build
instructions are included.
References
References found in this section, and in particular the HTML links were correct at time of writing (2007-11-14).
$Date: 2007/11/15 14:44:11 $