GeeCON Prague 2014*
The moose likes Linux / UNIX and the fly likes text based user interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "text based user interface" Watch "text based user interface" New topic
Author

text based user interface

Brett Wiggins
Greenhorn

Joined: Mar 23, 2009
Posts: 19
hi,

I have started writing a small application to run on a Linux Shell Server and am wondering if there is a way to make a text-only user interface. The program has a few threads that process I/O from a server as well as input from the user. All input and output are printed and captured to the console and what I would like to do is split the console into different sections so server I/O would be printed in one section and user input could be typed in another section.

thanks.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39045
    
  23
Too difficult a topic for us beginners.
Moving.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8914
    
    8

Java has poor console support. Consoles are very OS (and in Unix, shell) specific and Java tries to be platform-independent.
That said, you can use ASCII control characters, like 0x0d (carriage return) or 0x08 (backspace) to control the cursor on a single line. If your console recognizes ANSI escape sequences(I believe bash does), they allow greater flexibility.
If you want a fully-featured GUI, use AWT or Swing.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8914
    
    8

You can try the Java Curses library (curses is popular for building text interfaces on Unix). The examples look pretty impressive (character-based dialogs, scrolling lists, etc.).
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16095
    
  21

Actually, a true console should be considered as having all the graphics capabilities of a Teletype machine. Which is to say, virtually none. However most "glass TTY" devices (and the console windows that simulate them) are more flexible than that.

As Joe pointed out, there's system called "curses" that's designed to replace the wide variety of vendor-specific terminal control codes (escape sequences) with a standardized text-mode UI. While these days you could generally get by using the ANSI escape sequences, curses makes the process much more civilized.


Customer surveys are for companies who didn't pay proper attention to begin with.
Brett Wiggins
Greenhorn

Joined: Mar 23, 2009
Posts: 19
Hi guys,

Thanks for the help.I'll be checking out the java Curses Library.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: text based user interface