| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor { | 7 SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor { |
| 8 /** | 8 /** |
| 9 * @param {!SourceFrame.SourcesTextEditorDelegate} delegate | 9 * @param {!SourceFrame.SourcesTextEditorDelegate} delegate |
| 10 */ | 10 */ |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 * @param {number} lineNumber | 208 * @param {number} lineNumber |
| 209 * @param {number} columnNumber | 209 * @param {number} columnNumber |
| 210 */ | 210 */ |
| 211 setExecutionLocation(lineNumber, columnNumber) { | 211 setExecutionLocation(lineNumber, columnNumber) { |
| 212 this.clearPositionHighlight(); | 212 this.clearPositionHighlight(); |
| 213 | 213 |
| 214 this._executionLine = this.codeMirror().getLineHandle(lineNumber); | 214 this._executionLine = this.codeMirror().getLineHandle(lineNumber); |
| 215 if (!this._executionLine) | 215 if (!this._executionLine) |
| 216 return; | 216 return; |
| 217 | 217 |
| 218 this.codeMirror().addLineClass(this._executionLine, 'wrap', 'cm-execution-li
ne'); | 218 this.showExecutionLineBackground(); |
| 219 this.codeMirror().addLineClass(this._executionLine, 'wrap', 'cm-execution-li
ne-outline'); |
| 220 var token = this.tokenAtTextPosition(lineNumber, columnNumber); |
| 221 var endColumn; |
| 222 if (token && token.type) |
| 223 endColumn = token.endColumn; |
| 224 else |
| 225 endColumn = this.codeMirror().getLine(lineNumber).length; |
| 226 |
| 227 |
| 219 this._executionLineTailMarker = this.codeMirror().markText( | 228 this._executionLineTailMarker = this.codeMirror().markText( |
| 220 {line: lineNumber, ch: columnNumber}, {line: lineNumber, ch: this.codeMi
rror().getLine(lineNumber).length}, | 229 {line: lineNumber, ch: columnNumber}, {line: lineNumber, ch: endColumn},
{className: 'cm-execution-line-tail'}); |
| 221 {className: 'cm-execution-line-tail'}); | 230 } |
| 231 |
| 232 showExecutionLineBackground() { |
| 233 if (this._executionLine) |
| 234 this.codeMirror().addLineClass(this._executionLine, 'wrap', 'cm-execution-
line'); |
| 235 } |
| 236 |
| 237 hideExecutionLineBackground() { |
| 238 if (this._executionLine) |
| 239 this.codeMirror().removeLineClass(this._executionLine, 'wrap', 'cm-executi
on-line'); |
| 222 } | 240 } |
| 223 | 241 |
| 224 clearExecutionLine() { | 242 clearExecutionLine() { |
| 225 this.clearPositionHighlight(); | 243 this.clearPositionHighlight(); |
| 226 | 244 |
| 227 if (this._executionLine) | 245 if (this._executionLine) { |
| 228 this.codeMirror().removeLineClass(this._executionLine, 'wrap', 'cm-executi
on-line'); | 246 this.hideExecutionLineBackground(); |
| 247 this.codeMirror().removeLineClass(this._executionLine, 'wrap', 'cm-executi
on-line-outline'); |
| 248 } |
| 229 delete this._executionLine; | 249 delete this._executionLine; |
| 230 | 250 |
| 231 if (this._executionLineTailMarker) | 251 if (this._executionLineTailMarker) |
| 232 this._executionLineTailMarker.clear(); | 252 this._executionLineTailMarker.clear(); |
| 233 delete this._executionLineTailMarker; | 253 delete this._executionLineTailMarker; |
| 234 } | 254 } |
| 235 | 255 |
| 236 /** | 256 /** |
| 237 * @param {number} lineNumber | 257 * @param {number} lineNumber |
| 238 * @param {string} className | 258 * @param {string} className |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 */ | 859 */ |
| 840 _setHighlighter(highlighter, selectionStart) { | 860 _setHighlighter(highlighter, selectionStart) { |
| 841 var overlayMode = {token: highlighter}; | 861 var overlayMode = {token: highlighter}; |
| 842 this._codeMirror.addOverlay(overlayMode); | 862 this._codeMirror.addOverlay(overlayMode); |
| 843 this._highlightDescriptor = {overlay: overlayMode, selectionStart: selection
Start}; | 863 this._highlightDescriptor = {overlay: overlayMode, selectionStart: selection
Start}; |
| 844 } | 864 } |
| 845 }; | 865 }; |
| 846 | 866 |
| 847 SourceFrame.SourcesTextEditor.LinesToScanForIndentationGuessing = 1000; | 867 SourceFrame.SourcesTextEditor.LinesToScanForIndentationGuessing = 1000; |
| 848 SourceFrame.SourcesTextEditor.MaximumNumberOfWhitespacesPerSingleSpan = 16; | 868 SourceFrame.SourcesTextEditor.MaximumNumberOfWhitespacesPerSingleSpan = 16; |
| OLD | NEW |