Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: Source/devtools/front_end/CodeMirrorTextEditor.js

Issue 15665004: DevTools: [CodeMirror] add comment plugin (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add shortcut Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/devtools.gyp ('k') | Source/devtools/front_end/ScriptsPanelDescriptor.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « Source/devtools/devtools.gyp ('k') | Source/devtools/front_end/ScriptsPanelDescriptor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698