Xterminal Main page

A Object Oriented text-based User Interface with a
Client-Server architecture

written by Dragos Acostachioaie (dragos@biosfarm.ro)

1. What is Xterminal?

The main purpose of Xterminal is a friendly interface for the UNIX operating systems. It is designed to be used to build text based applications in C++.

It consists in a complete object oriented library including multiple, resizeable, overlapping windows, pull-down menus, dialog boxes, buttons, scroll bars, input lines, check boxes, radio buttons, etc. Mouse support, advanced object management, events handling, communications between objects are provided, too, bundled with a complete programmer's manual.

2. Why a text-based user interface?

During the last few years, the importance of programs' user interface have become crucial. Combine the power of UNIX with the easy-to-use property of some user interfaces and so the user will have both a powerful and a real operating system and a easy to use user interface.

Why a text-based user interface? Text-based interfaces, sufficient for many applications, are not as demanding as GUIs. Typically, they are more portable, run faster and require smaller communication bandwidth. The latter makes them especially appropriate for remote users on slow connections (e.g. over modem lines).

3. Why object-oriented?

Because of the interfaces' complexity, it is more convenient to partition them in more small pieces, in small objects. What programming model should be choosen for the base of a complex software, such as the user interfaces are? Could be the classic one, where all is written in standard structured programming and where applications use a number of documented functions and structures, called API. The problem is that any change in a routine inside API consists in a change in all existing applications, or in increasing the complexity of the GUI, because for a single feature there are several functions that perform it. It is however not the goal of this paper to discuss about the structured programming versus object-oriented programming. The object oriented programming seemed to be a good candidate for the user interfaces development.

Nowadays, object oriented programming have become very popular. That's because it's well-known advantages which helps the development of today's projects, that are becoming more and more complex. It makes the applications to split into several modules, relieves the developer of a module of having knowledge of the other's implementation details. This way, the application development time is decreasing, and it's quality is growing.

Last but not last, the object orientation is a very natural paradigm. In the real world, day by day, we are dealing with Objects. Everywere around are objects, which are interconnected, and which are communicating using Messages.

4. Why a client-server architecture?

The client-server architecture is a very natural paradigm too, nowadays. This architecture consists in two entities, one of them called Server, which offers some services for other's usage, and the other called Client, which benefits of these services; these two entities are communicating through messages. For example, this machine's web server provides this article to your web client, and you are reading it, so the machine it's a server and you are it's client.

5. A few words about implementation

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 program 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.

Because it is object oriented, objects can easily be modified through inheritance without recompiling the library. The polymorphism and embeding allows to hide operations (as initializations, parametrization) in private part of an object so the only programmer's task is to handle it by public methods. The object orientation give Xterminal a very high flexibility.

Xterminal was developed under Linux and it is known to work on Solaris and FreeBSD but it should be easy to port on other UNIX platforms, because it uses "GCC" as compiler and "libtool"/"autoconf" configuration scripts.

Right now, we are using "ncurses" to access the terminal, offering also limited support for "slang", and there are plans to offer support for "termcap" too, for a better portability. The mouse support is provided for Linux console using the "GPM" library, and support for "xterm" mouse is provided, too. It works great on console, but runs on "dumb" (like vt100) terminals, too, without any problem.

Here is an example application running in a xterm:

[Xterminal in a xterm]


The user interface is implemented as a library, and the programmer must not have any idea about it's internal implementation, but only about the results.

Xterminal is a hierarchy, not just a collection of disjoin objects. It includes almost everything needed for buiding a coherent user interface. Anyway, the programmer can use only one or more objects; Xterminal won't force them to use all of it.

Xterminal is very useful for building text based applications which need high implementation level, flexibility, easiness in use and a interactive user interface.

Copyright ©1998-2002 Dragos Acostachioaie
Last update on April 8, 2002