Re: [PATCH] git-gui: Add hotkeys to change focus between ui widgets

2018-03-06 Thread Junio C Hamano
Birger Skogeng Pedersen  writes:

> Thanks for the feedback.
>
> On Mon, Mar 5, 2018 at 5:55 PM, Johannes Schindelin
>  wrote:
>> Do you think there is a way to focus on the last-selected path? That would
>> make this feature even more convenient, I think.
>
> Yes, good idea. I'll implement it and create a second version.

Please make it a patch against the main git-gui project, not against
our tree.  That is, your patch text would look like this:

diff --git a/git-gui.sh b/git-gui.sh
index 5bc21b878d..39e80ebafa 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -3843,6 +3843,7 @@ bind .   <$M1B-Key-equal> {show_more_context;break}
 bind .   <$M1B-Key-plus> {show_more_context;break}
 bind .   <$M1B-Key-KP_Add> {show_more_context;break}
 bind .   <$M1B-Key-Return> do_commit
+bind .   <$M1B-Key-KP_Enter> do_commit
 foreach i [list $ui_index $ui_workdir] {
bind $i{ toggle_or_diff click %W %x %y; break }
bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }

We've seen three patches to git-gui from three different people in
the past week.  The project seems to be abandoned and we need to
find a volunteer (or a few) to take it over, it seems.  In the
meantime I have blindly been picking and queuing git-gui changes
but because I am not even a casual user of it, I know I will not do
a good job maintaining it in the longer term.


Re: [PATCH] git-gui: Add hotkeys to change focus between ui widgets

2018-03-06 Thread Birger Skogeng Pedersen
Thanks for the feedback.

On Mon, Mar 5, 2018 at 5:55 PM, Johannes Schindelin
 wrote:
> Do you think there is a way to focus on the last-selected path? That would
> make this feature even more convenient, I think.

Yes, good idea. I'll implement it and create a second version.

> I am not sure that this information is still there if switching back from
> another component...

I don't think so. But I can add a variable to hold the last selected
(clicked) path for both widgets.

Thanks (again),
Birger

On Mon, Mar 5, 2018 at 5:55 PM, Johannes Schindelin
 wrote:
> Hi Birger,
>
> On Wed, 28 Feb 2018, Birger Skogeng Pedersen wrote:
>
>> The user cannot change focus between the list of files, the diff view
>> and the commit message widgets without using the mouse (clicking either of
>> the four widgets ).
>>
>> Hotkeys CTRL/CMD+number (1-4) now focuses the first file of either the
>> "Unstaged Changes" or "Staged Changes", the diff view or the
>> commit message dialog widgets, respectively. This enables the user to
>> select/unselect files, view the diff and create a commit in git-gui
>> using keyboard-only.
>
> I like this!
>
>> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
>> index 91c00e648..f96c0a6b8 100755
>>
>> (This is my first patch ever, any feedback is highly appreciated)
>
> I am not an expert in Tcl/Tk, but I'll do my best to comment on this
> patch.
>
>> --- a/git-gui/git-gui.sh
>> +++ b/git-gui/git-gui.sh
>> @@ -2664,6 +2664,38 @@ proc show_less_context {} {
>>   }
>>  }
>>
>> +proc select_first_path {w} {
>> + global file_lists last_clicked selected_paths
>> + if {[llength $file_lists($w)] > 0} {
>> + focus $w
>> + set last_clicked [list $w 1]
>> + set path [lindex $file_lists($w) 0]
>> + array unset selected_paths
>> + set selected_paths($path) 1
>> + show_diff $path $w
>> + }
>> +}
>
> Do you think there is a way to focus on the last-selected path? That would
> make this feature even more convenient, I think.
>
> I am not sure that this information is still there if switching back from
> another component...
>
>> +proc select_first_unstaged_changes_path {} {
>> + global ui_workdir
>> + select_first_path $ui_workdir
>> +}
>> +
>> +proc select_first_staged_changes_path {} {
>> + global ui_index
>> + select_first_path $ui_index
>> +}
>> +
>> +proc focus_diff {} {
>> + global ui_diff
>> + focus $ui_diff
>> +}
>> +
>> +proc focus_commit_message {} {
>> + global ui_comm
>> + focus $ui_comm
>> +}
>> +
>>  ##
>>  ##
>>  ## ui construction
>> @@ -3876,6 +3908,11 @@ foreach i [list $ui_index $ui_workdir] {
>>  }
>>  unset i
>>
>> +bind . <$M1B-Key-1> {select_first_unstaged_changes_path}
>> +bind . <$M1B-Key-2> {select_first_staged_changes_path}
>> +bind . <$M1B-Key-3> {focus_diff}
>> +bind . <$M1B-Key-4> {focus_commit_message}
>> +
>>  set file_lists($ui_index) [list]
>>  set file_lists($ui_workdir) [list]
>
> Looks good!
>
> We are currently without an active Git GUI maintainer, so I hope that
> Junio (the Git maintainer) will pick this up.
>
> Ciao,
> Johannes


Re: [PATCH] git-gui: Add hotkeys to change focus between ui widgets

2018-03-05 Thread Johannes Schindelin
Hi Birger,

On Wed, 28 Feb 2018, Birger Skogeng Pedersen wrote:

> The user cannot change focus between the list of files, the diff view
> and the commit message widgets without using the mouse (clicking either of
> the four widgets ).
> 
> Hotkeys CTRL/CMD+number (1-4) now focuses the first file of either the
> "Unstaged Changes" or "Staged Changes", the diff view or the
> commit message dialog widgets, respectively. This enables the user to
> select/unselect files, view the diff and create a commit in git-gui
> using keyboard-only.

I like this!

> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
> index 91c00e648..f96c0a6b8 100755
> 
> (This is my first patch ever, any feedback is highly appreciated)

I am not an expert in Tcl/Tk, but I'll do my best to comment on this
patch.

> --- a/git-gui/git-gui.sh
> +++ b/git-gui/git-gui.sh
> @@ -2664,6 +2664,38 @@ proc show_less_context {} {
>   }
>  }
>  
> +proc select_first_path {w} {
> + global file_lists last_clicked selected_paths
> + if {[llength $file_lists($w)] > 0} {
> + focus $w
> + set last_clicked [list $w 1]
> + set path [lindex $file_lists($w) 0]
> + array unset selected_paths
> + set selected_paths($path) 1
> + show_diff $path $w
> + }
> +}

Do you think there is a way to focus on the last-selected path? That would
make this feature even more convenient, I think.

I am not sure that this information is still there if switching back from
another component...

> +proc select_first_unstaged_changes_path {} {
> + global ui_workdir
> + select_first_path $ui_workdir
> +}
> +
> +proc select_first_staged_changes_path {} {
> + global ui_index
> + select_first_path $ui_index
> +}
> +
> +proc focus_diff {} {
> + global ui_diff
> + focus $ui_diff
> +}
> +
> +proc focus_commit_message {} {
> + global ui_comm
> + focus $ui_comm
> +}
> +
>  ##
>  ##
>  ## ui construction
> @@ -3876,6 +3908,11 @@ foreach i [list $ui_index $ui_workdir] {
>  }
>  unset i
>  
> +bind . <$M1B-Key-1> {select_first_unstaged_changes_path}
> +bind . <$M1B-Key-2> {select_first_staged_changes_path}
> +bind . <$M1B-Key-3> {focus_diff}
> +bind . <$M1B-Key-4> {focus_commit_message}
> +
>  set file_lists($ui_index) [list]
>  set file_lists($ui_workdir) [list]

Looks good!

We are currently without an active Git GUI maintainer, so I hope that
Junio (the Git maintainer) will pick this up.

Ciao,
Johannes


Re: [PATCH] git-gui: Add hotkeys to change focus between ui widgets

2018-02-23 Thread Birger Skogeng Pedersen
Hi,

I've discovered a bug, I'll be sending a new version soon.

br
Birger

On Fri, Feb 23, 2018 at 11:22 AM, Birger Skogeng Pedersen
 wrote:
> The user cannot change focus between the list of files, the diff view
> and the commit message widgets without using the mouse (clicking either of
> the four widgets ).
>
> Hotkeys CTRL/CMD+number (1-4) now focuses the first file of either the
> "Unstaged Changes" or "Staged Changes", the diff view or the
> commit message dialog widgets, respectively. This enables the user to
> select/unselect files, view the diff and create a commit in git-gui
> using keyboard-only.
>
> Signed-off-by: Birger Skogeng Pedersen 
> ---
>  git-gui/git-gui.sh | 34 ++
>  1 file changed, 34 insertions(+)
>
> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
> index 91c00e648..bdbe166f7 100755
>
> (First timere here, any feedback is highly appreciated)
>
> --- a/git-gui/git-gui.sh
> +++ b/git-gui/git-gui.sh
> @@ -2664,6 +2664,35 @@ proc show_less_context {} {
> }
>  }
>
> +proc select_first_path {w} {
> +   global file_lists last_clicked selected_paths
> +   if {[llength $file_lists($w)] > 0} {
> +   focus $w
> +   set last_clicked [list $w 1]
> +   show_diff [lindex $file_lists($w) 0] $w
> +   }
> +}
> +
> +proc select_first_unstaged_changes_path {} {
> +   global ui_workdir
> +   select_first_path $ui_workdir
> +}
> +
> +proc select_first_staged_changes_path {} {
> +   global ui_index
> +   select_first_path $ui_index
> +}
> +
> +proc focus_diff {} {
> +   global ui_diff
> +   focus $ui_diff
> +}
> +
> +proc focus_commit_message {} {
> +   global ui_comm
> +   focus $ui_comm
> +}
> +
>  ##
>  ##
>  ## ui construction
> @@ -3876,6 +3905,11 @@ foreach i [list $ui_index $ui_workdir] {
>  }
>  unset i
>
> +bind . <$M1B-Key-1> {select_first_unstaged_changes_path}
> +bind . <$M1B-Key-2> {select_first_staged_changes_path}
> +bind . <$M1B-Key-3> {focus_diff}
> +bind . <$M1B-Key-4> {focus_commit_message}
> +
>  set file_lists($ui_index) [list]
>  set file_lists($ui_workdir) [list]
>
> --
> 2.16.2.266.g75bb9601e
>