javaterminal / TerminalFX

Java FX Terminal Emulator
MIT License
277 stars 52 forks source link
java javafx shell terminal terminal-emulators

= JavaFX Terminal Emulator Rahman Usta :doctype: article :encoding: utf-8 :lang: en :toc: left :numbered: :terminalfx-version: 1.2.0

== JavaFX Terminal Emulator

TerminalFX is a terminal (PTY) emulator application written in JavaFX 18.

We use https://github.com/traff/pty4j[Pty4J] to get VT codes from running process and https://chromium.googlesource.com/apps/libapps/+/master/hterm/[hterm.js] from Chromium project to interact with Pty4J. TerminalFX is using powerful JavaFX WebView component to run hterm.js.

== Features

== Usage

.Default Config [source,java]

TerminalBuilder terminalBuilder = new TerminalBuilder(); TerminalTab terminal = terminalBuilder.newTerminal();

TabPane tabPane = new TabPane(); tabPane.getTabs().add(terminal);

image::images\default.png[]

.Dark Config [source,java]

TerminalConfig darkConfig = new TerminalConfig(); darkConfig.setBackgroundColor(Color.rgb(16, 16, 16)); darkConfig.setForegroundColor(Color.rgb(240, 240, 240)); darkConfig.setCursorColor(Color.rgb(255, 0, 0, 0.5));

TerminalBuilder terminalBuilder = new TerminalBuilder(darkConfig); TerminalTab terminal = terminalBuilder.newTerminal();

TabPane tabPane = new TabPane(); tabPane.getTabs().add(terminal);

image::images\dark.png[]

== CygWin Support

[source,java]

TerminalConfig cygwinConfig = new TerminalConfig(); cygwinConfig.setWindowsTerminalStarter("C:\cygwin64\bin\bash -i"); <1>

TerminalBuilder terminalBuilder = new TerminalBuilder(cygwinConfig); TerminalTab terminal = terminalBuilder.newTerminal();

TabPane tabPane = new TabPane(); tabPane.getTabs().add(terminal);

<1> Set bash in cygwin path image::images\cygwin.png[] == Maven Dependency [source,xml] ---- terminalfx-repo https://github.com/javaterminal/terminalfx/raw/master/releases com.kodedu.terminalfx terminalfx 1.2.0 com.kodedu.terminalfx terminalfx 1.0.8 ---- == Compile & Run [source,bash] ---- git clone https://github.com/rahmanusta/TerminalFX cd TerminalFX mvn clean install mvn javafx:run ---- == Run as Java Module (Java 17) The following modules have to be added in JVM parameters ---- --add-modules=javafx.controls,javafx.graphics ---- == Run command You can run commands: [source,bash] ---- terminal.onTerminalFxReady(() -> { terminal.getTerminal().command("java -version\r"); }); ---- == Licence This project is licensed under the MIT license. See link:LICENSE[LICENSE] for more information.