This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Use windows-specific keybindings on linux #2331
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4c3a057
Makes windows specific Keybindings usable on Linux
pritambaral cee644a
Using not-equal-to instead of XOR. Cleared spacing issue.
pritambaral 4cf43a0
Revert. Modify addBinding to auto-expand "win" to "linux"
pritambaral 9bca94b
fix ctrl key handling on linux
jasonsanjose 89957f7
Merge remote-tracking branch 'pritambaral/linux' into jasonsanjose/li…
jasonsanjose cfa9755
fix merge error. clarify linux mapping.
jasonsanjose f0350cf
update comments
jasonsanjose 6881bf2
change windows-specific key bindings to be default bindings with a ma…
jasonsanjose 3f6709c
use windows-specific bindings by default for non-mac, non-win platforms
jasonsanjose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,8 +232,8 @@ 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), | ||
hasCtrl = (brackets.platform === "win") ? (event.ctrlKey) : (event.metaKey), | ||
var hasMacCtrl = (brackets.platform === "mac") ? (event.ctrlKey) : false, | ||
hasCtrl = (brackets.platform !== "mac") ? (event.ctrlKey) : (event.metaKey), | ||
hasAlt = (event.altKey), | ||
hasShift = (event.shiftKey), | ||
key = String.fromCharCode(event.keyCode); | ||
|
@@ -304,7 +304,9 @@ define(function (require, exports, module) { | |
* @param {string} commandID | ||
* @param {string|{{key: string, displayKey: string}}} keyBinding - a single shortcut. | ||
* @param {?string} platform - undefined indicates all platforms | ||
* @return {?{key: string, displayKey:String}} Returns a record for valid key bindings | ||
* @return {?{key: string, displayKey:String}} Returns a record for valid key bindings. | ||
* Returns null when key binding platform does not match, binding does not normalize, | ||
* or is already assigned. | ||
*/ | ||
function _addBinding(commandID, keyBinding, platform) { | ||
var key, | ||
|
@@ -407,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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrap these lines at 80 (or so) chars. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
* 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The wording of "If undefined, all platforms will use the key binding." can be improved: What about "If undefined, all platforms not explicitly defined will use the key binding." ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
* @return {{key: string, displayKey:String}|Array.<{key: string, displayKey:String}>} Returns record(s) for valid key binding(s) | ||
*/ | ||
|
@@ -424,7 +426,8 @@ define(function (require, exports, module) { | |
var keyBinding; | ||
results = []; | ||
|
||
keyBindings.forEach(function (keyBindingRequest) { | ||
keyBindings.forEach(function addSingleBinding(keyBindingRequest) { | ||
// attempt to add keybinding | ||
keyBinding = _addBinding(commandID, keyBindingRequest, keyBindingRequest.platform); | ||
|
||
if (keyBinding) { | ||
|
@@ -485,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]; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this file, in cases where the key bindings on mac are different from win/linux, the order is always generic first, followed by platform:mac. These can be specified in either order (and this file just happens to be organized that way), correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct