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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @constructor
7 * @extends {WebInspector.VBox}
8 */
9 WebInspector.TerminalWidget = function()
10 {
11 WebInspector.VBox.call(this, false);
12 this.registerRequiredCSS("terminal/xterm.js/build/xterm.css");
13 this.registerRequiredCSS("terminal/terminal.css");
14 WebInspector.serviceManager.lookupService("Terminal").then(this._init.bind(t his));
15 this.element.addEventListener("mousemove", this._mouseMove.bind(this), false );
16 }
17
18 WebInspector.TerminalWidget.prototype = {
19 /**
20 * @param {?WebInspector.ServiceManager.Service} backend
21 */
22 _init: function(backend)
23 {
24 if (!backend) {
25 console.error("Terminal service not available.");
dgozman 2016/09/27 19:25:48 Let's show something instead of completely white w
26 return;
27 }
28
29 this._backend = backend;
30 this._term = new Terminal({ cursorBlink: true });
31 this._term.open(this.contentElement);
32 this._term.on("data", data => {
33 this._backend.send("write", { data: data });
34 });
35 this._term.on("resize", size => {
36 this._backend.send("resize", { cols: size.cols, rows: size.rows });
37 });
38 this._backend.send("init", { colos: 80, rows: 25 }).then(result => {
39 if (result)
40 this._term.fit();
41 });
42 this._backend.on("data", result => {
43 this._term.write(result.data);
44 this._linkifyUpToDate = false;
45 });
46 this._backend.on("disposed", this._disposed.bind(this));
47 },
48
49 _mouseMove: function()
50 {
51 if (this._linkifyUpToDate)
52 return;
53 this._term.linkify();
54 this._linkifyUpToDate = true;
55 },
56
57 onResize: function()
58 {
59 if (this._term)
60 this._term.fit();
61 },
62
63 _disposed: function()
64 {
65 this.contentElement.classList.add("disabled");
66 },
67
68 /**
69 * @override
70 */
71 wasDetachedFromHierarchy: function()
dgozman 2016/09/27 19:25:48 Does this ever happen in the drawer?
72 {
73 if (this._backend)
74 this._backend.dispose();
75 },
76
77 __proto__: WebInspector.VBox.prototype
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698