| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 770 |
| 771 /** | 771 /** |
| 772 * @param {!Event} event | 772 * @param {!Event} event |
| 773 */ | 773 */ |
| 774 _promptKeyDown: function(event) | 774 _promptKeyDown: function(event) |
| 775 { | 775 { |
| 776 var keyboardEvent = /** @type {!KeyboardEvent} */ (event); | 776 var keyboardEvent = /** @type {!KeyboardEvent} */ (event); |
| 777 if (keyboardEvent.key === "PageUp") { | 777 if (keyboardEvent.key === "PageUp") { |
| 778 this._updateStickToBottomOnWheel(); | 778 this._updateStickToBottomOnWheel(); |
| 779 return; | 779 return; |
| 780 } else if (isEnterKey(keyboardEvent)) { | |
| 781 this._enterKeyPressed(keyboardEvent); | |
| 782 return; | |
| 783 } | 780 } |
| 784 | 781 |
| 785 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(keyboardEv
ent); | 782 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(keyboardEv
ent); |
| 786 var handler = this._shortcuts[shortcut]; | 783 var handler = this._shortcuts[shortcut]; |
| 787 if (handler) { | 784 if (handler) { |
| 788 handler(); | 785 handler(); |
| 789 keyboardEvent.preventDefault(); | 786 keyboardEvent.preventDefault(); |
| 790 } | 787 } |
| 791 }, | 788 }, |
| 792 | 789 |
| 793 _enterKeyPressed: function(event) | |
| 794 { | |
| 795 if (event.altKey || event.ctrlKey || event.shiftKey) | |
| 796 return; | |
| 797 | |
| 798 event.consume(true); | |
| 799 | |
| 800 this._prompt.clearAutocomplete(); | |
| 801 | |
| 802 var str = this._prompt.text(); | |
| 803 if (!str.length) | |
| 804 return; | |
| 805 | |
| 806 var currentExecutionContext = WebInspector.context.flavor(WebInspector.E
xecutionContext); | |
| 807 if (!this._prompt.isCaretAtEndOfPrompt() || !currentExecutionContext) { | |
| 808 this._appendCommand(str, true); | |
| 809 return; | |
| 810 } | |
| 811 currentExecutionContext.target().runtimeModel.compileScript(str, "", fal
se, currentExecutionContext.id, compileCallback.bind(this)); | |
| 812 | |
| 813 /** | |
| 814 * @param {!RuntimeAgent.ScriptId=} scriptId | |
| 815 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails | |
| 816 * @this {WebInspector.ConsoleView} | |
| 817 */ | |
| 818 function compileCallback(scriptId, exceptionDetails) | |
| 819 { | |
| 820 if (str !== this._prompt.text()) | |
| 821 return; | |
| 822 if (exceptionDetails && (exceptionDetails.exception.description ===
"SyntaxError: Unexpected end of input" | |
| 823 || exceptionDetails.exception.description === "SyntaxError: Unte
rminated template literal")) { | |
| 824 this._prompt.newlineAndIndent(); | |
| 825 return; | |
| 826 } | |
| 827 this._appendCommand(str, true); | |
| 828 } | |
| 829 }, | |
| 830 | |
| 831 /** | 790 /** |
| 832 * @param {?WebInspector.RemoteObject} result | 791 * @param {?WebInspector.RemoteObject} result |
| 833 * @param {!WebInspector.ConsoleMessage} originatingConsoleMessage | 792 * @param {!WebInspector.ConsoleMessage} originatingConsoleMessage |
| 834 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails | 793 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails |
| 835 */ | 794 */ |
| 836 _printResult: function(result, originatingConsoleMessage, exceptionDetails) | 795 _printResult: function(result, originatingConsoleMessage, exceptionDetails) |
| 837 { | 796 { |
| 838 if (!result) | 797 if (!result) |
| 839 return; | 798 return; |
| 840 | 799 |
| 841 var level = !!exceptionDetails ? WebInspector.ConsoleMessage.MessageLeve
l.Error : WebInspector.ConsoleMessage.MessageLevel.Log; | 800 var level = !!exceptionDetails ? WebInspector.ConsoleMessage.MessageLeve
l.Error : WebInspector.ConsoleMessage.MessageLevel.Log; |
| 842 var message; | 801 var message; |
| 843 if (!exceptionDetails) | 802 if (!exceptionDetails) |
| 844 message = new WebInspector.ConsoleMessage(result.target(), WebInspec
tor.ConsoleMessage.MessageSource.JS, level, "", WebInspector.ConsoleMessage.Mess
ageType.Result, undefined, undefined, undefined, undefined, [result]); | 803 message = new WebInspector.ConsoleMessage(result.target(), WebInspec
tor.ConsoleMessage.MessageSource.JS, level, "", WebInspector.ConsoleMessage.Mess
ageType.Result, undefined, undefined, undefined, undefined, [result]); |
| 845 else | 804 else |
| 846 message = WebInspector.ConsoleMessage.fromException(result.target(),
exceptionDetails, WebInspector.ConsoleMessage.MessageType.Result, undefined, un
defined); | 805 message = WebInspector.ConsoleMessage.fromException(result.target(),
exceptionDetails, WebInspector.ConsoleMessage.MessageType.Result, undefined, un
defined); |
| 847 message.setOriginatingMessage(originatingConsoleMessage); | 806 message.setOriginatingMessage(originatingConsoleMessage); |
| 848 result.target().consoleModel.addMessage(message); | 807 result.target().consoleModel.addMessage(message); |
| 849 }, | 808 }, |
| 850 | 809 |
| 851 /** | 810 /** |
| 852 * @param {string} text | |
| 853 * @param {boolean} useCommandLineAPI | |
| 854 */ | |
| 855 _appendCommand: function(text, useCommandLineAPI) | |
| 856 { | |
| 857 this._prompt.setText(""); | |
| 858 var currentExecutionContext = WebInspector.context.flavor(WebInspector.E
xecutionContext); | |
| 859 if (currentExecutionContext) { | |
| 860 WebInspector.ConsoleModel.evaluateCommandInConsole(currentExecutionC
ontext, text, useCommandLineAPI); | |
| 861 if (WebInspector.inspectorView.currentPanel() && WebInspector.inspec
torView.currentPanel().name === "console") | |
| 862 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Ac
tion.CommandEvaluatedInConsolePanel); | |
| 863 } | |
| 864 }, | |
| 865 | |
| 866 /** | |
| 867 * @param {!WebInspector.Event} event | 811 * @param {!WebInspector.Event} event |
| 868 */ | 812 */ |
| 869 _commandEvaluated: function(event) | 813 _commandEvaluated: function(event) |
| 870 { | 814 { |
| 871 var data = /** @type {{result: ?WebInspector.RemoteObject, text: string,
commandMessage: !WebInspector.ConsoleMessage, exceptionDetails: (!RuntimeAgent.
ExceptionDetails|undefined)}} */ (event.data); | 815 var data = /** @type {{result: ?WebInspector.RemoteObject, text: string,
commandMessage: !WebInspector.ConsoleMessage, exceptionDetails: (!RuntimeAgent.
ExceptionDetails|undefined)}} */ (event.data); |
| 872 this._prompt.history().pushHistoryItem(data.text); | 816 this._prompt.history().pushHistoryItem(data.text); |
| 873 this._consoleHistorySetting.set(this._prompt.history().historyData().sli
ce(-WebInspector.ConsoleView.persistedHistorySize)); | 817 this._consoleHistorySetting.set(this._prompt.history().historyData().sli
ce(-WebInspector.ConsoleView.persistedHistorySize)); |
| 874 this._printResult(data.result, data.commandMessage, data.exceptionDetail
s); | 818 this._printResult(data.result, data.commandMessage, data.exceptionDetail
s); |
| 875 }, | 819 }, |
| 876 | 820 |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 return true; | 1384 return true; |
| 1441 } | 1385 } |
| 1442 return false; | 1386 return false; |
| 1443 } | 1387 } |
| 1444 } | 1388 } |
| 1445 | 1389 |
| 1446 /** | 1390 /** |
| 1447 * @typedef {{messageIndex: number, matchIndex: number}} | 1391 * @typedef {{messageIndex: number, matchIndex: number}} |
| 1448 */ | 1392 */ |
| 1449 WebInspector.ConsoleView.RegexMatchRange; | 1393 WebInspector.ConsoleView.RegexMatchRange; |
| OLD | NEW |