fix(preferences): Display multiple keybindings when available

This commit is contained in:
Ben Gotow 2015-08-14 16:41:52 -07:00
parent 94372f22c8
commit e7fce1f120
4 changed files with 33 additions and 8 deletions

View file

@ -42,8 +42,7 @@ class PreferencesKeymaps extends React.Component
_getStateFromKeymaps: =>
bindings = {}
for [command, label] in DisplayedKeybindings
[found] = atom.keymaps.findKeyBindings(command: command, target: document.body) || []
bindings[command] = found
bindings[command] = atom.keymaps.findKeyBindings(command: command, target: document.body) || []
bindings
render: =>
@ -69,19 +68,32 @@ class PreferencesKeymaps extends React.Component
</div>
_renderBindingFor: ([command, label]) =>
description = "None"
descriptions = []
if @state.bindings[command]
{keystrokes} = @state.bindings[command]
description = keystrokes.replace(/-/gi,'').replace(/cmd/gi, '⌘').replace(/alt/gi, '⌥').replace(/shift/gi, '⇧').replace(/ctrl/gi, '^').toUpperCase()
for binding in @state.bindings[command]
descriptions.push(@_formatKeystrokes(binding.keystrokes))
if descriptions.length is 0
value = 'None'
else
value = _.uniq(descriptions).join(', ')
<Flexbox className="shortcut" key={command}>
<div className="shortcut-name">{label}</div>
<div className="shortcut-value">{description}</div>
<div className="shortcut-value">{value}</div>
</Flexbox>
_renderBindings: =>
DisplayedKeybindings.map(@_renderBindingFor)
_formatKeystrokes: (keystrokes) ->
if process.platform is 'win32'
# On Windows, display cmd-shift-c
return keystrokes
else
# On Mac and Linux, display ⌘⇧C
return keystrokes.replace(/-/gi,'').replace(/cmd/gi, '⌘').replace(/alt/gi, '⌥').replace(/shift/gi, '⇧').replace(/ctrl/gi, '^').toUpperCase()
_onShowUserKeymaps: =>
require('shell').openItem(atom.keymaps.getUserKeymapPath())

View file

@ -192,7 +192,6 @@ body.platform-darwin {
&.shortcut-select {
padding: 5px 0px 20px 0px;
select {
font-size: @font-size-larger;
width: 75%;
}
}

View file

@ -23,3 +23,17 @@
'e' : 'core:remove-item' # Gmail
's' : 'core:star-item' #Gmail
'x' : 'core:select-item'
# Gmail also includes some more basic ones that users expect from desktop software.
'body.platform-darwin':
'cmd-n' : 'application:new-message'
'cmd-r' : 'application:reply'
'cmd-R' : 'application:reply-all'
'cmd-F' : 'application:forward'
'body.platform-linux, body.platform-win32':
'ctrl-n' : 'application:new-message'
'ctrl-r' : 'application:reply'
'ctrl-R' : 'application:reply-all'
'ctrl-F' : 'application:forward'

View file

@ -196,7 +196,7 @@ var openWindowForComponent = function(Component, options) {
if (!styleNode.sourcePath) {
continue;
}
if ((styleNode.sourcePath.indexOf("static/index") > 0) || (options.stylesheetRegex && options.stylesheetRegex.test(styleNode.sourcePath))) {
if ((styleNode.sourcePath.indexOf('index') > 0) || (options.stylesheetRegex && options.stylesheetRegex.test(styleNode.sourcePath))) {
thinStyles = thinStyles + styleNode.innerText;
}
}