wip
This commit is contained in:
75
README.md
Normal file
75
README.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# jlibghostty
|
||||
|
||||
Java FFM bindings for Ghostty's `libghostty-vt`.
|
||||
|
||||
This targets Java 22+ and uses `java.lang.foreign`, not JNI. The public API is intentionally small while Ghostty's C API is still marked unstable upstream.
|
||||
|
||||
## Build
|
||||
|
||||
```sh
|
||||
nix build
|
||||
```
|
||||
|
||||
The default Nix package builds:
|
||||
|
||||
- `share/java/jlibghostty-0.1.0-SNAPSHOT.jar`
|
||||
- `maven/dev/jlibghostty/jlibghostty/0.1.0-SNAPSHOT/...`
|
||||
|
||||
The jar contains the host platform `libghostty-vt` under `dev/jlibghostty/native/<platform>/`.
|
||||
|
||||
## Gradle Consumer
|
||||
|
||||
After `nix build`, another Gradle project can consume the generated Maven repository:
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
maven {
|
||||
url = uri("/home/anon/Dev/jlibghostty/result/maven")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("dev.jlibghostty:jlibghostty:0.1.0-SNAPSHOT")
|
||||
}
|
||||
|
||||
tasks.withType<JavaExec>().configureEach {
|
||||
jvmArgs("--enable-native-access=ALL-UNNAMED")
|
||||
}
|
||||
```
|
||||
|
||||
If the app runs on the module path, use:
|
||||
|
||||
```sh
|
||||
--enable-native-access=dev.jlibghostty
|
||||
```
|
||||
|
||||
## External Native Library
|
||||
|
||||
The library normally loads the bundled native `libghostty-vt`. To override it:
|
||||
|
||||
```sh
|
||||
java -Djlibghostty.library.path=/path/to/libghostty-vt.so ...
|
||||
```
|
||||
|
||||
or set:
|
||||
|
||||
```sh
|
||||
export JLIBGHOSTTY_LIBRARY=/path/to/libghostty-vt.so
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```java
|
||||
try (Terminal terminal = Ghostty.open(TerminalOptions.of(80, 24))) {
|
||||
terminal.write("hello\r\n");
|
||||
System.out.println(terminal.snapshot());
|
||||
}
|
||||
```
|
||||
|
||||
## Development Shell
|
||||
|
||||
```sh
|
||||
nix develop
|
||||
```
|
||||
|
||||
The shell provides Java, Gradle, and `JLIBGHOSTTY_LIBRARY` pointing at the Nix-built `libghostty-vt`.
|
||||
Reference in New Issue
Block a user