in lib/playground.dart [495:569]
void _initPlayground() {
// Set up the iframe.
executionService = ExecutionServiceIFrame(_frame);
executionService.onStdout.listen(showOutput);
executionService.onStderr.listen((m) => showOutput(m, error: true));
// Set up Google Analytics.
deps[Analytics] = Analytics();
// Set up the gist loader.
deps[GistLoader] = GistLoader.defaultFilters();
// Set up CodeMirror
editor = (editorFactory as CodeMirrorFactory)
.createFromElement(_editorHost, options: codeMirrorOptions)
..theme = 'darkpad'
..mode = 'dart'
..showLineNumbers = true;
initKeyBindings();
context = PlaygroundContext(editor);
deps[Context] = context;
editorFactory.registerCompleter(
'dart', DartCompleter(dartServices, context.dartDocument));
context.onDartDirty.listen((_) => busyLight.on());
context.onDartReconcile.listen((_) => performAnalysis());
final Property htmlFile =
GistFileProperty(_editableGist.getGistFile('index.html'));
final Property htmlDoc =
EditorDocumentProperty(context.htmlDocument, 'html');
bind(htmlDoc, htmlFile);
bind(htmlFile, htmlDoc);
final Property cssFile =
GistFileProperty(_editableGist.getGistFile('styles.css'));
final Property cssDoc = EditorDocumentProperty(context.cssDocument, 'css');
bind(cssDoc, cssFile);
bind(cssFile, cssDoc);
final Property dartFile =
GistFileProperty(_editableGist.getGistFile('main.dart'));
final Property dartDoc =
EditorDocumentProperty(context.dartDocument, 'dart');
bind(dartDoc, dartFile);
bind(dartFile, dartDoc);
// Listen for changes that would effect the documentation panel.
editor.onMouseDown.listen((e) {
// Delay to give codemirror time to process the mouse event.
Timer.run(() {
if (!context.cursorPositionIsWhitespace()) {
_docHandler.generateDoc([_rightDocContentElement, _leftDocPanel]);
}
});
});
_docHandler = DocHandler(editor, context);
updateVersions();
analysisResultsController = AnalysisResultsController(
DElement(querySelector('#issues')!),
DElement(querySelector('#issues-message')!),
DElement(querySelector('#issues-toggle')!),
snackbar,
)..onItemClicked.listen((item) {
_jumpTo(item.line, item.charStart, item.charLength, focus: true);
});
_finishedInit();
}