The netbeans terminal emulator
- mailing list: email@example.com
- to manage mailing list visit http://netbeans.org/projects/www/lists
- terminalemulator open IZs list.
- API Review
terminal emulator vs Terminal Emulator
To most of us the word terminal emulator brings to mind an application like xterm, dtterm or konsole. What we might not realise is that such an application, especially the more modern ones, is actually made up of several cooperating subsystems ...
- The wrapper application. This might implement options, searching, menus etc.
- A terminal emulator widget/component.
- Ptys and a Line Discipline.
That is, functionality we usually associate with the application might not actually be implemented by the widget/component.
Term is a low-level swing component in lib.terminalemulator.
NetBeans already has ...
- A terminal emulator widget/component, Term, under lib.terminalemulator.
The following are being prepared under lib.terminalemulator/demosrc ...
- A Rich Execution library under lib.terminalemulator/demosrc/lib.richexecution
This library uses JNA to help execute Shells, Commands and Programs under Pty's. While it was originally intended solely for terminal support, it is likely to acquire additonal features for process interaction in unix-like environments.
Terminal is the higher-level manifestation of Term inside a TopComponent.
- A collection of support classes for Term under lib.terminalemulator/demosrc/lib.termsupport.
This is a collection of miscellaneous features like search, hyperlink support and soon, options.
- A demonstration application under lib.terminalemulator/demosrc/lib.termsupport/nbterm.
- A module to create fully functional Terminal's inside the IDE under lib.terminalemulator/demosrc/terminal.
This module also contains APIs for creating custom TopComponents as TerminalContainers and an exploratory implementation of IOProvider.
- A set of Terminal utilization examples under lib.terminalemulator/demosrc/terminal/examples.
The breakthrough which allowed all of this to happen is JNA and its acceptance into the NetBeans platform. Prior to this one had to resort to JNI to access native pty functions.
For the impatient ...
You can download ...
After untarring the tarfile just run nbterm ... or nbterm -h for options.
Upon successful installation you will have at your disposal:
- Run->Shell Term will run a shell (see below) in a terminal.
- Run->Command Term will ask for and run a command in a terminal.
Try date or top.
- Window->Output->Terminal will open the default terminal TopComponent.
- Terminals->* contains a collection of examples.
See TerminalEmulatorAndOutput for more info on these.
By default nbterm and Run->Shell Term will ...
- Under Linux - Run the shell defined in $SHELL or /bin/bash if $SHELL is unset.
- Under Solaris 10 and newer - Run the shell defined in $SHELL or /bin/bash if $SHELL is unset.
JNA does not work on Solaris 9 or older.
- Under Mac (aka BSD) - As above but with some limitations.
See TerminalEmulatorOnMac for more info.
- Under Windows - Run cmd.exe but don't expect much from it. I issued edit for example
and it went to nowhere-land.
In them you should be able to do the following:
- Use the shells cmdline editing.
- Use more/less/man and have them render and react as expected.
- Use a screen editor like vi
- Start a plain /bin/cat and ^C or ^D out of it or ^Z it.
- Issue "stty -a" and note how 'columns' and 'rows' tracks window size changes.
- These are in transition between lightweight demos and useful tools. For example, they have context menus and
search but no options support.
- In the NB module version and on systems other than Linux, ^C is ineffective. This has to do with how
netbeans is started. See NetbeansStartupAndCtlC.
- In the NB module version the terminal appears in it's own window. See
TerminalEmulatorAndOutput for more discussion.
- Instead of Ctl-C for Copy etc Alt-C etc are used. However, it's not working correctly yet!
For the hackers ...
The code for the above is under lib.terminalemulator/demosrc.
Please read Organization of terminal application modules, TerminalEmulatorCodingExamples and TerminalEmulatorHyperlinking to learn more about it.
Things recently introduced:
- Come up with a proper API and module organization.
- Add search and other "utilities" usually appearing in a context menu.
- Output filtering and hyperlinking facility. First exposure.
- Ability to create specialized TopComponents other than a default dedicated Terminal TC.
Things I'd like to do in the near future:
- Add a property sheet. There's code in SunStudio which is unencumbered and should be
relatively easy to open.
- Choice of tabbed or multiplexed Terms within a TopComponent.
For example the dbx command console and debugged process i/o Terms in SunStudio are multiplexed between debugging sessions.
- Pty-only Terminal's w/o a backing process.
This arises most frequently with debuggers (like dbx and gdb) where the debugger starts the process but the io needs to be connected to a terminal separetly via a Pty.
- Terminals for internal i/o.
More things I'd like to do:
The base Term widget has served reasonably well as the console for dbx and it's debuggees i/o under SunStudio, but it could use some improvements:
- It doesn't implement all the ANSI escape sequences. It suffices for common uses by vi, more,
shell cmdline editing and etc but customers who try to debug full-fledged curses based applications (yes they do exist) find it wanting.
A particularly challenging application is 'mc' (Midnight Commander). It's rendered reasonably well but cannot do the following:
- Render "graphic" characters (for boxes and such). While these characters are defined in
unicode, Java fonts don't support them.
- Handle Function keys. This isn't hard to do but I have to first work out how to make
this optional so there's no conflict with the IDE's Function keys.
- Convert mouse gestures to character sequences.
- Many users have expressed dissatisfaction with lack of font choices. You can get any
font you want as long as it's Java "monospaced".
One should be able to at least give users a choice of various fixed width fonts through a Term property sheet. However it's not obvious how to pick out only fixed-width fonts for the font palette.
- It doesn't have disk-based buffers like output2. The impact of large history size on
the heap and GC can be solved using nio Buffers.
- It will not re-wrap lines. So if it starts narrow and then gets widened the text emitted while
it was narrow stays narrow.
- The view paint() is lazy in that it repaints everything. This works well enough if the
output to the term is buffered. However if you write one character at a time to it it will get noticable.
- It is not thread-safe. All operations must be done on the AWT event dispatch thread.
- The terminalemulator open IZ list (which includes some of the above).
All Terminal links: