First of all, Xterminal is a hierarchy of objects, based on a client-
server model. That means there is one or more objects acting like servers, each
one having some clients. Each of these clients may act as servers too, having
each one some clients. The various events that comes from the system (keyboard,
mouse events, signals, messages, and so on) are going to a server and he
decide which of his clients must receive the event, and so forth. If a server
is redrawn, he asks it's clients to redraw themselves, too, for example. Events
are not passed syncronous to objects, but using a queue, so if the system is
busy with other tasks, events are not loosed.
Each object have an unique identificator, and Xterminal maintains an
internal table to keep track of these objects. Objects can communicate one
with other using messages. Messages are translated into events and inserted
into the queue, too.
1. 'cd' to the directory containing the package's source code and type
'./configure' to configure the package for your system. While running,
the 'configure' script prints some messages telling which features it is
checking for.
The 'configure' script is generated from 'configure.in' by GNU's autoconf
and it attempts to guess correct values for various system-dependent
variables used during compilation. It also creates the Makefiles needed to
compile the package and a '.h' file containing system-dependent
definitions.
2. Type 'make to compile the package. This should create the library, and no
warnings should be produced.
3. Type 'make install' to install the library, the include files and the
documentation. This operation should be done as root.
This step is not compulsory, but if you want to compile something with the
shared version of the library, such as the example files, you must install
it first. If you built the static version, you can skip this step.
4. Type 'make examples' if you wish to see some test programs. This will
create some 'ex*' files in the 'example' directory.
5. Type 'make clean' if you want to remove the object files from the source
directory. To also remove the files that 'configure' created, type
'make distclean'.
Installation directories
By default, 'make install' will install the package's files in
'/usr/include', '/usr/lib', etc. You can specify an installation prefix
other than '/usr' by giving 'configure' the option '--prefix=PATH'.
Other features and options
If you want to compile a static version of the library instead of a shared
one, you should use the option '--disable-shared'.
If you don't want mouse support, use the option '--without-gpm'.
Every class is derived from an abstract class, XObject. Each
instantiated XObject have an object id (identificator) associated to
it. The library itself maintains an internal table of instantiated classes.
There are three types of objects:
- abstract objects, which cannot be instantiated, but only declared;
their purpose is to provide a general manipulation to a class of objects;
- passive objects, which only displays something, but the user cannot
control them;
- active objects, which the user can do something with them, and which
knows to answer in a way to the user input.
XRect is an abstraction for a geometrical two-dimensional
"rectangle", having an a field of type XPoint
(the upper-left corner), and an b field of type
XPoint too (the bottom-right corner).
The events are not passed syncronously to the objects to which are
addressed, but using a event queue. That doesn't mean the events will be
delayed, anyway. The application will automatically query the system for
events (from keyboard, from mouse, messages from other objects, UNIX
signals), will find the object that event is addressed to, and will insert
them into the queue.
There is a basic event class, XEvent, and the other event classes
are derived from it.
Event "classes":
- EV_NOTHING, no event for an object;
- EV_KEYBOARD, an event from keyboard;
- EV_MOUSE, an event from mouse;
- EV_SIGNAL, a UNIX system signal;
- EV_MESSAGE, a message from an other object;
- EV_BROADCAST, an event received by all objects.
The Xterminal's event model is suggested by the picture below:
The terminal is accessed using the XTerminal class, which abstractize
the input/output operations with the terminal. This class is globally
instantiated as XTerminal *Terminal. This class allows you to control the
terminal input/output state, and provides methods to write to the terminal and
to get events (from keyboard or mouse) from it. Always remember that writing
something to the terminal does not imply screen update; the update is made only
at the XTerminal.Refresh() call.
In order to use the library, you must include Xterminal.h in your C++
programs. At the linking phase, you must have -lXterminal as parameter when
calling the C++ compiler. You may also need to use -lncurses -lgpm.
Any Xterminal application must first call
XInit() that initialize the terminal. The program also must call
XDone() before exit.