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

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

Issue 306023015: DevTools: [CodeMirror] show native copy/paste/cut items in editor context menu (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | « no previous file | no next file » | 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 this._blockIndentController = new WebInspector.CodeMirrorTextEditor.BlockInd entController(this._codeMirror); 132 this._blockIndentController = new WebInspector.CodeMirrorTextEditor.BlockInd entController(this._codeMirror);
133 this._fixWordMovement = new WebInspector.CodeMirrorTextEditor.FixWordMovemen t(this._codeMirror); 133 this._fixWordMovement = new WebInspector.CodeMirrorTextEditor.FixWordMovemen t(this._codeMirror);
134 this._selectNextOccurrenceController = new WebInspector.CodeMirrorTextEditor .SelectNextOccurrenceController(this, this._codeMirror); 134 this._selectNextOccurrenceController = new WebInspector.CodeMirrorTextEditor .SelectNextOccurrenceController(this, this._codeMirror);
135 135
136 this._codeMirror.on("changes", this._changes.bind(this)); 136 this._codeMirror.on("changes", this._changes.bind(this));
137 this._codeMirror.on("gutterClick", this._gutterClick.bind(this)); 137 this._codeMirror.on("gutterClick", this._gutterClick.bind(this));
138 this._codeMirror.on("cursorActivity", this._cursorActivity.bind(this)); 138 this._codeMirror.on("cursorActivity", this._cursorActivity.bind(this));
139 this._codeMirror.on("beforeSelectionChange", this._beforeSelectionChange.bin d(this)); 139 this._codeMirror.on("beforeSelectionChange", this._beforeSelectionChange.bin d(this));
140 this._codeMirror.on("scroll", this._scroll.bind(this)); 140 this._codeMirror.on("scroll", this._scroll.bind(this));
141 this._codeMirror.on("focus", this._focus.bind(this)); 141 this._codeMirror.on("focus", this._focus.bind(this));
142 this._codeMirror.on("contextmenu", this._contextMenu.bind(this)); 142 this.element.addEventListener("contextmenu", this._contextMenu.bind(this), f alse);
143 /** 143 /**
144 * @this {WebInspector.CodeMirrorTextEditor} 144 * @this {WebInspector.CodeMirrorTextEditor}
145 */ 145 */
146 function updateAnticipateJumpFlag(value) 146 function updateAnticipateJumpFlag(value)
147 { 147 {
148 this._isHandlingMouseDownEvent = value; 148 this._isHandlingMouseDownEvent = value;
149 } 149 }
150 this.element.addEventListener("mousedown", updateAnticipateJumpFlag.bind(thi s, true), true); 150 this.element.addEventListener("mousedown", updateAnticipateJumpFlag.bind(thi s, true), true);
151 this.element.addEventListener("mousedown", updateAnticipateJumpFlag.bind(thi s, false), false); 151 this.element.addEventListener("mousedown", updateAnticipateJumpFlag.bind(thi s, false), false);
152 152
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 var bottomLineToReveal = Math.min(lineNumber + (linesPerScreen / 2) - 1, this.linesCount - 1) | 0; 714 var bottomLineToReveal = Math.min(lineNumber + (linesPerScreen / 2) - 1, this.linesCount - 1) | 0;
715 this._codeMirror.scrollIntoView(new CodeMirror.Pos(bottomLineToRevea l, 0)); 715 this._codeMirror.scrollIntoView(new CodeMirror.Pos(bottomLineToRevea l, 0));
716 } 716 }
717 }, 717 },
718 718
719 _gutterClick: function(instance, lineNumber, gutter, event) 719 _gutterClick: function(instance, lineNumber, gutter, event)
720 { 720 {
721 this.dispatchEventToListeners(WebInspector.TextEditor.Events.GutterClick , { lineNumber: lineNumber, event: event }); 721 this.dispatchEventToListeners(WebInspector.TextEditor.Events.GutterClick , { lineNumber: lineNumber, event: event });
722 }, 722 },
723 723
724 _contextMenu: function(codeMirror, event) 724 _contextMenu: function(event)
725 { 725 {
726 var contextMenu = new WebInspector.ContextMenu(event); 726 var contextMenu = new WebInspector.ContextMenu(event);
727 var target = event.target.enclosingNodeOrSelfWithClass("CodeMirror-gutte r-elt"); 727 var target = event.target.enclosingNodeOrSelfWithClass("CodeMirror-gutte r-elt");
728 if (target) 728 if (target)
729 this._delegate.populateLineGutterContextMenu(contextMenu, parseInt(t arget.textContent, 10) - 1); 729 this._delegate.populateLineGutterContextMenu(contextMenu, parseInt(t arget.textContent, 10) - 1);
730 else 730 else
731 this._delegate.populateTextAreaContextMenu(contextMenu, 0); 731 this._delegate.populateTextAreaContextMenu(contextMenu, 0);
732 contextMenu.show(); 732 contextMenu.show();
733 }, 733 },
734 734
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 var backgroundColorRule = backgroundColor ? ".CodeMirror .CodeMirror-selecte d { background-color: " + backgroundColor + ";}" : ""; 2123 var backgroundColorRule = backgroundColor ? ".CodeMirror .CodeMirror-selecte d { background-color: " + backgroundColor + ";}" : "";
2124 var foregroundColor = InspectorFrontendHost.getSelectionForegroundColor(); 2124 var foregroundColor = InspectorFrontendHost.getSelectionForegroundColor();
2125 var foregroundColorRule = foregroundColor ? ".CodeMirror .CodeMirror-selecte dtext:not(.CodeMirror-persist-highlight) { color: " + foregroundColor + "!import ant;}" : ""; 2125 var foregroundColorRule = foregroundColor ? ".CodeMirror .CodeMirror-selecte dtext:not(.CodeMirror-persist-highlight) { color: " + foregroundColor + "!import ant;}" : "";
2126 if (!foregroundColorRule && !backgroundColorRule) 2126 if (!foregroundColorRule && !backgroundColorRule)
2127 return; 2127 return;
2128 2128
2129 var style = document.createElement("style"); 2129 var style = document.createElement("style");
2130 style.textContent = backgroundColorRule + foregroundColorRule; 2130 style.textContent = backgroundColorRule + foregroundColorRule;
2131 document.head.appendChild(style); 2131 document.head.appendChild(style);
2132 })(); 2132 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698