Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120360228
PhabricatorHelpKeyboardShortcutController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 3, 18:48
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Jul 5, 18:48 (2 d)
Engine
blob
Format
Raw Data
Handle
27171001
Attached To
rPH Phabricator
PhabricatorHelpKeyboardShortcutController.php
View Options
<?php
final
class
PhabricatorHelpKeyboardShortcutController
extends
PhabricatorHelpController
{
public
function
shouldAllowPublic
()
{
return
true
;
}
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$keys
=
$request
->
getStr
(
'keys'
);
try
{
$keys
=
phutil_json_decode
(
$keys
);
}
catch
(
PhutilJSONParserException
$ex
)
{
return
new
Aphront400Response
();
}
// There have been at least two users asking for a keyboard shortcut to
// close the dialog, so be explicit that escape works since it isn't
// terribly discoverable.
$keys
[]
=
array
(
'keys'
=>
array
(
'esc'
),
'description'
=>
pht
(
'Close any dialog, including this one.'
),
);
$stroke_map
=
array
(
'left'
=>
"
\x
E2
\x
86
\x
90"
,
'right'
=>
"
\x
E2
\x
86
\x
92"
,
'up'
=>
"
\x
E2
\x
86
\x
91"
,
'down'
=>
"
\x
E2
\x
86
\x
93"
,
'return'
=>
"
\x
E2
\x
8F
\x
8E"
,
'tab'
=>
"
\x
E2
\x
87
\x
A5"
,
'delete'
=>
"
\x
E2
\x
8C
\x
AB"
,
);
$rows
=
array
();
foreach
(
$keys
as
$shortcut
)
{
$keystrokes
=
array
();
foreach
(
$shortcut
[
'keys'
]
as
$stroke
)
{
$stroke
=
idx
(
$stroke_map
,
$stroke
,
$stroke
);
$keystrokes
[]
=
phutil_tag
(
'kbd'
,
array
(),
$stroke
);
}
$keystrokes
=
phutil_implode_html
(
' or '
,
$keystrokes
);
$rows
[]
=
phutil_tag
(
'tr'
,
array
(),
array
(
phutil_tag
(
'th'
,
array
(),
$keystrokes
),
phutil_tag
(
'td'
,
array
(),
$shortcut
[
'description'
]),
));
}
$table
=
phutil_tag
(
'table'
,
array
(
'class'
=>
'keyboard-shortcut-help'
),
$rows
);
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'Keyboard Shortcuts'
))
->
appendChild
(
$table
)
->
addCancelButton
(
'#'
,
pht
(
'Close'
));
}
}
Event Timeline
Log In to Comment