Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Unified Diff: third_party/WebKit/Source/devtools/front_end/terminal/TerminalWidget.js

Issue 2372303003: DevTools: introduce external service client (behind experiment). (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/terminal/TerminalWidget.js
diff --git a/third_party/WebKit/Source/devtools/front_end/terminal/TerminalWidget.js b/third_party/WebKit/Source/devtools/front_end/terminal/TerminalWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..895bd80742a1d2aa17fcfa2b0a24a44ff6a560cd
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/terminal/TerminalWidget.js
@@ -0,0 +1,78 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @constructor
+ * @extends {WebInspector.VBox}
+ */
+WebInspector.TerminalWidget = function()
+{
+ WebInspector.VBox.call(this, false);
+ this.registerRequiredCSS("terminal/xterm.js/build/xterm.css");
+ this.registerRequiredCSS("terminal/terminal.css");
+ WebInspector.serviceManager.lookupService("Terminal").then(this._init.bind(this));
+ this.element.addEventListener("mousemove", this._mouseMove.bind(this), false);
+}
+
+WebInspector.TerminalWidget.prototype = {
+ /**
+ * @param {?WebInspector.ServiceManager.Service} backend
+ */
+ _init: function(backend)
+ {
+ if (!backend) {
+ console.error("Terminal service not available.");
dgozman 2016/09/27 19:25:48 Let's show something instead of completely white w
+ return;
+ }
+
+ this._backend = backend;
+ this._term = new Terminal({ cursorBlink: true });
+ this._term.open(this.contentElement);
+ this._term.on("data", data => {
+ this._backend.send("write", { data: data });
+ });
+ this._term.on("resize", size => {
+ this._backend.send("resize", { cols: size.cols, rows: size.rows });
+ });
+ this._backend.send("init", { colos: 80, rows: 25 }).then(result => {
+ if (result)
+ this._term.fit();
+ });
+ this._backend.on("data", result => {
+ this._term.write(result.data);
+ this._linkifyUpToDate = false;
+ });
+ this._backend.on("disposed", this._disposed.bind(this));
+ },
+
+ _mouseMove: function()
+ {
+ if (this._linkifyUpToDate)
+ return;
+ this._term.linkify();
+ this._linkifyUpToDate = true;
+ },
+
+ onResize: function()
+ {
+ if (this._term)
+ this._term.fit();
+ },
+
+ _disposed: function()
+ {
+ this.contentElement.classList.add("disabled");
+ },
+
+ /**
+ * @override
+ */
+ wasDetachedFromHierarchy: function()
dgozman 2016/09/27 19:25:48 Does this ever happen in the drawer?
+ {
+ if (this._backend)
+ this._backend.dispose();
+ },
+
+ __proto__: WebInspector.VBox.prototype
+}

Powered by Google App Engine
This is Rietveld 408576698