Bug 968424 - Change keyboard shortcut to move selected lines in source editor to Alt-Up/Down. r=anton, a=sledru
authorGabriel Luong <gabriel.luong@gmail.com>
Thu, 13 Feb 2014 10:02:51 -0500
changeset 177436 bc0a26f61e41a7fe9471c02bf4b213081ad4033a
parent 177435 8c70b73529424602f116613d5644d5f87896d33c
child 177437 c07438fae1688dcfa21bf2c3b29544bf2478b2d6
push id5380
push userryanvm@gmail.com
push dateMon, 10 Mar 2014 13:25:17 +0000
treeherdermozilla-aurora@83627088b0c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanton, sledru
bugs968424
milestone29.0a2
Bug 968424 - Change keyboard shortcut to move selected lines in source editor to Alt-Up/Down. r=anton, a=sledru
browser/devtools/sourceeditor/editor.js
browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
--- a/browser/devtools/sourceeditor/editor.js
+++ b/browser/devtools/sourceeditor/editor.js
@@ -148,18 +148,18 @@ function Editor(config) {
     styleActiveLine:   true,
     autoCloseBrackets: "()[]{}''\"\"",
     autoCloseEnabled:  useAutoClose,
     theme:             "mozilla"
   };
 
   // Additional shortcuts.
   this.config.extraKeys[Editor.keyFor("jumpToLine")] = () => this.jumpToLine();
-  this.config.extraKeys[Editor.keyFor("moveLineUp")] = () => this.moveLineUp();
-  this.config.extraKeys[Editor.keyFor("moveLineDown")] = () => this.moveLineDown();
+  this.config.extraKeys[Editor.keyFor("moveLineUp", { noaccel: true })] = () => this.moveLineUp();
+  this.config.extraKeys[Editor.keyFor("moveLineDown", { noaccel: true })] = () => this.moveLineDown();
   this.config.extraKeys[Editor.keyFor("toggleComment")] = "toggleComment";
 
   // Disable ctrl-[ and ctrl-] because toolbox uses those shortcuts.
   this.config.extraKeys[Editor.keyFor("indentLess")] = false;
   this.config.extraKeys[Editor.keyFor("indentMore")] = false;
 
   // If alternative keymap is provided, use it.
   if (keyMap === "emacs" || keyMap === "vim")
@@ -820,22 +820,23 @@ CM_MAPPING.forEach(function (name) {
 Editor.accel = function (key, modifiers={}) {
   return (modifiers.shift ? "Shift-" : "") +
          (Services.appinfo.OS == "Darwin" ? "Cmd-" : "Ctrl-") +
          (modifiers.alt ? "Alt-" : "") + key;
 };
 
 /**
  * Returns a string representation of a shortcut for a
- * specified command 'cmd'. Cmd- for macs, Ctrl- for other
- * platforms. Useful when overwriting or disabling default
- * shortcuts.
+ * specified command 'cmd'. Append Cmd- for macs, Ctrl- for other
+ * platforms unless noaccel is specified in the options. Useful when overwriting
+ * or disabling default shortcuts.
  */
-Editor.keyFor = function (cmd) {
-  return Editor.accel(L10N.GetStringFromName(cmd + ".commandkey"));
+Editor.keyFor = function (cmd, opts={ noaccel: false }) {
+  let key = L10N.GetStringFromName(cmd + ".commandkey");
+  return opts.noaccel ? key : Editor.accel(key);
 };
 
 // Since Gecko already provide complete and up to date list of CSS property
 // names, values and color names, we compute them so that they can replace
 // the ones used in CodeMirror while initiating an editor object. This is done
 // here instead of the file codemirror/css.js so as to leave that file untouched
 // and easily upgradable.
 function getCSSKeywords() {
--- a/browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
@@ -70,17 +70,15 @@ indentLess.commandkey=[
 # LOCALIZATION NOTE  (toolboxPrevTool.commandkey): This the key to use in
 # conjunction with accel (Command on Mac or Ctrl on other platforms) to increase
 # indentation level in CodeMirror. However, its default value also used by
 # the Toolbox to switch between tools
 #
 # DO NOT translate this key without proper synchronization with toolbox.dtd.
 indentMore.commandkey=]
 
-# LOCALIZATION NOTE  (moveLineUp.commandkey): This the key to use in
-# conjunction with accel (Command on Mac or Ctrl on other platforms) to move
+# LOCALIZATION NOTE  (moveLineUp.commandkey): This is the key to use to move
 # the selected lines up.
 moveLineUp.commandkey=Alt-Up
 
-# LOCALIZATION NOTE  (moveLineDown.commandkey): This the key to use in
-# conjunction with accel (Command on Mac or Ctrl on other platforms) to move
+# LOCALIZATION NOTE  (moveLineDown.commandkey): This is the key to use to move
 # the selected lines down.
 moveLineDown.commandkey=Alt-Down