update entries
[nikiroo-utils.git] / README.md

Jexer - Java Text User Interface library

This library implements a text-based windowing system loosely reminiscient of Borland’s Turbo Vision system. (For those wishing to use the actual C++ Turbo Vision library, see Sergio Sigala’s C++ version based on the sources released by Borland, or consider Free Pascal’s Free Vision library.)

Jexer currently supports three backends:

Additional backends can be created by subclassing jexer.backend.Backend and passing it into the TApplication constructor. See Demo5 and Demo6 for examples of other backends.

The Jexer homepage, which includes additional information and binary release downloads, is at: https://jexer.sourceforge.io . The Jexer source code is hosted at: https://gitlab.com/klamonte/jexer .

License

This project is licensed under the MIT License. See the file LICENSE for the full license text.

Maven

Jexer is available on Maven Central:

xml <dependency> <groupId>com.gitlab.klamonte</groupId> <artifactId>jexer</artifactId> <version>0.3.0</version> </dependency>

Acknowledgements

Jexer makes use of the Terminus TrueType font made available here .

Usage

Simply subclass TApplication and then run it in a new thread:

```Java import jexer.*;

class MyApplication extends TApplication {

public MyApplication() throws Exception {
    super(BackendType.SWING); // Could also use BackendType.XTERM

    // Create standard menus for File and Window
    addFileMenu();
    addWindowMenu();

    // Add a custom window, see below for its code.  The TWindow
    // constructor will add it to this application.
    new MyWindow(this);
}

public static void main(String [] args) throws Exception {
    MyApplication app = new MyApplication();
    (new Thread(app)).start();
}

} ```

Similarly, subclass TWindow and add some widgets:

```Java class MyWindow extends TWindow {

public MyWindow(TApplication application) {
    // See TWindow's API for several constructors.  This one uses the
    // application, title, width, and height.  Note that the window width
    // and height include the borders.  The widgets inside the window
    // will see (0, 0) as the top-left corner inside the borders,
    // i.e. what the window would see as (1, 1).
    super(application, "My Window", 30, 20);

    // See TWidget's API for convenience methods to add various kinds of
    // widgets.  Note that ANY widget can be a container for other
    // widgets: TRadioGroup for example has TRadioButtons as child
    // widgets.

    // We will add a basic label, text entry field, and button.
    addLabel("This is a label", 5, 3);
    addField(5, 5, 20, false, "enter text here");
    // For the button, we will pop up a message box if the user presses
    // it.
    addButton("Press &Me!", 5, 8, new TAction() {
        public void DO() {
            MyWindow.this.messageBox("Box Title", "You pressed me, yay!");
        }
    } );
}

} ```

Put these into a file, compile it with jexer.jar in the classpath, run it and you’ll see an application like this:

The Example Code Above

More Examples

The examples/ folder currently contains:

jexer.demos contains official demos showing all of the existing UI controls. The demos can be run as follows:

More Screenshots

Several Windows Open Including A Terminal

Yo Dawg...

Sixel Pictures Of Cliffs Of Moher And Buoy

Sixel Color Wheel

Terminal Support

The table below lists terminals tested against Jexer’s ECMA48/Xterm backend.

Terminal Environment Mouse Click Mouse Cursor Images
xterm X11 yes yes yes
lcxterm(3) CLI, Linux console yes yes no
rxvt-unicode X11 yes yes no
alacritty(3) X11 yes yes no
gnome-terminal X11 yes yes no
xfce4-terminal X11 yes yes no
mlterm X11 yes yes no(5)
aminal(3) X11 yes no no
konsole X11 yes no no
yakuake X11 yes no no
screen CLI yes(1) yes(1) no(2)
tmux CLI yes(1) yes(1) no
putty X11, Windows yes no no(2)
Linux Linux console no no no(2)
qodem(3) CLI, Linux console yes yes(4) no
qodem-x11(3) X11 yes no no

1 - Requires mouse support from host terminal.

2 - Also fails to filter out sixel data, leaving garbage on screen.

3 - Latest in repository.

4 - Requires TERM=xterm-1003 before starting.

5 - Opening image crashes terminal.

System Properties

The following properties control features of Jexer:

jexer.Swing

Used only by jexer.demos.Demo1 and jexer.demos.Demo4. If true, use the Swing interface for the demo application. Default: true on Windows (os.name starts with “Windows”) and Mac (os.name starts with “Mac”), false on non-Windows and non-Mac platforms.

jexer.Swing.cursorStyle

Used by jexer.backend.SwingTerminal. Selects the cursor style to draw. Valid values are: underline, block, outline. Default: underline.

jexer.Swing.tripleBuffer

Used by jexer.backend.SwingTerminal. If true, use triple-buffering which reduces screen tearing but may also be slower to draw on slower systems. If false, use naive Swing thread drawing, which may be faster on slower systems but also more likely to have screen tearing. Default: true.

jexer.TTerminal.ptypipe

Used by jexer.TTerminalWindow. If true, spawn shell using the ‘ptypipe’ utility rather than ‘script’. This permits terminals to resize with the window. ptypipe is a separate C language utility, available at https://gitlab.com/klamonte/ptypipe. Default: false.

jexer.TTerminal.closeOnExit

Used by jexer.TTerminalWindow. If true, close the window when the spawned shell exits. Default: false.

jexer.ECMA48.rgbColor

Used by jexer.backend.ECMA48Terminal. If true, emit T.416-style RGB colors for normal system colors. This is expensive in bandwidth, and potentially terrible looking for non-xterms. Default: false.

jexer.ECMA48.sixel

Used by jexer.backend.ECMA48Terminal. If true, emit image data using sixel, otherwise show blank cells where images could be. This is expensive in bandwidth, very expensive in CPU (especially for large images), and will leave artifacts on the screen if the terminal does not support sixel. Default: true.

Known Issues / Arbitrary Decisions

Some arbitrary design decisions had to be made when either the obviously expected behavior did not happen or when a specification was ambiguous. This section describes such issues.

See Also

Tranquil Java IDE is a TUI-based integrated development environment for the Java language that was built using a very lightly modified GPL version of Jexer. TJ provided a real-world use case to shake out numerous bugs and limitations of Jexer.

Maintainers Wanted

Both Jexer and TJIDE are seeking additional maintainers. I am not in a position in life to take on significant off-hours programming work, and am willing to hand these projects over to one or more persons with time and interest.

My personal code design philosophy for TJIDE/Jexer is outlined at https://gitlab.com/klamonte/tjide/blob/master/java/docs/code_design.txt . I realize that some of the features listed below may require deviations from this philosophy, but this is what I have built so far.

Some of the areas that will likely require significant efforts are:

These are what I can clearly see right now. Obviously users are capable of finding many more.

I intend to continue poking on Jexer and TJIDE, and will maintain a branch to be “the fastest and simplest Java language IDE available”, which will deliberately remain small.

I hope that other languages choose to transliterate Jexer to provide TUIs to their own platforms. I will be happy to help them understand the code to support those efforts.