threads / patch / 50522

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

Subject: [PATCH v2] git-gui: Handle Ctrl + BS/Del in the commit msg

## tl;dr

5 messages between Feb 16, 2019 and Mar 4, 2019. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Ismael Luceno· Feb 16, 2019, 03:10 UTC · lore
- 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.

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
---
Notes:
    Changes since v1:
    - Improved commit message.
 git-gui.sh | 2 ++
 1 file changed, 2 insertions(+)
Show changes to git-gui.sh +2 −0
diff --git a/git-gui.sh b/git-gui.sh
index 5bc21b878d41..e00d9a345294 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -3788,6 +3788,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> {%W delete {insert -1 chars wordstart} insert;break}
+bind $ui_comm <Control-Key-Delete> {%W delete insert {insert wordend};break}
 
 bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
 bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
-- 
2.20.1
Junio C Hamano· Feb 20, 2019, 20:05 UTC · re: Ismael Luceno · lore

Re: [PATCH v2] git-gui: Handle Ctrl + BS/Del in the commit msg

Ismael Luceno <ismael@iodev.co.uk> writes:
Show 13 quoted lines
> - 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.
>
> Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> ---
>
> Notes:
>     Changes since v1:
>     - Improved commit message.

I do not use git-gui, but as a bystander, the intent of the change sounds sane. deleting from the insertion cursor to the end of the word where the insertion cursor is looks like the right way to delete the word to the right of the cursor. I am not sure if going back by one character from where the current insertion cursor is and further go back to the wordstart would give the beginning of the word to the left of the cursor, though.

A larger issue is that we haven't heard from Pat, who has been helping git-gui.sh maintenance, for quite a while, so we'd need to find a volunteer to act as a replacement maintainer. If you are willing to, that would be great ;-)

Thanks.
Show 16 quoted lines
>  git-gui.sh | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/git-gui.sh b/git-gui.sh
> index 5bc21b878d41..e00d9a345294 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -3788,6 +3788,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> {%W delete {insert -1 chars wordstart} insert;break}
> +bind $ui_comm <Control-Key-Delete> {%W delete insert {insert wordend};break}
>  
>  bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
>  bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
Ismael Luceno· Feb 21, 2019, 09:31 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] git-gui: Handle Ctrl + BS/Del in the commit msg

On 20/Feb/2019 12:05, Junio C Hamano wrote:
Show 23 quoted lines
> Ismael Luceno <ismael@iodev.co.uk> writes:
> 
> > - 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.
> >
> > Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> > ---
> >
> > Notes:
> >     Changes since v1:
> >     - Improved commit message.
> 
> I do not use git-gui, but as a bystander, the intent of the change
> sounds sane.  deleting from the insertion cursor to the end of the
> word where the insertion cursor is looks like the right way to
> delete the word to the right of the cursor.  I am not sure if going
> back by one character from where the current insertion cursor is and
> further go back to the wordstart would give the beginning of the
> word to the left of the cursor, though.
Graphical explanation:
Deleting to the left:
      v----- pointer
X_WORD_X
  ^--^------ selection
Deleting to the right:
  v--------- pointer
X_WORD_X
  ^--^------ selection

Current implementation doesn't behave correctly when there's multiple spaces:

Deleting to the left:
        v--- pointer
X_WORD____X
       ^---- selection
Deleting to the right:
  v--------- pointer
X____WORD_X
  ^--------- selection
> A larger issue is that we haven't heard from Pat, who has been
> helping git-gui.sh maintenance, for quite a while, so we'd need to
> find a volunteer to act as a replacement maintainer.  If you are
> willing to, that would be great ;-)
Sure.
Junio C Hamano· Feb 21, 2019, 20:47 UTC · re: Ismael Luceno · lore

Re: [PATCH v2] git-gui: Handle Ctrl + BS/Del in the commit msg

Ismael Luceno <ismael@iodev.co.uk> writes:
Show 8 quoted lines
>> ....  I am not sure if going
>> back by one character from where the current insertion cursor is and
>> further go back to the wordstart would give the beginning of the
>> word to the left of the cursor, though.
>
> ...
> Current implementation doesn't behave correctly when there's multiple
> spaces:
In short, I wondered if it is correct, and you say it is not correct.

I would be surprised if git-gui were the only program that implemented an editor-like feature using tcl/tk, and none of the other editor implementations using tcl/tk had such an industry standard "delete previous word". Perhaps you can see if there is already a correct implementation of the feature this patch can borrow from?

Show 6 quoted lines
>> A larger issue is that we haven't heard from Pat, who has been
>> helping git-gui.sh maintenance, for quite a while, so we'd need to
>> find a volunteer to act as a replacement maintainer.  If you are
>> willing to, that would be great ;-)
>
> Sure.
Ismael Luceno· Mar 4, 2019, 14:09 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] git-gui: Handle Ctrl + BS/Del in the commit msg

On 21/Feb/2019 12:47, Junio C Hamano wrote:
Show 12 quoted lines
> Ismael Luceno <ismael@iodev.co.uk> writes:
> 
> >> ....  I am not sure if going
> >> back by one character from where the current insertion cursor is and
> >> further go back to the wordstart would give the beginning of the
> >> word to the left of the cursor, though.
> >
> > ...
> > Current implementation doesn't behave correctly when there's multiple
> > spaces:
> 
> In short, I wondered if it is correct, and you say it is not correct.
It's better than nothing, and the behavior isn't harmful.
Show 6 quoted lines
> I would be surprised if git-gui were the only program that
> implemented an editor-like feature using tcl/tk, and none of the
> other editor implementations using tcl/tk had such an industry
> standard "delete previous word".  Perhaps you can see if there
> is already a correct implementation of the feature this patch can
> borrow from?

I couldn't find such implementation yet. I'll come up with an improved version if there's nothing else, but in the meanwhile it's worth to have this one merged.

← back to recent threads