Subject: [pgAdmin4][Patch]: RM#1478 - Make code mirror text editor keyboard shortcuts consistent irrespective of platform type

From: Surinder Kumar <[email-masked]>
Date: Fri, 5 Aug 2016 23:12:40 +0530

Hi

I found that *Code-mirror* library itself provides the List of keyboard
shortcuts for Mac OSX and other platform type.
We just need to pass them in extraKeys param while creating code-mirror
instance.

*Following is the keyboard shortcuts for various operations in text editor:*

   1. Copy -                            [Ctrl-C, Cmd-C]
   2. Cut -                               [Ctrl-X, Cmd-X]
   3. Select All -                      [Ctrl-A, Cmd-A]
   4. Undo -                            [Ctrl-Z, Cmd-Z]
   5. Redo -                            [Ctrl-Y, Cmd-Y]
   6. Delete Line -                  [Ctrl-D, Cmd-D]
   7. Move left/right(words) -  [Alt-Left, Alt-Right]
   8. Move start/end of line -  [Cmd-Left, Cmd-Right] // *Ctrl-Left/Right*
   are bound to System   shortcuts. so these keys cannot be used.

These keyboard shortcuts are consistent in Web/Runtime applications in all
platform types.

*Issue not fixed:*
keyboard shortcut for *Paste text* doesn't work in Mac Runtime only. It is
working on Linux runtime & Windows Runtime.
An issue "Key shortcuts doesn't work on Mac OS for QWebView widget
<https://bugreports.qt.io/browse/QTBUG-46330?jql=project%20%3D%20QTBUG%20AND%20resolution%20%3D%20Unresolved%20AND%20assignee%20%3D%20allan.jensen%20ORDER%20BY%20priority%20DESC>"
is also reported.

I also found that right click paste is working in Mac Runtime which is the
feature of code-mirror, So I am looking into its code to figure out and I
will send a patch with fix once it gets fixed.

Please find attached patch and review.

Thanks,
Surinder Kumar

-- 
Sent via pgadmin-hackers mailing list ([email-masked])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

---

From: Dave Page <[email-masked]>
Date: Mon, 8 Aug 2016 12:13:07 +0100

Hi Surinder,

This looks very promising, but it only covers the query tool at
present. We need the shortcuts to apply to all codemirror instances.
Do the others work anyway, because we're invoking in a different way,
or is more work needed there?

On Fri, Aug 5, 2016 at 6:42 PM, Surinder Kumar
<[email-masked]> wrote:
> Hi
>
> I found that Code-mirror library itself provides the List of keyboard
> Following is the keyboard shortcuts for various operations in text editor:
>
> Copy -                            [Ctrl-C, Cmd-C]
> Cut -                               [Ctrl-X, Cmd-X]
> Select All -                      [Ctrl-A, Cmd-A]
> Undo -                            [Ctrl-Z, Cmd-Z]
> Redo -                            [Ctrl-Y, Cmd-Y]
> Delete Line -                  [Ctrl-D, Cmd-D]
> Move left/right(words) -  [Alt-Left, Alt-Right]
> Move start/end of line -  [Cmd-Left, Cmd-Right] // Ctrl-Left/Right are bound
> to System   shortcuts. so these keys cannot be used.
>
> Issue not fixed:
> keyboard shortcut for Paste text doesn't work in Mac Runtime only. It is
> An issue "Key shortcuts doesn't work on Mac OS for QWebView widget" is also
> reported.
>

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

---

From: Surinder Kumar <[email-masked]>
Date: Mon, 8 Aug 2016 17:45:22 +0530

> or is more work needed there?

​To apply the same shortcuts to other codemirror instances(e.g:
SqlTabControl) we just need to set a parameter
*extraKeys: pgAdmin.editor_shortcut_keys​ *for every codemirror instance.
As of now, shortcuts are applicable to *query tool & data filter*.

Also, we need to define *pgAdmin.editor_shortcut_keys​ *variable in
server.js instead of sqleditor.js to work it for
other code mirror instances.

---

From: Dave Page <[email-masked]>
Date: Mon, 8 Aug 2016 13:22:31 +0100

On Mon, Aug 8, 2016 at 1:15 PM, Surinder Kumar
<[email-masked]> wrote:
> To apply the same shortcuts to other codemirror instances(e.g:
> extraKeys: pgAdmin.editor_shortcut_keys for every codemirror instance.
> As of now, shortcuts are applicable to query tool & data filter.
>
> Also, we need to define pgAdmin.editor_shortcut_keys variable in server.js
> instead of sqleditor.js to work it for

OK, please update the patch to do that.

Can you get that to me in the next hour or so? I'd like to include it in beta 4.

---

From: Surinder Kumar <[email-masked]>
Date: Mon, 8 Aug 2016 17:53:42 +0530

> Can you get that to me in the next hour or so? I'd like to include it in
​Sure.​

> >> > feature of code-mirror, So I am looking into its code to figure out
> and
> >> > I

---

From: Surinder Kumar <[email-masked]>
Date: Mon, 8 Aug 2016 19:04:17 +0530

Hi Dave,

This patch contains following changes:

   1. Add "*editor_shortcut_keys*" variable to *pgAdmin.Browser* in
   *browser.js* object to make it accessible to all pgAdmin modules.
   2. Apply shortcuts keys to following code mirror instances:

           a) Query tool, Query filter & Datagrid.
           b) Debugger tool.
           c) Sql Panel.
           d) SqlTab & SqlField Controls.

Please find updated patch and review.

On Mon, Aug 8, 2016 at 5:53 PM, Surinder Kumar <
[email-masked]> wrote:

>> >> > Move start/end of line -  [Cmd-Left, Cmd-Right] // Ctrl-Left/Right
>> are
>> >> > bound
>> >> > These keyboard shortcuts are consistent in Web/Runtime applications
>> in
>> >> > all
>> >> > platform types.
>> >> >
>> >> > Issue not fixed:
>> >> > An issue "Key shortcuts doesn't work on Mac OS for QWebView widget"
>> is
>> >> > also
>> >> > reported.
>> >> >
>> >> > I also found that right click paste is working in Mac Runtime which
>> is
>> >> > the

---

From: Dave Page <[email-masked]>
Date: Mon, 8 Aug 2016 15:48:16 +0100

Thanks, applied with minor changes per our discussion on skype.

On Mon, Aug 8, 2016 at 2:34 PM, Surinder Kumar
<[email-masked]> wrote:
> Add "editor_shortcut_keys" variable to pgAdmin.Browser in browser.js object
> to make it accessible to all pgAdmin modules.
> Apply shortcuts keys to following code mirror instances:
>
> On Mon, Aug 8, 2016 at 5:53 PM, Surinder Kumar
>> Sure.