| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 importScript("cm/codemirror.js"); | 31 importScript("cm/codemirror.js"); |
| 32 importScript("cm/css.js"); | 32 importScript("cm/css.js"); |
| 33 importScript("cm/javascript.js"); | 33 importScript("cm/javascript.js"); |
| 34 importScript("cm/xml.js"); | 34 importScript("cm/xml.js"); |
| 35 importScript("cm/htmlmixed.js"); | 35 importScript("cm/htmlmixed.js"); |
| 36 importScript("cm/matchbrackets.js"); | 36 importScript("cm/matchbrackets.js"); |
| 37 importScript("cm/closebrackets.js"); | 37 importScript("cm/closebrackets.js"); |
| 38 importScript("cm/markselection.js"); | 38 importScript("cm/markselection.js"); |
| 39 importScript("cm/showhint.js"); | 39 importScript("cm/showhint.js"); |
| 40 importScript("cm/comment.js"); |
| 40 | 41 |
| 41 /** | 42 /** |
| 42 * @constructor | 43 * @constructor |
| 43 * @extends {WebInspector.View} | 44 * @extends {WebInspector.View} |
| 44 * @implements {WebInspector.TextEditor} | 45 * @implements {WebInspector.TextEditor} |
| 45 * @param {?string} url | 46 * @param {?string} url |
| 46 * @param {WebInspector.TextEditorDelegate} delegate | 47 * @param {WebInspector.TextEditorDelegate} delegate |
| 47 */ | 48 */ |
| 48 WebInspector.CodeMirrorTextEditor = function(url, delegate) | 49 WebInspector.CodeMirrorTextEditor = function(url, delegate) |
| 49 { | 50 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 66 this._codeMirror = window.CodeMirror(this.element, { | 67 this._codeMirror = window.CodeMirror(this.element, { |
| 67 lineNumbers: true, | 68 lineNumbers: true, |
| 68 gutters: ["CodeMirror-linenumbers"], | 69 gutters: ["CodeMirror-linenumbers"], |
| 69 matchBrackets: true, | 70 matchBrackets: true, |
| 70 smartIndent: false, | 71 smartIndent: false, |
| 71 styleSelectedText: true, | 72 styleSelectedText: true, |
| 72 electricChars: false, | 73 electricChars: false, |
| 73 autoCloseBrackets: true | 74 autoCloseBrackets: true |
| 74 }); | 75 }); |
| 75 | 76 |
| 76 var extraKeys = {"Ctrl-Space": "autocomplete"}; | 77 var extraKeys = {}; |
| 78 extraKeys["Ctrl-Space"] = "autocomplete"; |
| 79 extraKeys[(WebInspector.isMac() ? "Cmd-" : "Ctrl-") + "/"] = "toggleComment"
; |
| 77 var indent = WebInspector.settings.textEditorIndent.get(); | 80 var indent = WebInspector.settings.textEditorIndent.get(); |
| 78 if (indent === WebInspector.TextUtils.Indent.TabCharacter) { | 81 if (indent === WebInspector.TextUtils.Indent.TabCharacter) { |
| 79 this._codeMirror.setOption("indentWithTabs", true); | 82 this._codeMirror.setOption("indentWithTabs", true); |
| 80 this._codeMirror.setOption("indentUnit", 4); | 83 this._codeMirror.setOption("indentUnit", 4); |
| 81 } else { | 84 } else { |
| 82 this._codeMirror.setOption("indentWithTabs", false); | 85 this._codeMirror.setOption("indentWithTabs", false); |
| 83 this._codeMirror.setOption("indentUnit", indent.length); | 86 this._codeMirror.setOption("indentUnit", indent.length); |
| 84 extraKeys.Tab = function(codeMirror) | 87 extraKeys.Tab = function(codeMirror) |
| 85 { | 88 { |
| 86 if (codeMirror.somethingSelected()) | 89 if (codeMirror.somethingSelected()) |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 var modifierKey = WebInspector.isMac() ? "Alt" : "Ctrl"; | 995 var modifierKey = WebInspector.isMac() ? "Alt" : "Ctrl"; |
| 993 var leftKey = modifierKey + "-Left"; | 996 var leftKey = modifierKey + "-Left"; |
| 994 var rightKey = modifierKey + "-Right"; | 997 var rightKey = modifierKey + "-Right"; |
| 995 var keyMap = {}; | 998 var keyMap = {}; |
| 996 keyMap[leftKey] = moveLeft.bind(this, false); | 999 keyMap[leftKey] = moveLeft.bind(this, false); |
| 997 keyMap[rightKey] = moveRight.bind(this, false); | 1000 keyMap[rightKey] = moveRight.bind(this, false); |
| 998 keyMap["Shift-" + leftKey] = moveLeft.bind(this, true); | 1001 keyMap["Shift-" + leftKey] = moveLeft.bind(this, true); |
| 999 keyMap["Shift-" + rightKey] = moveRight.bind(this, true); | 1002 keyMap["Shift-" + rightKey] = moveRight.bind(this, true); |
| 1000 codeMirror.addKeyMap(keyMap); | 1003 codeMirror.addKeyMap(keyMap); |
| 1001 } | 1004 } |
| OLD | NEW |