DomTerm is a contemporary terminal emulator that makes use of a browser engine as a “GUI toolkit.” This permits some neat options, akin to embeddable graphics and hyperlinks, HTML wealthy textual content, and foldable (present/cover) instructions. Otherwise it appears and appears like a feature-full, standalone terminal emulator, with glorious xterm compatibility (together with mouse dealing with and 24-bit coloration), and applicable “chrome” (menus). In addition, there’s built-in help for session administration and sub-windows (as in tmux
and GNU display screen
), fundamental enter enhancing (as in readline
), and paging (as in much less
).
Below we’ll look extra at these options. We’ll assume you could have domterm
put in (skip to the tip of this text if it’s good to get and construct DomTerm). First, although, this is a fast overview of the expertise.
Frontend vs. backend
Most of DomTerm is written in JavaScript and runs in a browser engine. This could be a desktop internet browser, akin to Chrome or Firefox (see image 3), or it may be an embedded browser. Using a normal internet browser works high quality, however the consumer expertise is not as good (because the menus are designed for normal looking, not for a terminal emulator), and the safety mannequin will get in the way in which, so utilizing an embedded browser is nicer.
The following are presently supported:
qtdomterm
, which makes use of the Qt toolkit andQtWebEngine
- An
Electron
embedding (see image 1) atom-domterm
runs DomTerm as a package deal within the Atom text editor (which can also be primarily based on Electron) and integrates with the Atom pane system (see image 2)- A wrapper for JavaFX’s
WebEngine
, which is beneficial for code written in Java (see image 4) - Previously, the popular frontend used Firefox-XUL, however Mozilla has since dropped XUL
Currently, the Electron frontend might be the nicest choice, intently adopted by the Qt frontend. If you utilize Atom, atom-domterm
works fairly nicely.
The backend server is written in C. It manages pseudo terminals (PTYs) and classes. It can also be an HTTP server that gives the JavaScript and different recordsdata to the frontend. The domterm
command begins terminal jobs and performs different requests. If there isn’t any server working, domterm
daemonizes itself. Communication between the backend and the server is generally accomplished utilizing WebSockets (with libwebsockets on the server). However, the JavaFX embedding makes use of neither WebSockets nor the DomTerm server; as a substitute Java purposes talk immediately utilizing the Java–JavaScript bridge.
A stable xterm-compatible terminal emulator
DomTerm appears and appears like a contemporary terminal emulator. It handles mouse occasions, 24-bit coloration, Unicode, double-width (CJK) characters, and enter strategies. DomTerm does an excellent job on the vttest testsuite.
Unusual options embrace:
Show/cover buttons (“folding”): The little triangles (seen in image 2 above) are buttons that cover/present the corresponding output. To create the buttons, simply add sure escape sequences within the prompt text.
Mouse-click help for readline
and comparable enter editors: If you click on within the (yellow) enter space, DomTerm will ship the suitable sequence of arrow-key keystrokes to the appliance. (This is enabled by escape sequences within the immediate; you may also pressure it utilizing Alt+Click.)
Style the terminal utilizing CSS: This is often accomplished in ~/.domterm/settings.ini
, which is routinely reloaded when saved. For instance, in image 2, terminal-specific background colours had been set.
A greater REPL console
A traditional terminal emulator works on rectangular grids of character cells. This works for a REPL (command shell), however it’s not perfect. Here are some DomTerm options helpful for REPLs that aren’t usually present in terminal emulators:
A command can “print” a picture, a graph, a mathematical components, or a set of clickable hyperlinks: An software can ship an escape sequence containing virtually any HTML. (The HTML is scrubbed to take away JavaScript and different harmful options.)
The image 3 exhibits a fraction from a gnuplot
session. Gnuplot (2.1 or later) helps domterm
as a terminal kind. Graphical output is transformed to an SVG image, which is then printed to the terminal. My weblog publish Gnuplot display on DomTerm supplies extra info on this.
The Kawa language has a library for creating and remodeling geometric picture values. If you print such an image worth to a DomTerm terminal, the image is transformed to SVG and embedded within the output.
Rich textual content in output: Help messages are extra readable and look nicer with HTML styling. The decrease pane of image 1 exhibits the ouput from domterm assist
. (The output is plaintext if not working underneath DomTerm.) Note the PAUSED
message from the built-in pager.
Error messages can embrace clickable hyperlinks: DomTerm acknowledges the syntax filename:line:column:
and turns it right into a hyperlink that opens the file and line in a configurable textual content editor. (This works for relative filenames in the event you use PROMPT_COMMAND
or just like monitor directories.)
A compiler can detect that it’s working underneath DomTerm and immediately emit file hyperlinks in an escape sequence. This is extra strong than relying on DomTerm’s sample matching, because it handles areas and different particular characters, and it doesn’t rely upon listing monitoring. In image 4, you possibly can see error messages from the Kawa compiler. Hovering over the file place causes it to be underlined, and the file:
URL exhibits within the atom-domterm
message space (backside of the window). (When not utilizing atom-domterm
, such messages are proven in an overlay field, as seen for the PAUSED
message in image 1.)
The motion when clicking on a hyperlink is configurable. The default motion for a file:
hyperlink with a #place
suffix is to open the file in a textual content editor.
Structured inside illustration: The following are all represented within the inside node construction: Commands, prompts, enter strains, regular and error output, tabs, and preserving the construction in the event you “Save as HTML.” The HTML file is appropriate with XML, so you should utilize XML instruments to look or remodel the output. The command domterm view-saved
opens a saved HTML file in a method that allows command folding (present/cover buttons are lively) and reflow on window resize.
Built-in Lisp-style pretty-printing: You can embrace pretty-printing directives (e.g., grouping) within the output such that line breaks are recalculated on window resize. See my article Dynamic pretty-printing in DomTerm for a deeper dialogue.
Basic built-in line enhancing with historical past (like GNU readline
): This makes use of the browser’s built-in editor, so it has nice mouse and choice dealing with. You can swap between regular character-mode (most characters typed are despatched on to the method); or line-mode (common characters are inserted whereas management characters trigger enhancing actions, with Enter sending the edited line to the method). The default is automated mode, the place DomTerm switches between character-mode and line-mode relying on whether or not the PTY is in uncooked
or
canonical
mode.
A built-in pager (like a simplified much less
): Keyboard shortcuts will management scrolling. In “paging mode,” the output pauses after every new display screen (or single line, in the event you transfer ahead line-by-line). The paging mode is unobtrusive and good about consumer enter, so you possibly can (if you want) run it with out it interfering with interactive applications.
Multiplexing and classes
Tabs and tiling: Not solely are you able to create a number of terminal tabs, you may also tile them. You can use both the mouse or a keyboard shortcut to maneuver between panes and tabs in addition to create new ones. They will be rearranged and resized with the mouse. This is applied utilizing the GoldenLayout JavaScript library. Image 1 exhibits a window with two panes. The prime one has two tabs, with one working Midnight Commander; the underside pane exhibits domterm assist
output as HTML. However, on Atom we as a substitute use its built-in draggable tiles and tabs; you possibly can see this in image 2.
Detaching and reattaching to classes: DomTerm helps classes association, just like tmux
and GNU display screen
. You may even connect a number of home windows or panes to the identical session. This helps multi-user session sharing and distant connections. (For safety, all classes of the identical server want to have the ability to learn a Unix area socket and an area file containing a random key. This restriction can be lifted when we have now an excellent, protected remote-access story.)
The domterm
command can also be like tmux
or GNU display screen
in that has a number of choices for controlling or beginning a server that manages a number of classes. The main distinction is that, if it isn’t already working underneath DomTerm, the domterm
command creates a brand new top-level window, fairly than working within the present terminal.
The domterm
command has plenty of sub-commands, just like tmux
or git
. Some sub-commands create home windows or classes. Others (akin to “printing” a picture) solely work inside an present DomTerm session.
The command domterm browse
opens a window or pane for looking a specified URL, akin to when looking documentation.
Getting and putting in DomTerm
DomTerm is offered from its GitHub repository. Currently, there aren’t any prebuilt packages, however there are detailed instructions. All stipulations can be found on Fedora 27, which makes it particularly straightforward to construct.