or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

ast-browser.mdconsole-application.mdindex.mdobject-inspector.mdsystem-integration.mdtext-editing.md

system-integration.mddocs/

0

# System Integration

1

2

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

3

4

## System Output Capture

5

6

```groovy { .api }

7

class SystemOutputInterceptor extends FilterOutputStream {

8

// Constructor

9

SystemOutputInterceptor(OutputStream out)

10

11

// Inherits all FilterOutputStream methods for output redirection

12

}

13

```

14

15

### Parameters

16

17

**Constructor Parameters:**

18

- `out` (OutputStream): Target output stream to redirect system output to

19

20

### Usage

21

22

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

23

24

## Preferences Management

25

26

```groovy { .api }

27

class ConsolePreferences {

28

// Constructor

29

ConsolePreferences()

30

31

// Configuration methods for console settings

32

}

33

```

34

35

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

36

- Font settings and display preferences

37

- Editor behavior configuration

38

- Window size and layout preferences

39

- Syntax highlighting options

40

41

## Abstract Console Support

42

43

```groovy { .api }

44

abstract class ConsoleSupport {

45

// Abstract base class providing common console utilities

46

}

47

```

48

49

ConsoleSupport provides foundational functionality shared across different console implementations.

50

51

## History Management

52

53

```groovy { .api }

54

class HistoryRecord {

55

// Manages console command and execution history

56

}

57

```

58

59

The HistoryRecord class maintains:

60

- Command execution history

61

- Script content and results

62

- Execution timestamps and context

63

- History navigation and replay capabilities

64

65

## Output Processing

66

67

```groovy { .api }

68

class OutputTransforms {

69

// Output transformation and formatting utilities

70

}

71

```

72

73

OutputTransforms provides utilities for:

74

- Formatting script execution results

75

- Converting objects to display-friendly representations

76

- Applying syntax highlighting to output

77

- Managing output length and truncation

78

79

## UI Framework Components

80

81

### Console Actions

82

83

```groovy { .api }

84

// ConsoleActions.groovy - Defines all UI actions for menu items and toolbar buttons

85

// Contains action definitions including:

86

// - newFileAction, newWindowAction, openAction

87

// - saveAction, saveAsAction, printAction

88

// - undoAction, redoAction, cutAction, copyAction, pasteAction

89

// - runAction, runSelectionAction, stopAction

90

// - inspectLastAction, inspectVariablesAction, inspectAstAction

91

// - clearOutputAction, aboutAction, preferencesAction

92

// - And many more UI actions with their keyboard shortcuts and icons

93

```

94

95

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

96

97

### Console View

98

99

```groovy { .api }

100

// ConsoleView.groovy - Platform-aware UI view configuration

101

// Automatically detects system Look-and-Feel and applies appropriate defaults:

102

// - Windows: WindowsDefaults

103

// - macOS: MacOSXDefaults

104

// - GTK/Linux: GTKDefaults

105

// - Default: Defaults

106

```

107

108

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

109

110

## Platform-Specific UI Components

111

112

### Basic UI Components

113

114

```groovy { .api }

115

class BasicMenuBar {

116

// Cross-platform menu bar implementation

117

}

118

119

class BasicToolBar {

120

// Cross-platform toolbar implementation

121

}

122

123

class BasicStatusBar {

124

// Cross-platform status bar implementation

125

}

126

127

class BasicContentPane {

128

// Cross-platform content pane layout

129

}

130

```

131

132

### Platform Defaults

133

134

```groovy { .api }

135

class Defaults {

136

// Base UI defaults and theming

137

}

138

139

class MacOSXDefaults {

140

// macOS-specific UI defaults and native integration

141

}

142

143

class WindowsDefaults {

144

// Windows-specific UI defaults and native integration

145

}

146

147

class GTKDefaults {

148

// GTK/Linux-specific UI defaults and native integration

149

}

150

```

151

152

### macOS Integration

153

154

```groovy { .api }

155

class MacOSXMenuBar {

156

// macOS-specific menu bar with native integration

157

}

158

159

class ConsoleMacOsSupport implements MRJQuitHandler, MRJAboutHandler, MRJPrefsHandler {

160

// macOS-specific handlers for system events

161

}

162

```

163

164

## Ivy Dependency Management

165

166

```groovy { .api }

167

class ConsoleIvyPlugin {

168

// Apache Ivy integration for dependency management

169

}

170

```

171

172

The ConsoleIvyPlugin provides:

173

- Dynamic dependency resolution

174

- Classpath management for scripts

175

- Repository configuration

176

- Dependency download and caching

177

178

## Usage Examples

179

180

### System Output Capture

181

182

```groovy

183

def outputStream = new ByteArrayOutputStream()

184

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

185

186

// Redirect system output

187

def originalOut = System.out

188

System.setOut(new PrintStream(interceptor))

189

190

// Execute script - output will be captured

191

println "This will be captured"

192

193

// Restore original output

194

System.setOut(originalOut)

195

196

// Get captured output

197

def capturedOutput = outputStream.toString()

198

```

199

200

### Console Preferences

201

202

```groovy

203

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

204

205

// Configure console settings

206

// (Specific configuration methods depend on implementation)

207

```

208

209

### Platform-Specific UI Setup

210

211

```groovy

212

// The console automatically detects platform and applies appropriate defaults

213

def console = new groovy.console.ui.Console()

214

215

// Platform-specific defaults are applied automatically:

216

// - macOS: Native menu bar integration, Mac-specific shortcuts

217

// - Windows: Windows look-and-feel, Windows-specific behaviors

218

// - Linux/GTK: GTK theming and Linux conventions

219

```

220

221

### History Management

222

223

```groovy

224

// History is managed automatically by the console

225

// Access through console UI or programmatically through HistoryRecord

226

227

def console = new groovy.console.ui.Console()

228

// History navigation available through UI (up/down arrows, etc.)

229

```

230

231

## Integration Points

232

233

### Console-wide Integration

234

235

All system integration components work together:

236

- **Output Capture**: Redirects script output to console display

237

- **Preferences**: Persists user customizations across sessions

238

- **Platform UI**: Provides native look and feel

239

- **History**: Maintains session continuity

240

- **Ivy Plugin**: Enables dynamic dependency management

241

242

### Script Execution Context

243

244

During script execution:

245

- System output is automatically captured and displayed

246

- History records execution details

247

- Platform-specific behaviors are applied

248

- Dependencies can be resolved dynamically

249

250

## Legacy API

251

252

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

253

254

```groovy

255

// Legacy imports (same API as groovy.console.ui)

256

import groovy.ui.SystemOutputInterceptor

257

import groovy.ui.ConsolePreferences

258

import groovy.ui.ConsoleSupport

259

import groovy.ui.HistoryRecord

260

import groovy.ui.OutputTransforms

261

import groovy.ui.ConsoleIvyPlugin

262

```

263

264

## Advanced Features

265

266

### Multi-Platform Support

267

268

The console provides native integration on:

269

- **macOS**: Native menu bar, Aqua look-and-feel, system event handling

270

- **Windows**: Windows-specific UI elements, registry integration where appropriate

271

- **Linux/Unix**: GTK theming, desktop environment integration

272

273

### Output Management

274

275

Advanced output features:

276

- **Stream Redirection**: Capture both stdout and stderr

277

- **Output Formatting**: Syntax highlighting for different output types

278

- **Length Management**: Automatic truncation of very long output

279

- **Export Options**: Save output to files or clipboard

280

281

### Dependency Management

282

283

Through the Ivy plugin:

284

- **Dynamic Resolution**: Add dependencies at runtime

285

- **Repository Configuration**: Connect to Maven Central, custom repositories

286

- **Classpath Updates**: Automatically update script classpath

287

- **Version Management**: Handle version conflicts and resolution