@@ -2505,20 +2505,36 @@ proc force_first_diff {after} {
2505
2505
}
2506
2506
}
2507
2507
2508
- proc toggle_or_diff {w x y } {
2508
+ proc toggle_or_diff {mode w args } {
2509
2509
global file_states file_lists current_diff_path ui_index ui_workdir
2510
2510
global last_clicked selected_paths
2511
2511
2512
- set pos [ split [$w index @$x ,$y ] .]
2513
- set lno [ lindex $pos 0]
2514
- set col [ lindex $pos 1]
2512
+ if {$mode eq " click" } {
2513
+ foreach {x y} $args break
2514
+ set pos [ split [$w index @$x ,$y ] .]
2515
+ foreach {lno col} $pos break
2516
+ } else {
2517
+ if {$last_clicked ne {}} {
2518
+ set lno [ lindex $last_clicked 1]
2519
+ } else {
2520
+ set lno [ expr {int([lindex [$w tag ranges in_diff] 0])}]
2521
+ }
2522
+ if {$mode eq " toggle" } {
2523
+ set col 0; set y 2
2524
+ } else {
2525
+ incr lno [ expr {$mode eq " up" ? -1 : 1}]
2526
+ set col 1
2527
+ }
2528
+ }
2529
+
2515
2530
set path [ lindex $file_lists($w) [expr {$lno - 1}] ]
2516
2531
if {$path eq {}} {
2517
2532
set last_clicked {}
2518
2533
return
2519
2534
}
2520
2535
2521
2536
set last_clicked [ list $w $lno ]
2537
+ focus $w
2522
2538
array unset selected_paths
2523
2539
$ui_index tag remove in_sel 0.0 end
2524
2540
$ui_workdir tag remove in_sel 0.0 end
@@ -2598,7 +2614,7 @@ proc add_range_to_selection {w x y} {
2598
2614
global file_lists last_clicked selected_paths
2599
2615
2600
2616
if {[ lindex $last_clicked 0] ne $w } {
2601
- toggle_or_diff $w $x $y
2617
+ toggle_or_diff click $w $x $y
2602
2618
return
2603
2619
}
2604
2620
@@ -3188,6 +3204,7 @@ text $ui_index -background white -foreground black \
3188
3204
-borderwidth 0 \
3189
3205
-width 20 -height 10 \
3190
3206
-wrap none \
3207
+ -takefocus 1 -highlightthickness 1\
3191
3208
-cursor $cursor_ptr \
3192
3209
-xscrollcommand {.vpane.files.index.sx set} \
3193
3210
-yscrollcommand {.vpane.files.index.sy set} \
@@ -3208,6 +3225,7 @@ text $ui_workdir -background white -foreground black \
3208
3225
-borderwidth 0 \
3209
3226
-width 20 -height 10 \
3210
3227
-wrap none \
3228
+ -takefocus 1 -highlightthickness 1\
3211
3229
-cursor $cursor_ptr \
3212
3230
-xscrollcommand {.vpane.files.workdir.sx set} \
3213
3231
-yscrollcommand {.vpane.files.workdir.sy set} \
@@ -3815,10 +3833,10 @@ bind . <$M1B-Key-r> ui_do_rescan
3815
3833
bind . <$M1B -Key-R> ui_do_rescan
3816
3834
bind . <$M1B -Key-s> do_signoff
3817
3835
bind . <$M1B -Key-S> do_signoff
3818
- bind . <$M1B -Key-t> do_add_selection
3819
- bind . <$M1B -Key-T> do_add_selection
3820
- bind . <$M1B -Key-u> do_unstage_selection
3821
- bind . <$M1B -Key-U> do_unstage_selection
3836
+ bind . <$M1B -Key-t> { toggle_or_diff toggle %W }
3837
+ bind . <$M1B -Key-T> { toggle_or_diff toggle %W }
3838
+ bind . <$M1B -Key-u> { toggle_or_diff toggle %W }
3839
+ bind . <$M1B -Key-U> { toggle_or_diff toggle %W }
3822
3840
bind . <$M1B -Key-j> do_revert_selection
3823
3841
bind . <$M1B -Key-J> do_revert_selection
3824
3842
bind . <$M1B -Key-i> do_add_all
@@ -3830,9 +3848,11 @@ bind . <$M1B-Key-plus> {show_more_context;break}
3830
3848
bind . <$M1B -Key-KP_Add> {show_more_context;break}
3831
3849
bind . <$M1B -Key-Return> do_commit
3832
3850
foreach i [ list $ui_index $ui_workdir ] {
3833
- bind $i <Button-1> " toggle_or_diff $i %x %y; break "
3834
- bind $i <$M1B -Button-1> " add_one_to_selection $i %x %y; break "
3835
- bind $i <Shift-Button-1> " add_range_to_selection $i %x %y; break "
3851
+ bind $i <Button-1> { toggle_or_diff click %W %x %y; break }
3852
+ bind $i <$M1B -Button-1> { add_one_to_selection %W %x %y; break }
3853
+ bind $i <Shift-Button-1> { add_range_to_selection %W %x %y; break }
3854
+ bind $i <Key-Up> { toggle_or_diff up %W; break }
3855
+ bind $i <Key-Down> { toggle_or_diff down %W; break }
3836
3856
}
3837
3857
unset i
3838
3858
0 commit comments