| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.TerminalWidget = class extends WebInspector.VBox { | 7 Terminal.TerminalWidget = class extends UI.VBox { |
| 8 constructor() { | 8 constructor() { |
| 9 super(false); | 9 super(false); |
| 10 this.registerRequiredCSS('terminal/xterm.js/build/xterm.css'); | 10 this.registerRequiredCSS('terminal/xterm.js/build/xterm.css'); |
| 11 this.registerRequiredCSS('terminal/terminal.css'); | 11 this.registerRequiredCSS('terminal/terminal.css'); |
| 12 this.element.classList.add('terminal-root'); | 12 this.element.classList.add('terminal-root'); |
| 13 this.element.addEventListener('mousemove', this._mouseMove.bind(this), false
); | 13 this.element.addEventListener('mousemove', this._mouseMove.bind(this), false
); |
| 14 this._init(); | 14 this._init(); |
| 15 this._linkifier = new WebInspector.Linkifier(); | 15 this._linkifier = new Components.Linkifier(); |
| 16 this._linkifyFunction = this._linkifyURL.bind(this); | 16 this._linkifyFunction = this._linkifyURL.bind(this); |
| 17 } | 17 } |
| 18 | 18 |
| 19 _init() { | 19 _init() { |
| 20 WebInspector.serviceManager.createRemoteService('Terminal').then(this._initi
alized.bind(this)); | 20 Services.serviceManager.createRemoteService('Terminal').then(this._initializ
ed.bind(this)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * @param {?WebInspector.ServiceManager.Service} backend | 24 * @param {?Services.ServiceManager.Service} backend |
| 25 */ | 25 */ |
| 26 _initialized(backend) { | 26 _initialized(backend) { |
| 27 if (!backend) { | 27 if (!backend) { |
| 28 if (!this._unavailableLabel) { | 28 if (!this._unavailableLabel) { |
| 29 this._unavailableLabel = this.element.createChild('div', 'terminal-error
-message fill'); | 29 this._unavailableLabel = this.element.createChild('div', 'terminal-error
-message fill'); |
| 30 this._unavailableLabel.createChild('div').textContent = | 30 this._unavailableLabel.createChild('div').textContent = |
| 31 WebInspector.UIString('Terminal service is not available'); | 31 Common.UIString('Terminal service is not available'); |
| 32 } | 32 } |
| 33 if (this.isShowing()) | 33 if (this.isShowing()) |
| 34 setTimeout(this._init.bind(this), 2000); | 34 setTimeout(this._init.bind(this), 2000); |
| 35 return; | 35 return; |
| 36 } | 36 } |
| 37 | 37 |
| 38 if (this._unavailableLabel) { | 38 if (this._unavailableLabel) { |
| 39 this._unavailableLabel.remove(); | 39 this._unavailableLabel.remove(); |
| 40 delete this._unavailableLabel; | 40 delete this._unavailableLabel; |
| 41 } | 41 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 */ | 104 */ |
| 105 _linkifyTerminalLine(line) { | 105 _linkifyTerminalLine(line) { |
| 106 var node = line.firstChild; | 106 var node = line.firstChild; |
| 107 while (node) { | 107 while (node) { |
| 108 if (node.nodeType !== Node.TEXT_NODE) { | 108 if (node.nodeType !== Node.TEXT_NODE) { |
| 109 node = node.nextSibling; | 109 node = node.nextSibling; |
| 110 continue; | 110 continue; |
| 111 } | 111 } |
| 112 var nextNode = node.nextSibling; | 112 var nextNode = node.nextSibling; |
| 113 node.remove(); | 113 node.remove(); |
| 114 var linkified = WebInspector.linkifyStringAsFragmentWithCustomLinkifier(no
de.textContent, this._linkifyFunction); | 114 var linkified = Components.linkifyStringAsFragmentWithCustomLinkifier(node
.textContent, this._linkifyFunction); |
| 115 line.insertBefore(linkified, nextNode); | 115 line.insertBefore(linkified, nextNode); |
| 116 node = nextNode; | 116 node = nextNode; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 /** | 120 /** |
| 121 * @param {string} title | 121 * @param {string} title |
| 122 * @param {string} url | 122 * @param {string} url |
| 123 * @param {number=} lineNumber | 123 * @param {number=} lineNumber |
| 124 * @param {number=} columnNumber | 124 * @param {number=} columnNumber |
| 125 */ | 125 */ |
| 126 _linkifyURL(title, url, lineNumber, columnNumber) { | 126 _linkifyURL(title, url, lineNumber, columnNumber) { |
| 127 return this._linkifier.linkifyScriptLocation(null, null, url, lineNumber ||
0, columnNumber || 0); | 127 return this._linkifier.linkifyScriptLocation(null, null, url, lineNumber ||
0, columnNumber || 0); |
| 128 } | 128 } |
| 129 }; | 129 }; |
| OLD | NEW |