CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-codehaus-groovy--groovy-console

A Swing-based interactive console for evaluating Groovy expressions and scripts with syntax highlighting, code completion, and an integrated AST browser.

Pending
Overview
Eval results
Files

system-integration.mddocs/

System Integration

The Groovy Console provides comprehensive system integration features including output capture, preferences management, platform-specific UI adaptations, and dependency management through Apache Ivy.

System Output Capture

class SystemOutputInterceptor extends FilterOutputStream {
    // Constructor
    SystemOutputInterceptor(OutputStream out)
    
    // Inherits all FilterOutputStream methods for output redirection
}

Parameters

Constructor Parameters:

  • out (OutputStream): Target output stream to redirect system output to

Usage

The SystemOutputInterceptor captures System.out and System.err output from executed scripts and redirects it to the console's output area.

Preferences Management

class ConsolePreferences {
    // Constructor
    ConsolePreferences()
    
    // Configuration methods for console settings
}

The ConsolePreferences class manages persistent configuration settings for the console including:

  • Font settings and display preferences
  • Editor behavior configuration
  • Window size and layout preferences
  • Syntax highlighting options

Abstract Console Support

abstract class ConsoleSupport {
    // Abstract base class providing common console utilities
}

ConsoleSupport provides foundational functionality shared across different console implementations.

History Management

class HistoryRecord {
    // Manages console command and execution history
}

The HistoryRecord class maintains:

  • Command execution history
  • Script content and results
  • Execution timestamps and context
  • History navigation and replay capabilities

Output Processing

class OutputTransforms {
    // Output transformation and formatting utilities
}

OutputTransforms provides utilities for:

  • Formatting script execution results
  • Converting objects to display-friendly representations
  • Applying syntax highlighting to output
  • Managing output length and truncation

UI Framework Components

Console Actions

// ConsoleActions.groovy - Defines all UI actions for menu items and toolbar buttons
// Contains action definitions including:
// - newFileAction, newWindowAction, openAction
// - saveAction, saveAsAction, printAction  
// - undoAction, redoAction, cutAction, copyAction, pasteAction
// - runAction, runSelectionAction, stopAction
// - inspectLastAction, inspectVariablesAction, inspectAstAction
// - clearOutputAction, aboutAction, preferencesAction
// - And many more UI actions with their keyboard shortcuts and icons

ConsoleActions defines all the Swing Actions used throughout the console interface, providing consistent behavior for menu items, toolbar buttons, and keyboard shortcuts.

Console View

// ConsoleView.groovy - Platform-aware UI view configuration
// Automatically detects system Look-and-Feel and applies appropriate defaults:
// - Windows: WindowsDefaults
// - macOS: MacOSXDefaults  
// - GTK/Linux: GTKDefaults
// - Default: Defaults

ConsoleView handles platform-specific UI configuration, automatically detecting the system's look-and-feel and applying the appropriate UI defaults for optimal native integration.

Platform-Specific UI Components

Basic UI Components

class BasicMenuBar {
    // Cross-platform menu bar implementation
}

class BasicToolBar {
    // Cross-platform toolbar implementation
}

class BasicStatusBar {
    // Cross-platform status bar implementation
}

class BasicContentPane {
    // Cross-platform content pane layout
}

Platform Defaults

class Defaults {
    // Base UI defaults and theming
}

class MacOSXDefaults {
    // macOS-specific UI defaults and native integration
}

class WindowsDefaults {
    // Windows-specific UI defaults and native integration
}

class GTKDefaults {
    // GTK/Linux-specific UI defaults and native integration
}

macOS Integration

class MacOSXMenuBar {
    // macOS-specific menu bar with native integration
}

class ConsoleMacOsSupport implements MRJQuitHandler, MRJAboutHandler, MRJPrefsHandler {
    // macOS-specific handlers for system events
}

Ivy Dependency Management

class ConsoleIvyPlugin {
    // Apache Ivy integration for dependency management
}

The ConsoleIvyPlugin provides:

  • Dynamic dependency resolution
  • Classpath management for scripts
  • Repository configuration
  • Dependency download and caching

Usage Examples

System Output Capture

def outputStream = new ByteArrayOutputStream()
def interceptor = new groovy.console.ui.SystemOutputInterceptor(outputStream)

// Redirect system output
def originalOut = System.out
System.setOut(new PrintStream(interceptor))

// Execute script - output will be captured
println "This will be captured"

// Restore original output
System.setOut(originalOut)

// Get captured output
def capturedOutput = outputStream.toString()

Console Preferences

def preferences = new groovy.console.ui.ConsolePreferences()

// Configure console settings
// (Specific configuration methods depend on implementation)

Platform-Specific UI Setup

// The console automatically detects platform and applies appropriate defaults
def console = new groovy.console.ui.Console()

// Platform-specific defaults are applied automatically:
// - macOS: Native menu bar integration, Mac-specific shortcuts
// - Windows: Windows look-and-feel, Windows-specific behaviors  
// - Linux/GTK: GTK theming and Linux conventions

History Management

// History is managed automatically by the console
// Access through console UI or programmatically through HistoryRecord

def console = new groovy.console.ui.Console()
// History navigation available through UI (up/down arrows, etc.)

Integration Points

Console-wide Integration

All system integration components work together:

  • Output Capture: Redirects script output to console display
  • Preferences: Persists user customizations across sessions
  • Platform UI: Provides native look and feel
  • History: Maintains session continuity
  • Ivy Plugin: Enables dynamic dependency management

Script Execution Context

During script execution:

  • System output is automatically captured and displayed
  • History records execution details
  • Platform-specific behaviors are applied
  • Dependencies can be resolved dynamically

Legacy API

The same system integration functionality is available in the legacy groovy.ui package:

// Legacy imports (same API as groovy.console.ui)
import groovy.ui.SystemOutputInterceptor
import groovy.ui.ConsolePreferences
import groovy.ui.ConsoleSupport
import groovy.ui.HistoryRecord
import groovy.ui.OutputTransforms
import groovy.ui.ConsoleIvyPlugin

Advanced Features

Multi-Platform Support

The console provides native integration on:

  • macOS: Native menu bar, Aqua look-and-feel, system event handling
  • Windows: Windows-specific UI elements, registry integration where appropriate
  • Linux/Unix: GTK theming, desktop environment integration

Output Management

Advanced output features:

  • Stream Redirection: Capture both stdout and stderr
  • Output Formatting: Syntax highlighting for different output types
  • Length Management: Automatic truncation of very long output
  • Export Options: Save output to files or clipboard

Dependency Management

Through the Ivy plugin:

  • Dynamic Resolution: Add dependencies at runtime
  • Repository Configuration: Connect to Maven Central, custom repositories
  • Classpath Updates: Automatically update script classpath
  • Version Management: Handle version conflicts and resolution

Install with Tessl CLI

npx tessl i tessl/maven-org-codehaus-groovy--groovy-console

docs

ast-browser.md

console-application.md

index.md

object-inspector.md

system-integration.md

text-editing.md

tile.json