feat: add Web and Swing Terminal Implementations #1348
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces two new terminal implementations built on top of the existing
ScreenTerminalclass, enabling JLine to be used in web applications and desktop GUI applications.New Features
🌐 WebTerminal
An HTTP-based terminal implementation that serves a web interface:
HttpServer(no external dependencies)🖥️ SwingTerminal
A Swing JComponent-based terminal for desktop applications:
Implementation Details
Architecture
ScreenTerminaland inherit full ANSI escape sequence supportCode Quality
Files Added
Core Implementation
builtins/src/main/java/org/jline/builtins/WebTerminal.java- Web-based terminalbuiltins/src/main/java/org/jline/builtins/SwingTerminal.java- Swing-based terminalbuiltins/src/main/java/org/jline/builtins/TerminalDemo.java- Demo applicationsTesting
builtins/src/test/java/org/jline/builtins/TerminalTest.java- Comprehensive test suitebuiltins/src/test/java/org/jline/builtins/SimpleTerminalTest.java- Basic functionality testsDocumentation
website/docs/advanced/web-swing-terminals.md- Complete user documentation with examplesFiles Modified
builtins/src/main/java/org/jline/builtins/ScreenTerminal.java- AddedgetWidth()andgetHeight()public methodswebsite/docs/modules/builtins.md- Added section about terminal implementationswebsite/sidebars.ts- Added new documentation page to navigationUsage Examples
WebTerminal
SwingTerminal
Demo Applications
The
TerminalDemoclass provides several demo modes:web- Web terminal demoswing- Basic Swing terminal demoadvanced- Advanced Swing terminal with menu bar and font selectionboth- Both terminals running simultaneouslyTesting
Backward Compatibility
ScreenTerminal(new public getter methods)Performance
Future Enhancements
Potential improvements identified for future versions:
Documentation
Comprehensive documentation has been added to the website including:
This feature significantly expands JLine's capabilities, enabling it to be used in web applications and desktop GUI applications while maintaining the same powerful terminal functionality that JLine is known for.
Pull Request opened by Augment Code with guidance from the PR author