Hi Dave,
Please find updated patch for new shortcut keys, I have tested it on all
three major platforms (macOS, Linux & Windows with Chrome, FF & IE11
Browsers).
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Fri, Jul 21, 2017 at 9:38 PM, Robert Eckhardt <[email protected]>
wrote:
> Right - we lose the ability to uncomment multiple levels though, which may
>> also be useful.
>>
>
> Well yes.
>
> I would argue that simplicity trumps potential use. I'd also argue that
> attempting to maintain consistency across environments (IDEs, etc. ) is
> advantageous. This was the philosophy we were going with when enabling
> excel like behavior (also why I'm not fully happy with how it is today).
>
> -- Rob
>
diff --git a/docs/en_US/keyboard_shortcuts.rst
b/docs/en_US/keyboard_shortcuts.rst
index cd0938d..32f06f0 100644
--- a/docs/en_US/keyboard_shortcuts.rst
+++ b/docs/en_US/keyboard_shortcuts.rst
@@ -41,11 +41,11 @@ When using the syntax-highlighting SQL editors, the
following shortcuts are avai
+--------------------------+------------------+-------------------------------------+
| Ctrl+Alt+Right | Cmd+Option+Right | Move right one word
|
+--------------------------+------------------+-------------------------------------+
-| Ctrl+Shift+, | Ctrl+Shift+, | Comment selected code (Inline)
|
+| Ctrl+Shift+/ | Cmd+Shift+/ | Comment selected code (Inline)
|
+--------------------------+------------------+-------------------------------------+
-| Ctrl+Shift+. | Ctrl+Shift+. | Uncomment selected code
(Inline) |
+| Ctrl+Shift+. | Cmd+Shift+. | Uncomment selected code
(Inline) |
+--------------------------+------------------+-------------------------------------+
-| Ctrl+Shift+/ | Ctrl+Shift+/ | Comment/Uncomment code (Block)
|
+| Ctrl+/ | Cmd+/ | Comment/Uncomment code (Block)
|
+--------------------------+------------------+-------------------------------------+
| Ctrl+A | Cmd+A | Select all
|
+--------------------------+------------------+-------------------------------------+
diff --git a/web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js
b/web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js
index c117413..5d947d1 100644
--- a/web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js
+++ b/web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js
@@ -1,9 +1,9 @@
const F5_KEY = 116,
F7_KEY = 118,
F8_KEY = 119,
- COMMA_KEY = 188,
PERIOD_KEY = 190,
- FWD_SLASH_KEY = 191;
+ FWD_SLASH_KEY = 191,
+ IS_CMD_KEY = window.navigator.platform.search('Mac') != -1;
function keyboardShortcuts(sqlEditorController, event) {
if (sqlEditorController.isQueryRunning()) {
@@ -24,13 +24,16 @@ function keyboardShortcuts(sqlEditorController, event) {
} else if (keyCode === F8_KEY) {
event.preventDefault();
sqlEditorController.download();
- } else if (event.shiftKey && event.ctrlKey && keyCode === COMMA_KEY) {
+ } else if (((IS_CMD_KEY && event.metaKey) || (!IS_CMD_KEY && event.ctrlKey))
&&
+ event.shiftKey && keyCode === FWD_SLASH_KEY) {
_stopEventPropagation();
sqlEditorController.commentLineCode();
- } else if (event.shiftKey && event.ctrlKey && keyCode === PERIOD_KEY) {
+ } else if (((IS_CMD_KEY && event.metaKey) || (!IS_CMD_KEY && event.ctrlKey))
&&
+ event.shiftKey && keyCode === PERIOD_KEY) {
_stopEventPropagation();
sqlEditorController.uncommentLineCode();
- } else if (event.shiftKey && event.ctrlKey && keyCode === FWD_SLASH_KEY) {
+ } else if (((IS_CMD_KEY && event.metaKey) || (!IS_CMD_KEY && event.ctrlKey))
&&
+ keyCode === FWD_SLASH_KEY) {
_stopEventPropagation();
sqlEditorController.commentBlockCode();
}
diff --git a/web/pgadmin/tools/datagrid/__init__.py
b/web/pgadmin/tools/datagrid/__init__.py
index 08b01ab..d3a4a9d 100644
--- a/web/pgadmin/tools/datagrid/__init__.py
+++ b/web/pgadmin/tools/datagrid/__init__.py
@@ -15,6 +15,7 @@ import pickle
import random
from flask import Response, url_for, session, request, make_response
+from werkzeug.useragents import UserAgent
from flask import current_app as app
from flask_babel import gettext
from flask_security import login_required
@@ -183,6 +184,9 @@ def panel(trans_id, is_query_tool, editor_title):
else:
sURL = None
+ # We need client OS information to render correct Keyboard shortcuts
+ user_agent = UserAgent(request.headers.get('User-Agent'))
+
"""
Animations and transitions are not automatically GPU accelerated and by
default use browser's slow rendering engine.
We need to set 'translate3d' value of '-webkit-transform' property in
order to use GPU.
@@ -212,7 +216,8 @@ def panel(trans_id, is_query_tool, editor_title):
editor_title=editor_title, script_type_url=sURL,
is_desktop_mode=app.PGADMIN_RUNTIME,
is_linux=is_linux_platform,
- is_new_browser_tab=new_browser_tab
+ is_new_browser_tab=new_browser_tab,
+ client_plaform=user_agent.platform
)
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index fa6f750..937ae87 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -127,13 +127,22 @@
<span> {{ _('Unindent Selection (Shift+Tab)') }}
</span>
</a>
<a id="btn-comment-line" href="#">
- <span> {{ _('Inline Comment Selection
(Ctrl+Shift+,)') }} </span>
+ <span> {{ _('Inline Comment Selection') }}{% if
client_plaform == 'macos' -%}
+ {{ _(' (Cmd+Shift+/)') }}
+ {% else %}
+ {{ _(' (Ctrl+Shift+/)') }}{%- endif %}</span>
</a>
<a id="btn-uncomment-line" href="#">
- <span> {{ _('Inline Uncomment Selection
(Ctrl+Shift+.)') }} </span>
+ <span> {{ _('Inline Uncomment Selection') }}{% if
client_plaform == 'macos' -%}
+ {{ _(' (Cmd+Shift+.)') }}
+ {% else %}
+ {{ _(' (Ctrl+Shift+.)') }}{%- endif %}</span>
</a>
<a id="btn-toggle-comment-block" href="#">
- <span> {{ _('Block Comment/Uncomment Selection
(Ctrl+Shift+/)') }} </span>
+ <span> {{ _('Block Comment/Uncomment Selection')
}}{% if client_plaform == 'macos' -%}
+ {{ _(' (Cmd+/)') }}
+ {% else %}
+ {{ _(' (Ctrl+/)') }}{%- endif %}</span>
</a>
</li>
</ul>