Twinkle is a Java framework for creating text-based user interfaces (TUIs) in terminal emulators. It provides a layered architecture with components for text manipulation, screen rendering, shapes/borders, image encoding, and terminal abstraction.
The project follows a layered architecture:
- Foundation: Text utilities and ANSI escape code support
- Rendering: Screen buffers and double-buffering for flicker-free rendering
- UI Components: Drawing utilities for borders and shapes
- Terminal Access: Abstraction layer with pluggable implementations
-
twinkle-text- Core text handling and utilities for terminal applications- Position, Size, and dimension management
- Unicode character utilities
- Text sequence processing
- ANSI escape codes (colors, styles, hyperlinks, mouse events)
- Fluent API for building styled text with markup parsing
-
twinkle-screen- Screen and buffer management for rendering contentBuffer- 2D renderable buffer with styled text and colorsSwappableBuffer- Double-buffering for flicker-free renderingBufferStack- Stack-based buffer management for layering- Buffer I/O utilities
-
twinkle-shapes- ASCII-based drawing utilities and UI components- Border drawing with various styles (ASCII, single-line, rounded)
- Line and corner styles
- Drawing utilities
-
twinkle-terminal- Terminal access and management abstraction APITerminalinterface for terminal operations- Service provider interface for different implementations
- Support for terminal sizing and resize callbacks
-
twinkle-terminal-aesh- Terminal implementation using the Aesh library -
twinkle-terminal-jline- Terminal implementation using the JLine 3 library -
twinkle-terminal-miniterm- Terminal implementation using the java-miniterm library
examples- Example programs demonstrating Twinkle capabilitiesBouncingTwinkleDemo- Animated demo with bouncing text and ASCII borders
To build the project, run the following command:
./mvnw clean packageAfter building, you can run the example programs to see Twinkle in action. This is most easily done using JBang:
# Bouncing animation demo
jbang bounceOr if you want to use regular Java commands:
# Bouncing animation demo
java -jar examples/target/examples-1.0-SNAPSHOT.jar org.codejive.twinkle.examples.BouncingTwinkleDemo- Java 8 or higher (tests require Java 21)
- A terminal emulator with ANSI support
- For image rendering: Terminal with Sixel, Kitty, iTerm2, or Unicode block support