| 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 Console.ConsolePrompt = class extends UI.Widget { | 7 Console.ConsolePrompt = class extends UI.Widget { |
| 8 constructor() { | 8 constructor() { |
| 9 super(); | 9 super(); |
| 10 this._addCompletionsFromHistory = true; | 10 this._addCompletionsFromHistory = true; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 */ | 23 */ |
| 24 function gotFactory(factory) { | 24 function gotFactory(factory) { |
| 25 this._editor = | 25 this._editor = |
| 26 factory.createEditor({lineNumbers: false, lineWrapping: true, mimeType
: 'javascript', autoHeight: true}); | 26 factory.createEditor({lineNumbers: false, lineWrapping: true, mimeType
: 'javascript', autoHeight: true}); |
| 27 | 27 |
| 28 this._editor.configureAutocomplete({ | 28 this._editor.configureAutocomplete({ |
| 29 substituteRangeCallback: this._substituteRange.bind(this), | 29 substituteRangeCallback: this._substituteRange.bind(this), |
| 30 suggestionsCallback: this._wordsWithQuery.bind(this), | 30 suggestionsCallback: this._wordsWithQuery.bind(this), |
| 31 captureEnter: true | 31 captureEnter: true |
| 32 }); | 32 }); |
| 33 this._editor.widget().element.addEventListener('keydown', this._editorKeyD
own.bind(this), true); | 33 this._editor.element.addEventListener('keydown', this._editorKeyDown.bind(
this), true); |
| 34 this._editor.widget().show(this.element); | 34 this._editor.show(this.element); |
| 35 | 35 |
| 36 this.setText(this._initialText); | 36 this.setText(this._initialText); |
| 37 delete this._initialText; | 37 delete this._initialText; |
| 38 if (this.hasFocus()) | 38 if (this.hasFocus()) |
| 39 this.focus(); | 39 this.focus(); |
| 40 this.element.tabIndex = -1; | 40 this.element.tabIndex = -1; |
| 41 | 41 |
| 42 this._editorSetForTest(); | 42 this._editorSetForTest(); |
| 43 } | 43 } |
| 44 } | 44 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 if (newText === undefined) | 131 if (newText === undefined) |
| 132 return; | 132 return; |
| 133 keyboardEvent.consume(true); | 133 keyboardEvent.consume(true); |
| 134 this.setText(newText); | 134 this.setText(newText); |
| 135 | 135 |
| 136 if (isPrevious) | 136 if (isPrevious) |
| 137 this._editor.setSelection(Common.TextRange.createFromLocation(0, Infinity)
); | 137 this._editor.setSelection(Common.TextRange.createFromLocation(0, Infinity)
); |
| 138 else | 138 else |
| 139 this.moveCaretToEndOfPrompt(); | 139 this.moveCaretToEndOfPrompt(); |
| 140 this.setMinimumSize(0, this._editor.widget().element.offsetHeight); | 140 this.setMinimumSize(0, this._editor.element.offsetHeight); |
| 141 } | 141 } |
| 142 | 142 |
| 143 /** | 143 /** |
| 144 * @param {!KeyboardEvent} event | 144 * @param {!KeyboardEvent} event |
| 145 */ | 145 */ |
| 146 _enterKeyPressed(event) { | 146 _enterKeyPressed(event) { |
| 147 if (event.altKey || event.ctrlKey || event.shiftKey) | 147 if (event.altKey || event.ctrlKey || event.shiftKey) |
| 148 return; | 148 return; |
| 149 | 149 |
| 150 event.consume(true); | 150 event.consume(true); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 {text: item.substring(text.length - prefix.length), iconType: 'smallic
on-text-prompt', isSecondary: true}); | 223 {text: item.substring(text.length - prefix.length), iconType: 'smallic
on-text-prompt', isSecondary: true}); |
| 224 } | 224 } |
| 225 return result; | 225 return result; |
| 226 } | 226 } |
| 227 | 227 |
| 228 /** | 228 /** |
| 229 * @override | 229 * @override |
| 230 */ | 230 */ |
| 231 focus() { | 231 focus() { |
| 232 if (this._editor) | 232 if (this._editor) |
| 233 this._editor.widget().focus(); | 233 this._editor.focus(); |
| 234 else | 234 else |
| 235 this.element.focus(); | 235 this.element.focus(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 /** | 238 /** |
| 239 * @param {number} lineNumber | 239 * @param {number} lineNumber |
| 240 * @param {number} columnNumber | 240 * @param {number} columnNumber |
| 241 * @return {?Common.TextRange} | 241 * @return {?Common.TextRange} |
| 242 */ | 242 */ |
| 243 _substituteRange(lineNumber, columnNumber) { | 243 _substituteRange(lineNumber, columnNumber) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 return this._currentHistoryItem(); | 361 return this._currentHistoryItem(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 /** | 364 /** |
| 365 * @return {string|undefined} | 365 * @return {string|undefined} |
| 366 */ | 366 */ |
| 367 _currentHistoryItem() { | 367 _currentHistoryItem() { |
| 368 return this._data[this._data.length - this._historyOffset]; | 368 return this._data[this._data.length - this._historyOffset]; |
| 369 } | 369 } |
| 370 }; | 370 }; |
| OLD | NEW |