Skip to contentSkip to conversation

git-gui: Handle Ctrl + BS/Del in the commit msg

PATCH Applied Ismael Luceno 2 participants 4 messages May 12, 2020 – May 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 git-gui: Handle Ctrl + BS/Del in the commit msg

From: Ismael Luceno <[email protected]>

- Control+BackSpace: Delete word to the left of the cursor.
- Control+Delete : Delete word to the right of the cursor.

Originally introduced by BRIEF and Turbo Vision between 1985 and 1992, they were adopted by most CUA-Compliant UIs, including those of: OS/2, Windows, Mac OS, Qt, GTK, Open/Libre Office, Gecko, and GNU Emacs.

In both cases Tk already implements the functionality bound to other key combination, so we use that.

Graphical examples:

Deleting to the left:

        v------ pointer

X_WORD____X
^-----^------ selection

Deleting to the right:
v--------- pointer
X_WORD_X
^--^------ selection

---
I'm re-submitting the patch after >1 year.

CC Junio C Hamano <[email protected]>
CC "brian m. carlson" <[email protected]>
CC Pat Thoyts <[email protected]>
CC Johannes Schindelin <[email protected]>

Notes:
Changes since v2:
- Reimplemented via existing events, which correctly delete spaces.
- Further improved commit message.

Changes since v1:
- Improved commit message.

 git-gui/git-gui.sh | 2 ++
 1 file changed, 2 insertions(+)
git-gui/git-gui.sh +2 -0
index 6de74ce639..c4e0270626 100755
@@ -3812,6 +3812,8 @@ bind $ui_comm <$M1B-Key-KP_Subtract> {show_less_context;break}
 bind $ui_comm <$M1B-Key-equal> {show_more_context;break}
 bind $ui_comm <$M1B-Key-plus> {show_more_context;break}
 bind $ui_comm <$M1B-Key-KP_Add> {show_more_context;break}
+bind $ui_comm <Control-Key-BackSpace> {event generate %W <Meta-Delete>;break}
+bind $ui_comm <Control-Key-Delete> {event generate %W <Meta-d>;break}
 
 bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
 bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
Signature · 1 line
2.19.1
#1 lore raw

Hi Ismael,

git-gui/git-gui.sh

Quoted 49 lines · Ismael Luceno

From: Ismael Luceno <[email protected]>

- Control+BackSpace: Delete word to the left of the cursor.
- Control+Delete : Delete word to the right of the cursor.

Originally introduced by BRIEF and Turbo Vision between 1985 and 1992, they were adopted by most CUA-Compliant UIs, including those of: OS/2, Windows, Mac OS, Qt, GTK, Open/Libre Office, Gecko, and GNU Emacs.

In both cases Tk already implements the functionality bound to other key combination, so we use that.

Graphical examples:

Deleting to the left:

        v------ pointer

X_WORD____X
^-----^------ selection

Deleting to the right:
v--------- pointer
X_WORD_X
^--^------ selection

---
I'm re-submitting the patch after >1 year.

CC Junio C Hamano <[email protected]>
CC "brian m. carlson" <[email protected]>
CC Pat Thoyts <[email protected]>
CC Johannes Schindelin <[email protected]>

Notes:
Changes since v2:
- Reimplemented via existing events, which correctly delete spaces.
- Further improved commit message.

Changes since v1:
- Improved commit message.

 git-gui/git-gui.sh | 2 ++
 1 file changed, 2 insertions(+)
git-gui/git-gui.sh +0 -0
index 6de74ce639..c4e0270626 100755

You based the patch on top of the Git tree. Since Git Gui is maintained separate from Git, patches are expected to be based on top of the Git Gui tree [0]. I fixed it up and applied the patch on my tree.

git-gui/git-gui.sh bind $ui_comm <$M1B-Key-KP_Subtract> {show_less_context;break} · line 3816

Quoted 6 lines
git-gui/git-gui.sh +2 -0
@@ -3812,6 +3812,8 @@ bind $ui_comm <$M1B-Key-KP_Subtract> {show_less_context;break}
 bind $ui_comm <$M1B-Key-equal> {show_more_context;break}
 bind $ui_comm <$M1B-Key-plus> {show_more_context;break}
 bind $ui_comm <$M1B-Key-KP_Add> {show_more_context;break}
+bind $ui_comm <Control-Key-BackSpace> {event generate %W <Meta-Delete>;break}
+bind $ui_comm <Control-Key-Delete> {event generate %W <Meta-d>;break}

Don't use "Control" directly to maintain compatibility with MacOS. Use $M1B like the surrounding code does. I fixed it up locally, so no need to send in a new version. You can find the fixed up version here [1]. Test it if you'd like.

Will merge it in. Thanks.

[0] https://github.com/prati0100/git-gui/
[1] https://github.com/prati0100/git-gui/tree/il/ctrl-bs-del

Signature · 2 lines
Regards,
Pratyush Yadav
#2 lore raw
Quoted 69 lines · Pratyush Yadav

Hi Ismael,

git-gui/git-gui.sh

Quoted 49 lines · Ismael Luceno

From: Ismael Luceno <[email protected]>

- Control+BackSpace: Delete word to the left of the cursor.
- Control+Delete : Delete word to the right of the cursor.

Originally introduced by BRIEF and Turbo Vision between 1985 and 1992, they were adopted by most CUA-Compliant UIs, including those of: OS/2, Windows, Mac OS, Qt, GTK, Open/Libre Office, Gecko, and GNU Emacs.

In both cases Tk already implements the functionality bound to other key combination, so we use that.

Graphical examples:

Deleting to the left:

        v------ pointer

X_WORD____X
^-----^------ selection

Deleting to the right:
v--------- pointer
X_WORD_X
^--^------ selection

---
I'm re-submitting the patch after >1 year.

CC Junio C Hamano <[email protected]>
CC "brian m. carlson" <[email protected]>
CC Pat Thoyts <[email protected]>
CC Johannes Schindelin <[email protected]>

Notes:
Changes since v2:
- Reimplemented via existing events, which correctly delete spaces.
- Further improved commit message.

Changes since v1:
- Improved commit message.

 git-gui/git-gui.sh | 2 ++
 1 file changed, 2 insertions(+)
git-gui/git-gui.sh +0 -0
index 6de74ce639..c4e0270626 100755

You based the patch on top of the Git tree. Since Git Gui is maintained separate from Git, patches are expected to be based on top of the Git Gui tree [0]. I fixed it up and applied the patch on my tree.

git-gui/git-gui.sh bind $ui_comm <$M1B-Key-KP_Subtract> {show_less_context;break} · line 3816

Quoted 6 lines
git-gui/git-gui.sh +2 -0
@@ -3812,6 +3812,8 @@ bind $ui_comm <$M1B-Key-KP_Subtract> {show_less_context;break}
 bind $ui_comm <$M1B-Key-equal> {show_more_context;break}
 bind $ui_comm <$M1B-Key-plus> {show_more_context;break}
 bind $ui_comm <$M1B-Key-KP_Add> {show_more_context;break}
+bind $ui_comm <Control-Key-BackSpace> {event generate %W <Meta-Delete>;break}
+bind $ui_comm <Control-Key-Delete> {event generate %W <Meta-d>;break}

Don't use "Control" directly to maintain compatibility with MacOS. Use $M1B like the surrounding code does. I fixed it up locally, so no need to send in a new version. You can find the fixed up version here [1]. Test it if you'd like.

Quoted 1 line

Will merge it in. Thanks.

Thanks.

#3 lore raw
In reply to Ismael Luceno
Quoted 19 lines · Ismael Luceno

From: Ismael Luceno <[email protected]>

- Control+BackSpace: Delete word to the left of the cursor.
- Control+Delete : Delete word to the right of the cursor.

Originally introduced by BRIEF and Turbo Vision between 1985 and 1992, they were adopted by most CUA-Compliant UIs, including those of: OS/2, Windows, Mac OS, Qt, GTK, Open/Libre Office, Gecko, and GNU Emacs.

In both cases Tk already implements the functionality bound to other key combination, so we use that.

Graphical examples:

Deleting to the left:

        v------ pointer

X_WORD____X
^-----^------ selection

Quoted 6 lines

Deleting to the right:
v--------- pointer
X_WORD_X
^--^------ selection

Merged to git-gui/master.

Signature · 2 lines
Regards,
Pratyush Yadav