Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
change windows-specific key bindings to be default bindings with a ma…
Browse files Browse the repository at this point in the history
…c-specific override. remove linux patch.
  • Loading branch information
jasonsanjose committed Nov 19, 2012
1 parent f0350cf commit 6881bf2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
33 changes: 11 additions & 22 deletions src/base-config/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
],
"edit.selectLine": [
{
"key": "Ctrl-L",
"platform": "win"
"key": "Ctrl-L"
},
{
"key": "Ctrl-L",
Expand All @@ -47,8 +46,7 @@
],
"edit.findNext": [
{
"key": "F3",
"platform": "win"
"key": "F3"
},
{
"key": "Cmd-G",
Expand All @@ -57,8 +55,7 @@
],
"edit.findPrevious": [
{
"key": "Shift-F3",
"platform": "win"
"key": "Shift-F3"
},
{
"key": "Cmd-Shift-G",
Expand All @@ -67,8 +64,7 @@
],
"edit.replace": [
{
"key": "Ctrl-H",
"platform": "win"
"key": "Ctrl-H"
},
{
"key": "Cmd-Alt-F",
Expand Down Expand Up @@ -96,8 +92,7 @@
"edit.lineUp": [
{
"key": "Ctrl-Shift-Up",
"displayKey": "Ctrl-Shift-↑",
"platform": "win"
"displayKey": "Ctrl-Shift-↑"
},
{
"key": "Cmd-Ctrl-Up",
Expand All @@ -108,8 +103,7 @@
"edit.lineDown": [
{
"key": "Ctrl-Shift-Down",
"displayKey": "Ctrl-Shift-↓",
"platform": "win"
"displayKey": "Ctrl-Shift-↓"
},
{
"key": "Cmd-Ctrl-Down",
Expand Down Expand Up @@ -150,8 +144,7 @@
],
"navigate.gotoLine": [
{
"key": "Ctrl-G",
"platform": "win"
"key": "Ctrl-G"
},
{
"key": "Cmd-L",
Expand All @@ -163,8 +156,7 @@
],
"navigate.nextDoc": [
{
"key": "Ctrl-Tab",
"platform": "win"
"key": "Ctrl-Tab"
},
{
"key": "Ctrl-Tab",
Expand All @@ -173,8 +165,7 @@
],
"navigate.prevDoc": [
{
"key": "Ctrl-Shift-Tab",
"platform": "win"
"key": "Ctrl-Shift-Tab"
},
{
"key": "Ctrl-Shift-Tab",
Expand All @@ -198,8 +189,7 @@
],
"debug.showDeveloperTools": [
{
"key": "F12",
"platform": "win"
"key": "F12"
},
{
"key": "Cmd-Opt-I",
Expand All @@ -208,8 +198,7 @@
],
"debug.refreshWindow": [
{
"key": "F5",
"platform": "win"
"key": "F5"
},
{
"key": "Cmd-R",
Expand Down
15 changes: 7 additions & 8 deletions src/command/KeyBindingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ define(function (require, exports, module) {
* Takes a keyboard event and translates it into a key in a key map
*/
function _translateKeyboardEvent(event) {
var hasMacCtrl = (brackets.platform === "win") ? false : (event.ctrlKey),
var hasMacCtrl = (brackets.platform === "mac") ? (event.ctrlKey) : false,
hasCtrl = (brackets.platform === "win") ? (event.ctrlKey) : (event.metaKey),
hasAlt = (event.altKey),
hasShift = (event.shiftKey),
Expand Down Expand Up @@ -409,7 +409,7 @@ define(function (require, exports, module) {
* @param {?({key: string, displayKey: string} | Array.<{key: string, displayKey: string, platform: string}>)} keyBindings - a single key binding
* or an array of keybindings. Example: "Shift-Cmd-F". Mac and Win key equivalents are automatically
* mapped to each other. Use displayKey property to display a different string (e.g. "CMD+" instead of "CMD=").
* @param {?string} platform - the target OS of the keyBindings either "mac" or "win". If undefined, all platforms will use
* @param {?string} platform - the target OS of the keyBindings either "mac", "win" or "linux". If undefined, all platforms will use
* the key binding. Ignored if keyBindings is passed an Array.
* @return {{key: string, displayKey:String}|Array.<{key: string, displayKey:String}>} Returns record(s) for valid key binding(s)
*/
Expand All @@ -432,12 +432,6 @@ define(function (require, exports, module) {

if (keyBinding) {
results.push(keyBinding);
} else if (brackets.platform === "linux" &&
keyBindingRequest.platform &&
keyBindingRequest.platform === "win") {
// if running on linux, map windows-specific keybindings to linux
keyBindingRequest.platform = brackets.platform;
addSingleBinding(keyBindingRequest);
}
});
} else {
Expand Down Expand Up @@ -494,6 +488,11 @@ define(function (require, exports, module) {
return bindings || [];
}

/**
* Adds default key bindings when commands are registered to CommandManager
* @param {$.Event} event jQuery event
* @param {Command} command Newly registered command
*/
function _handleCommandRegistered(event, command) {
var commandId = command.getID(),
defaults = KeyboardPrefs[commandId];
Expand Down

0 comments on commit 6881bf2

Please sign in to comment.