| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @implements {WebInspector.Searchable} | 31 * @implements {UI.Searchable} |
| 32 * @implements {WebInspector.Replaceable} | 32 * @implements {UI.Replaceable} |
| 33 * @implements {WebInspector.SourcesTextEditorDelegate} | 33 * @implements {SourceFrame.SourcesTextEditorDelegate} |
| 34 * @unrestricted | 34 * @unrestricted |
| 35 */ | 35 */ |
| 36 WebInspector.SourceFrame = class extends WebInspector.SimpleView { | 36 SourceFrame.SourceFrame = class extends UI.SimpleView { |
| 37 /** | 37 /** |
| 38 * @param {string} url | 38 * @param {string} url |
| 39 * @param {function(): !Promise<?string>} lazyContent | 39 * @param {function(): !Promise<?string>} lazyContent |
| 40 */ | 40 */ |
| 41 constructor(url, lazyContent) { | 41 constructor(url, lazyContent) { |
| 42 super(WebInspector.UIString('Source')); | 42 super(Common.UIString('Source')); |
| 43 | 43 |
| 44 this._url = url; | 44 this._url = url; |
| 45 this._lazyContent = lazyContent; | 45 this._lazyContent = lazyContent; |
| 46 | 46 |
| 47 this._textEditor = new WebInspector.SourcesTextEditor(this); | 47 this._textEditor = new SourceFrame.SourcesTextEditor(this); |
| 48 | 48 |
| 49 this._currentSearchResultIndex = -1; | 49 this._currentSearchResultIndex = -1; |
| 50 this._searchResults = []; | 50 this._searchResults = []; |
| 51 | 51 |
| 52 this._textEditor.addEventListener( | 52 this._textEditor.addEventListener( |
| 53 WebInspector.SourcesTextEditor.Events.EditorFocused, this._resetCurrentS
earchResultIndex, this); | 53 SourceFrame.SourcesTextEditor.Events.EditorFocused, this._resetCurrentSe
archResultIndex, this); |
| 54 this._textEditor.addEventListener( | 54 this._textEditor.addEventListener( |
| 55 WebInspector.SourcesTextEditor.Events.SelectionChanged, this._updateSour
cePosition, this); | 55 SourceFrame.SourcesTextEditor.Events.SelectionChanged, this._updateSourc
ePosition, this); |
| 56 this._textEditor.addEventListener( | 56 this._textEditor.addEventListener( |
| 57 WebInspector.SourcesTextEditor.Events.TextChanged, | 57 SourceFrame.SourcesTextEditor.Events.TextChanged, |
| 58 event => this.onTextChanged(event.data.oldRange, event.data.newRange)); | 58 event => this.onTextChanged(event.data.oldRange, event.data.newRange)); |
| 59 | 59 |
| 60 this._shortcuts = {}; | 60 this._shortcuts = {}; |
| 61 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal
se); | 61 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal
se); |
| 62 | 62 |
| 63 this._sourcePosition = new WebInspector.ToolbarText(); | 63 this._sourcePosition = new UI.ToolbarText(); |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * @type {?WebInspector.SearchableView} | 66 * @type {?UI.SearchableView} |
| 67 */ | 67 */ |
| 68 this._searchableView = null; | 68 this._searchableView = null; |
| 69 this._editable = false; | 69 this._editable = false; |
| 70 } | 70 } |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * @param {boolean} editable | 73 * @param {boolean} editable |
| 74 */ | 74 */ |
| 75 setEditable(editable) { | 75 setEditable(editable) { |
| 76 this._editable = editable; | 76 this._editable = editable; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 106 * @override | 106 * @override |
| 107 */ | 107 */ |
| 108 willHide() { | 108 willHide() { |
| 109 super.willHide(); | 109 super.willHide(); |
| 110 | 110 |
| 111 this._clearPositionToReveal(); | 111 this._clearPositionToReveal(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 /** | 114 /** |
| 115 * @override | 115 * @override |
| 116 * @return {!Array<!WebInspector.ToolbarItem>} | 116 * @return {!Array<!UI.ToolbarItem>} |
| 117 */ | 117 */ |
| 118 syncToolbarItems() { | 118 syncToolbarItems() { |
| 119 return [this._sourcePosition]; | 119 return [this._sourcePosition]; |
| 120 } | 120 } |
| 121 | 121 |
| 122 get loaded() { | 122 get loaded() { |
| 123 return this._loaded; | 123 return this._loaded; |
| 124 } | 124 } |
| 125 | 125 |
| 126 get textEditor() { | 126 get textEditor() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 delete this._lineToScrollTo; | 179 delete this._lineToScrollTo; |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 _clearLineToScrollTo() { | 184 _clearLineToScrollTo() { |
| 185 delete this._lineToScrollTo; | 185 delete this._lineToScrollTo; |
| 186 } | 186 } |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * @return {!WebInspector.TextRange} | 189 * @return {!Common.TextRange} |
| 190 */ | 190 */ |
| 191 selection() { | 191 selection() { |
| 192 return this.textEditor.selection(); | 192 return this.textEditor.selection(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 /** | 195 /** |
| 196 * @param {!WebInspector.TextRange} textRange | 196 * @param {!Common.TextRange} textRange |
| 197 */ | 197 */ |
| 198 setSelection(textRange) { | 198 setSelection(textRange) { |
| 199 this._selectionToSet = textRange; | 199 this._selectionToSet = textRange; |
| 200 this._innerSetSelectionIfNeeded(); | 200 this._innerSetSelectionIfNeeded(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 _innerSetSelectionIfNeeded() { | 203 _innerSetSelectionIfNeeded() { |
| 204 if (this._selectionToSet && this.loaded && this.isEditorShowing()) { | 204 if (this._selectionToSet && this.loaded && this.isEditorShowing()) { |
| 205 this._textEditor.setSelection(this._selectionToSet); | 205 this._textEditor.setSelection(this._selectionToSet); |
| 206 delete this._selectionToSet; | 206 delete this._selectionToSet; |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 _clearSelectionToSet() { | 210 _clearSelectionToSet() { |
| 211 delete this._selectionToSet; | 211 delete this._selectionToSet; |
| 212 } | 212 } |
| 213 | 213 |
| 214 _wasShownOrLoaded() { | 214 _wasShownOrLoaded() { |
| 215 this._innerRevealPositionIfNeeded(); | 215 this._innerRevealPositionIfNeeded(); |
| 216 this._innerSetSelectionIfNeeded(); | 216 this._innerSetSelectionIfNeeded(); |
| 217 this._innerScrollToLineIfNeeded(); | 217 this._innerScrollToLineIfNeeded(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 /** | 220 /** |
| 221 * @param {!WebInspector.TextRange} oldRange | 221 * @param {!Common.TextRange} oldRange |
| 222 * @param {!WebInspector.TextRange} newRange | 222 * @param {!Common.TextRange} newRange |
| 223 */ | 223 */ |
| 224 onTextChanged(oldRange, newRange) { | 224 onTextChanged(oldRange, newRange) { |
| 225 if (this._searchConfig && this._searchableView) | 225 if (this._searchConfig && this._searchableView) |
| 226 this.performSearch(this._searchConfig, false, false); | 226 this.performSearch(this._searchConfig, false, false); |
| 227 } | 227 } |
| 228 | 228 |
| 229 /** | 229 /** |
| 230 * @param {string} content | 230 * @param {string} content |
| 231 * @param {string} mimeType | 231 * @param {string} mimeType |
| 232 * @return {string} | 232 * @return {string} |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 this._delayedFindSearchMatches(); | 280 this._delayedFindSearchMatches(); |
| 281 delete this._delayedFindSearchMatches; | 281 delete this._delayedFindSearchMatches; |
| 282 } | 282 } |
| 283 this.onTextEditorContentSet(); | 283 this.onTextEditorContentSet(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 onTextEditorContentSet() { | 286 onTextEditorContentSet() { |
| 287 } | 287 } |
| 288 | 288 |
| 289 /** | 289 /** |
| 290 * @param {?WebInspector.SearchableView} view | 290 * @param {?UI.SearchableView} view |
| 291 */ | 291 */ |
| 292 setSearchableView(view) { | 292 setSearchableView(view) { |
| 293 this._searchableView = view; | 293 this._searchableView = view; |
| 294 } | 294 } |
| 295 | 295 |
| 296 /** | 296 /** |
| 297 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig | 297 * @param {!UI.SearchableView.SearchConfig} searchConfig |
| 298 * @param {boolean} shouldJump | 298 * @param {boolean} shouldJump |
| 299 * @param {boolean} jumpBackwards | 299 * @param {boolean} jumpBackwards |
| 300 */ | 300 */ |
| 301 _doFindSearchMatches(searchConfig, shouldJump, jumpBackwards) { | 301 _doFindSearchMatches(searchConfig, shouldJump, jumpBackwards) { |
| 302 this._currentSearchResultIndex = -1; | 302 this._currentSearchResultIndex = -1; |
| 303 this._searchResults = []; | 303 this._searchResults = []; |
| 304 | 304 |
| 305 var regex = searchConfig.toSearchRegex(); | 305 var regex = searchConfig.toSearchRegex(); |
| 306 this._searchRegex = regex; | 306 this._searchRegex = regex; |
| 307 this._searchResults = this._collectRegexMatches(regex); | 307 this._searchResults = this._collectRegexMatches(regex); |
| 308 | 308 |
| 309 if (this._searchableView) | 309 if (this._searchableView) |
| 310 this._searchableView.updateSearchMatchesCount(this._searchResults.length); | 310 this._searchableView.updateSearchMatchesCount(this._searchResults.length); |
| 311 | 311 |
| 312 if (!this._searchResults.length) | 312 if (!this._searchResults.length) |
| 313 this._textEditor.cancelSearchResultsHighlight(); | 313 this._textEditor.cancelSearchResultsHighlight(); |
| 314 else if (shouldJump && jumpBackwards) | 314 else if (shouldJump && jumpBackwards) |
| 315 this.jumpToPreviousSearchResult(); | 315 this.jumpToPreviousSearchResult(); |
| 316 else if (shouldJump) | 316 else if (shouldJump) |
| 317 this.jumpToNextSearchResult(); | 317 this.jumpToNextSearchResult(); |
| 318 else | 318 else |
| 319 this._textEditor.highlightSearchResults(regex, null); | 319 this._textEditor.highlightSearchResults(regex, null); |
| 320 } | 320 } |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * @override | 323 * @override |
| 324 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig | 324 * @param {!UI.SearchableView.SearchConfig} searchConfig |
| 325 * @param {boolean} shouldJump | 325 * @param {boolean} shouldJump |
| 326 * @param {boolean=} jumpBackwards | 326 * @param {boolean=} jumpBackwards |
| 327 */ | 327 */ |
| 328 performSearch(searchConfig, shouldJump, jumpBackwards) { | 328 performSearch(searchConfig, shouldJump, jumpBackwards) { |
| 329 if (this._searchableView) | 329 if (this._searchableView) |
| 330 this._searchableView.updateSearchMatchesCount(0); | 330 this._searchableView.updateSearchMatchesCount(0); |
| 331 | 331 |
| 332 this._resetSearch(); | 332 this._resetSearch(); |
| 333 this._searchConfig = searchConfig; | 333 this._searchConfig = searchConfig; |
| 334 if (this.loaded) | 334 if (this.loaded) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 382 |
| 383 jumpToLastSearchResult() { | 383 jumpToLastSearchResult() { |
| 384 this.jumpToSearchResult(this._searchResults.length - 1); | 384 this.jumpToSearchResult(this._searchResults.length - 1); |
| 385 } | 385 } |
| 386 | 386 |
| 387 /** | 387 /** |
| 388 * @return {number} | 388 * @return {number} |
| 389 */ | 389 */ |
| 390 _searchResultIndexForCurrentSelection() { | 390 _searchResultIndexForCurrentSelection() { |
| 391 return this._searchResults.lowerBound( | 391 return this._searchResults.lowerBound( |
| 392 this._textEditor.selection().collapseToEnd(), WebInspector.TextRange.com
parator); | 392 this._textEditor.selection().collapseToEnd(), Common.TextRange.comparato
r); |
| 393 } | 393 } |
| 394 | 394 |
| 395 /** | 395 /** |
| 396 * @override | 396 * @override |
| 397 */ | 397 */ |
| 398 jumpToNextSearchResult() { | 398 jumpToNextSearchResult() { |
| 399 var currentIndex = this._searchResultIndexForCurrentSelection(); | 399 var currentIndex = this._searchResultIndexForCurrentSelection(); |
| 400 var nextIndex = this._currentSearchResultIndex === -1 ? currentIndex : curre
ntIndex + 1; | 400 var nextIndex = this._currentSearchResultIndex === -1 ? currentIndex : curre
ntIndex + 1; |
| 401 this.jumpToSearchResult(nextIndex); | 401 this.jumpToSearchResult(nextIndex); |
| 402 } | 402 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 433 if (!this.loaded || !this._searchResults.length) | 433 if (!this.loaded || !this._searchResults.length) |
| 434 return; | 434 return; |
| 435 this._currentSearchResultIndex = (index + this._searchResults.length) % this
._searchResults.length; | 435 this._currentSearchResultIndex = (index + this._searchResults.length) % this
._searchResults.length; |
| 436 if (this._searchableView) | 436 if (this._searchableView) |
| 437 this._searchableView.updateCurrentMatchIndex(this._currentSearchResultInde
x); | 437 this._searchableView.updateCurrentMatchIndex(this._currentSearchResultInde
x); |
| 438 this._textEditor.highlightSearchResults(this._searchRegex, this._searchResul
ts[this._currentSearchResultIndex]); | 438 this._textEditor.highlightSearchResults(this._searchRegex, this._searchResul
ts[this._currentSearchResultIndex]); |
| 439 } | 439 } |
| 440 | 440 |
| 441 /** | 441 /** |
| 442 * @override | 442 * @override |
| 443 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig | 443 * @param {!UI.SearchableView.SearchConfig} searchConfig |
| 444 * @param {string} replacement | 444 * @param {string} replacement |
| 445 */ | 445 */ |
| 446 replaceSelectionWith(searchConfig, replacement) { | 446 replaceSelectionWith(searchConfig, replacement) { |
| 447 var range = this._searchResults[this._currentSearchResultIndex]; | 447 var range = this._searchResults[this._currentSearchResultIndex]; |
| 448 if (!range) | 448 if (!range) |
| 449 return; | 449 return; |
| 450 this._textEditor.highlightSearchResults(this._searchRegex, null); | 450 this._textEditor.highlightSearchResults(this._searchRegex, null); |
| 451 | 451 |
| 452 var oldText = this._textEditor.text(range); | 452 var oldText = this._textEditor.text(range); |
| 453 var regex = searchConfig.toSearchRegex(); | 453 var regex = searchConfig.toSearchRegex(); |
| 454 var text; | 454 var text; |
| 455 if (regex.__fromRegExpQuery) | 455 if (regex.__fromRegExpQuery) |
| 456 text = oldText.replace(regex, replacement); | 456 text = oldText.replace(regex, replacement); |
| 457 else | 457 else |
| 458 text = oldText.replace(regex, function() { | 458 text = oldText.replace(regex, function() { |
| 459 return replacement; | 459 return replacement; |
| 460 }); | 460 }); |
| 461 | 461 |
| 462 var newRange = this._textEditor.editRange(range, text); | 462 var newRange = this._textEditor.editRange(range, text); |
| 463 this._textEditor.setSelection(newRange.collapseToEnd()); | 463 this._textEditor.setSelection(newRange.collapseToEnd()); |
| 464 } | 464 } |
| 465 | 465 |
| 466 /** | 466 /** |
| 467 * @override | 467 * @override |
| 468 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig | 468 * @param {!UI.SearchableView.SearchConfig} searchConfig |
| 469 * @param {string} replacement | 469 * @param {string} replacement |
| 470 */ | 470 */ |
| 471 replaceAllWith(searchConfig, replacement) { | 471 replaceAllWith(searchConfig, replacement) { |
| 472 this._resetCurrentSearchResultIndex(); | 472 this._resetCurrentSearchResultIndex(); |
| 473 | 473 |
| 474 var text = this._textEditor.text(); | 474 var text = this._textEditor.text(); |
| 475 var range = this._textEditor.fullRange(); | 475 var range = this._textEditor.fullRange(); |
| 476 | 476 |
| 477 var regex = searchConfig.toSearchRegex(true); | 477 var regex = searchConfig.toSearchRegex(true); |
| 478 if (regex.__fromRegExpQuery) | 478 if (regex.__fromRegExpQuery) |
| 479 text = text.replace(regex, replacement); | 479 text = text.replace(regex, replacement); |
| 480 else | 480 else |
| 481 text = text.replace(regex, function() { | 481 text = text.replace(regex, function() { |
| 482 return replacement; | 482 return replacement; |
| 483 }); | 483 }); |
| 484 | 484 |
| 485 var ranges = this._collectRegexMatches(regex); | 485 var ranges = this._collectRegexMatches(regex); |
| 486 if (!ranges.length) | 486 if (!ranges.length) |
| 487 return; | 487 return; |
| 488 | 488 |
| 489 // Calculate the position of the end of the last range to be edited. | 489 // Calculate the position of the end of the last range to be edited. |
| 490 var currentRangeIndex = ranges.lowerBound(this._textEditor.selection(), WebI
nspector.TextRange.comparator); | 490 var currentRangeIndex = ranges.lowerBound(this._textEditor.selection(), Comm
on.TextRange.comparator); |
| 491 var lastRangeIndex = mod(currentRangeIndex - 1, ranges.length); | 491 var lastRangeIndex = mod(currentRangeIndex - 1, ranges.length); |
| 492 var lastRange = ranges[lastRangeIndex]; | 492 var lastRange = ranges[lastRangeIndex]; |
| 493 var replacementLineEndings = replacement.computeLineEndings(); | 493 var replacementLineEndings = replacement.computeLineEndings(); |
| 494 var replacementLineCount = replacementLineEndings.length; | 494 var replacementLineCount = replacementLineEndings.length; |
| 495 var lastLineNumber = lastRange.startLine + replacementLineEndings.length - 1
; | 495 var lastLineNumber = lastRange.startLine + replacementLineEndings.length - 1
; |
| 496 var lastColumnNumber = lastRange.startColumn; | 496 var lastColumnNumber = lastRange.startColumn; |
| 497 if (replacementLineEndings.length > 1) | 497 if (replacementLineEndings.length > 1) |
| 498 lastColumnNumber = | 498 lastColumnNumber = |
| 499 replacementLineEndings[replacementLineCount - 1] - replacementLineEndi
ngs[replacementLineCount - 2] - 1; | 499 replacementLineEndings[replacementLineCount - 1] - replacementLineEndi
ngs[replacementLineCount - 2] - 1; |
| 500 | 500 |
| 501 this._textEditor.editRange(range, text); | 501 this._textEditor.editRange(range, text); |
| 502 this._textEditor.revealPosition(lastLineNumber, lastColumnNumber); | 502 this._textEditor.revealPosition(lastLineNumber, lastColumnNumber); |
| 503 this._textEditor.setSelection(WebInspector.TextRange.createFromLocation(last
LineNumber, lastColumnNumber)); | 503 this._textEditor.setSelection(Common.TextRange.createFromLocation(lastLineNu
mber, lastColumnNumber)); |
| 504 } | 504 } |
| 505 | 505 |
| 506 _collectRegexMatches(regexObject) { | 506 _collectRegexMatches(regexObject) { |
| 507 var ranges = []; | 507 var ranges = []; |
| 508 for (var i = 0; i < this._textEditor.linesCount; ++i) { | 508 for (var i = 0; i < this._textEditor.linesCount; ++i) { |
| 509 var line = this._textEditor.line(i); | 509 var line = this._textEditor.line(i); |
| 510 var offset = 0; | 510 var offset = 0; |
| 511 do { | 511 do { |
| 512 var match = regexObject.exec(line); | 512 var match = regexObject.exec(line); |
| 513 if (match) { | 513 if (match) { |
| 514 var matchEndIndex = match.index + Math.max(match[0].length, 1); | 514 var matchEndIndex = match.index + Math.max(match[0].length, 1); |
| 515 if (match[0].length) | 515 if (match[0].length) |
| 516 ranges.push(new WebInspector.TextRange(i, offset + match.index, i, o
ffset + matchEndIndex)); | 516 ranges.push(new Common.TextRange(i, offset + match.index, i, offset
+ matchEndIndex)); |
| 517 offset += matchEndIndex; | 517 offset += matchEndIndex; |
| 518 line = line.substring(matchEndIndex); | 518 line = line.substring(matchEndIndex); |
| 519 } | 519 } |
| 520 } while (match && line); | 520 } while (match && line); |
| 521 } | 521 } |
| 522 return ranges; | 522 return ranges; |
| 523 } | 523 } |
| 524 | 524 |
| 525 /** | 525 /** |
| 526 * @override | 526 * @override |
| (...skipping 16 matching lines...) Expand all Loading... |
| 543 */ | 543 */ |
| 544 canEditSource() { | 544 canEditSource() { |
| 545 return this._editable; | 545 return this._editable; |
| 546 } | 546 } |
| 547 | 547 |
| 548 _updateSourcePosition() { | 548 _updateSourcePosition() { |
| 549 var selections = this._textEditor.selections(); | 549 var selections = this._textEditor.selections(); |
| 550 if (!selections.length) | 550 if (!selections.length) |
| 551 return; | 551 return; |
| 552 if (selections.length > 1) { | 552 if (selections.length > 1) { |
| 553 this._sourcePosition.setText(WebInspector.UIString('%d selection regions',
selections.length)); | 553 this._sourcePosition.setText(Common.UIString('%d selection regions', selec
tions.length)); |
| 554 return; | 554 return; |
| 555 } | 555 } |
| 556 var textRange = selections[0]; | 556 var textRange = selections[0]; |
| 557 if (textRange.isEmpty()) { | 557 if (textRange.isEmpty()) { |
| 558 this._sourcePosition.setText( | 558 this._sourcePosition.setText( |
| 559 WebInspector.UIString('Line %d, Column %d', textRange.endLine + 1, tex
tRange.endColumn + 1)); | 559 Common.UIString('Line %d, Column %d', textRange.endLine + 1, textRange
.endColumn + 1)); |
| 560 return; | 560 return; |
| 561 } | 561 } |
| 562 textRange = textRange.normalize(); | 562 textRange = textRange.normalize(); |
| 563 | 563 |
| 564 var selectedText = this._textEditor.text(textRange); | 564 var selectedText = this._textEditor.text(textRange); |
| 565 if (textRange.startLine === textRange.endLine) | 565 if (textRange.startLine === textRange.endLine) |
| 566 this._sourcePosition.setText(WebInspector.UIString('%d characters selected
', selectedText.length)); | 566 this._sourcePosition.setText(Common.UIString('%d characters selected', sel
ectedText.length)); |
| 567 else | 567 else |
| 568 this._sourcePosition.setText(WebInspector.UIString( | 568 this._sourcePosition.setText(Common.UIString( |
| 569 '%d lines, %d characters selected', textRange.endLine - textRange.star
tLine + 1, selectedText.length)); | 569 '%d lines, %d characters selected', textRange.endLine - textRange.star
tLine + 1, selectedText.length)); |
| 570 } | 570 } |
| 571 | 571 |
| 572 _handleKeyDown(e) { | 572 _handleKeyDown(e) { |
| 573 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(e); | 573 var shortcutKey = UI.KeyboardShortcut.makeKeyFromEvent(e); |
| 574 var handler = this._shortcuts[shortcutKey]; | 574 var handler = this._shortcuts[shortcutKey]; |
| 575 if (handler && handler()) | 575 if (handler && handler()) |
| 576 e.consume(true); | 576 e.consume(true); |
| 577 } | 577 } |
| 578 }; | 578 }; |
| OLD | NEW |