Update keyboard shortcuts per discussion. Also, make the labels platform sensitive.

This commit is contained in:
Murtuza Zabuawala 2017-07-26 12:50:42 +01:00 committed by Dave Page
parent d339d6b816
commit 1fa9648a21
4 changed files with 47 additions and 20 deletions

View File

@ -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 |
+--------------------------+------------------+-------------------------------------+
@ -89,9 +89,7 @@ When using the Query Tool, the following shortcuts are available:
+--------------------------+--------------------+-----------------------------------+
| Ctrl+G | Cmd+G | Find next |
+--------------------------+--------------------+-----------------------------------+
| Shift+Ctrl+G | Shift+Cmd+G | Find previous |
| Ctrl+Shift+G | Cmd+Shift+G | Find previous |
+--------------------------+--------------------+-----------------------------------+
| Shift+Ctrl+F | Shift+Cmd+F | Replace |
| Ctrl+Shift+F | Cmd+Shift+F | Replace |
+--------------------------+--------------------+-----------------------------------+
| Shift+Ctrl+R | Shift+Cmd+Option+F | Replace all |
+--------------------------+--------------------+-----------------------------------+

View File

@ -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();
}

View File

@ -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
)

View File

@ -58,17 +58,26 @@
<ul class="dropdown-menu">
<li>
<a id="btn-find-menu-find" href="#">
<span>{{ _('Find (Ctrl/Cmd+F)') }}</span>
<span> {{ _('Find') }}{% if client_plaform == 'macos' -%}
{{ _(' (Cmd+F)') }}
{% else %}
{{ _(' (Ctrl+F)') }}{%- endif %}</span>
</a>
</li>
<li>
<a id="btn-find-menu-find-next" href="#">
<span>{{ _('Find next (Ctrl/Cmd+G)') }}</span>
<span> {{ _('Find next') }}{% if client_plaform == 'macos' -%}
{{ _(' (Cmd+G)') }}
{% else %}
{{ _(' (Ctrl+G)') }}{%- endif %}</span>
</a>
</li>
<li>
<a id="btn-find-menu-find-previous" href="#">
<span>{{ _('Find previous (Shift+Ctrl/Cmd+G)') }}</span>
<span> {{ _('Find previous') }}{% if client_plaform == 'macos' -%}
{{ _(' (Cmd+Shift+G)') }}
{% else %}
{{ _(' (Ctrl+Shift+G)') }}{%- endif %}</span>
</a>
</li>
<li>
@ -79,7 +88,10 @@
<li class="divider"></li>
<li>
<a id="btn-find-menu-replace" href="#">
<span>{{ _('Replace (Shift+Ctrl/Cmd+F)') }}</span>
<span> {{ _('Replace') }}{% if client_plaform == 'macos' -%}
{{ _(' (Cmd+Shift+F)') }}
{% else %}
{{ _(' (Ctrl+Shift+F)') }}{%- endif %}</span>
</a>
</li>
<li>
@ -127,13 +139,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>