1
1
# JWebTerminal - a web-based console
2
2
3
3
JWebTerminal implements a general-purpose interactive console:
4
- Users can type commands which get sent to a command handler ,
4
+ Users can type commands which gets sent to an application ,
5
5
which evaluates the command, and displays the results, typically
6
6
in some kind of type-script format.
7
7
8
8
There are two basic modes:
9
9
- In line-editing mode each input line is an input field you
10
10
edit locally (in the browser). The finished line is sent to the
11
- client when you type Enter.
12
- - In character mode each character is sent directly to the client ,
11
+ application when you type Enter.
12
+ - In character mode each character is sent directly to the application ,
13
13
which is also responsible for input echoing.
14
14
15
15
Applications of JWebTerminal include:
@@ -18,7 +18,13 @@ Applications of JWebTerminal include:
18
18
- A command console.
19
19
- A terminal emulator.
20
20
21
- WebTerminal recognizes a large subset of the standard ANSI/xterm
21
+ JWebTerminal is a rough and incomplete prototype. It is meant to
22
+ demo my belief that a modern terminal emulator should be based
23
+ on a web browser engine. It seems reasonable to re-write the "guts"
24
+ of the terminal emulator code in JavaScript (rather than Java),
25
+ to make the code useful in non-Java context.
26
+
27
+ JWebTerminal recognizes a large subset of the standard ANSI/xterm
22
28
terminal escape sequences for repositioning the cursor, erasing
23
29
previous text, changing style, etc. Enough of a subset is recognized
24
30
that you can run programs like the emacs text editor, with styling.
@@ -32,15 +38,37 @@ The terminfo directory defines the escape sequences supported by the
32
38
"jfxterm" terminal type, using a terminfo descriptor. The terminal emulation
33
39
is a subset of the standard xterm/ansi/vt100 ones.
34
40
41
+ JWebTerminal handles automatic line-wrapping, distinguishing between
42
+ explicit line-breaks and those caused by line-wrapping. This allows
43
+ for re-flow on windows re-size (though that is not yet implemented),
44
+ and "intelligent" cut-and-paste (also not yet implemented).
45
+
35
46
There is an escape sequence to send HTML to WebTerminal.
36
47
This allows you to embed images, forms, and other HTML elements
37
48
in the console output.
38
49
39
50
The primary class is webterminal.WebTerminal, which is
40
- an abstract (overridable) control you embed in your scenegraph.
51
+ an abstract (overridable) control you embed in your JavaFX scenegraph.
52
+
53
+ ## Building and running
54
+
55
+ The prototype requires not only Java, but specifically JavaFX 2.x.
56
+ The latter is bundled with JDK 8.x. JavaFX is also distributed
57
+ with newer releases of JDK 7.x; however, you may have to manually
58
+ set the classpath to include jfxrt.jar.
59
+
60
+ Build the library and sample applications with the Ant tool:
61
+ $ ant
62
+
63
+ The PtyConsole requires non-portable native code, so it is
64
+ not built by default. Build it with:
65
+ $ ant all
41
66
42
67
## Sample Applications
43
68
69
+ These sample applications are very simple. There is currently no
70
+ menues or other "chrome" beside the actual WebTerminal window.
71
+
44
72
#### RunInConsole
45
73
46
74
The utility class webterminal.RunInConsole make it easy to
@@ -49,11 +77,16 @@ It re-binds System.in, System.out, and System.err to the WebTerminal.
49
77
50
78
For example, the jrunscript tool is a wrapper around the class
51
79
com.sun.tools.script.shell.Main in tools.jar. So to start up
52
- a JavaScript read-elal-print-tool, do:
80
+ a JavaScript read-eval-print-tool, do:
81
+
82
+ $ ant run-main -Drunmain.classpath=$JAVA_HOME/lib/tools.jar \
83
+ -Drunmain.class="com.sun.tools.script.shell.Main" \
84
+ -Drunmain.args="-l javascript"
85
+ or:
86
+ $ java -cp dist/WebTerminal.jar:${JAVA_HOME}/lib/tools.jar \
87
+ webterminal.RunInConsole com.sun.tools.script.shell.Main -l javascript
53
88
54
- $ ant run-main -Drunmain.classpath=$JAVA_HOME/lib/tools.jar \
55
- -Drunmain.class="com.sun.tools.script.shell.Main" \
56
- -Drunmain.args="-l javascript"
89
+ This uses line-editing mode.
57
90
58
91
#### ShellConsole
59
92
@@ -62,6 +95,14 @@ to run a process inside a WebTerminal. Currently, it is hard-wired to
62
95
run /bin/bash. (It does work under Cygwin if you edit the
63
96
commandWithArgs field.)
64
97
98
+ You can start this using Ant:
99
+ $ ant run
100
+ or directly:
101
+ $ java -cp dist/WebTerminal.jar:${JAVA_HOME}/lib/tools.jar \
102
+ webterminal.ShellConsole
103
+
104
+ This also uses line-editing mode.
105
+
65
106
#### PtyConsole
66
107
67
108
An application that implements a terminal emulator
@@ -75,3 +116,7 @@ pseudo-teletypes. At the time of writing it has only been tested on
75
116
GNU/Linux Fedora 21; it may need some porting effort on older
76
117
or non-Linux platforms, especially Windows.
77
118
119
+ You can run this with Ant:
120
+ $ ant run-pty
121
+
122
+ This uses character mode.
0 commit comments