@@ -2511,20 +2511,36 @@ proc force_first_diff {after} {
2511
2511
}
2512
2512
}
2513
2513
2514
- proc toggle_or_diff {w x y } {
2514
+ proc toggle_or_diff {mode w args } {
2515
2515
global file_states file_lists current_diff_path ui_index ui_workdir
2516
2516
global last_clicked selected_paths
2517
2517
2518
- set pos [ split [$w index @$x ,$y ] .]
2519
- set lno [ lindex $pos 0]
2520
- set col [ lindex $pos 1]
2518
+ if {$mode eq " click" } {
2519
+ foreach {x y} $args break
2520
+ set pos [ split [$w index @$x ,$y ] .]
2521
+ foreach {lno col} $pos break
2522
+ } else {
2523
+ if {$last_clicked ne {}} {
2524
+ set lno [ lindex $last_clicked 1]
2525
+ } else {
2526
+ set lno [ expr {int([lindex [$w tag ranges in_diff] 0])}]
2527
+ }
2528
+ if {$mode eq " toggle" } {
2529
+ set col 0; set y 2
2530
+ } else {
2531
+ incr lno [ expr {$mode eq " up" ? -1 : 1}]
2532
+ set col 1
2533
+ }
2534
+ }
2535
+
2521
2536
set path [ lindex $file_lists($w) [expr {$lno - 1}] ]
2522
2537
if {$path eq {}} {
2523
2538
set last_clicked {}
2524
2539
return
2525
2540
}
2526
2541
2527
2542
set last_clicked [ list $w $lno ]
2543
+ focus $w
2528
2544
array unset selected_paths
2529
2545
$ui_index tag remove in_sel 0.0 end
2530
2546
$ui_workdir tag remove in_sel 0.0 end
@@ -2604,7 +2620,7 @@ proc add_range_to_selection {w x y} {
2604
2620
global file_lists last_clicked selected_paths
2605
2621
2606
2622
if {[ lindex $last_clicked 0] ne $w } {
2607
- toggle_or_diff $w $x $y
2623
+ toggle_or_diff click $w $x $y
2608
2624
return
2609
2625
}
2610
2626
@@ -3184,16 +3200,38 @@ if {$use_ttk} {
3184
3200
}
3185
3201
pack .vpane -anchor n -side top -fill both -expand 1
3186
3202
3203
+ # -- Working Directory File List
3204
+
3205
+ textframe .vpane.files.workdir -height 100 -width 200
3206
+ tlabel .vpane.files.workdir.title -text [ mc " Unstaged Changes" ] \
3207
+ -background lightsalmon -foreground black
3208
+ ttext $ui_workdir -background white -foreground black \
3209
+ -borderwidth 0 \
3210
+ -width 20 -height 10 \
3211
+ -wrap none \
3212
+ -takefocus 1 -highlightthickness 1\
3213
+ -cursor $cursor_ptr \
3214
+ -xscrollcommand {.vpane.files.workdir.sx set} \
3215
+ -yscrollcommand {.vpane.files.workdir.sy set} \
3216
+ -state disabled
3217
+ ${NS} ::scrollbar .vpane.files.workdir.sx -orient h -command [ list $ui_workdir xview]
3218
+ ${NS} ::scrollbar .vpane.files.workdir.sy -orient v -command [ list $ui_workdir yview]
3219
+ pack .vpane.files.workdir.title -side top -fill x
3220
+ pack .vpane.files.workdir.sx -side bottom -fill x
3221
+ pack .vpane.files.workdir.sy -side right -fill y
3222
+ pack $ui_workdir -side left -fill both -expand 1
3223
+
3187
3224
# -- Index File List
3188
3225
#
3189
- ${NS} ::frame .vpane.files.index -height 100 -width 200
3226
+ textframe .vpane.files.index -height 100 -width 200
3190
3227
tlabel .vpane.files.index.title \
3191
3228
-text [ mc " Staged Changes (Will Commit)" ] \
3192
3229
-background lightgreen -foreground black
3193
- text $ui_index -background white -foreground black \
3230
+ ttext $ui_index -background white -foreground black \
3194
3231
-borderwidth 0 \
3195
3232
-width 20 -height 10 \
3196
3233
-wrap none \
3234
+ -takefocus 1 -highlightthickness 1\
3197
3235
-cursor $cursor_ptr \
3198
3236
-xscrollcommand {.vpane.files.index.sx set} \
3199
3237
-yscrollcommand {.vpane.files.index.sy set} \
@@ -3205,26 +3243,8 @@ pack .vpane.files.index.sx -side bottom -fill x
3205
3243
pack .vpane.files.index.sy -side right -fill y
3206
3244
pack $ui_index -side left -fill both -expand 1
3207
3245
3208
- # -- Working Directory File List
3246
+ # -- Insert the workdir and index into the panes
3209
3247
#
3210
- ${NS} ::frame .vpane.files.workdir -height 100 -width 200
3211
- tlabel .vpane.files.workdir.title -text [ mc " Unstaged Changes" ] \
3212
- -background lightsalmon -foreground black
3213
- text $ui_workdir -background white -foreground black \
3214
- -borderwidth 0 \
3215
- -width 20 -height 10 \
3216
- -wrap none \
3217
- -cursor $cursor_ptr \
3218
- -xscrollcommand {.vpane.files.workdir.sx set} \
3219
- -yscrollcommand {.vpane.files.workdir.sy set} \
3220
- -state disabled
3221
- ${NS} ::scrollbar .vpane.files.workdir.sx -orient h -command [ list $ui_workdir xview]
3222
- ${NS} ::scrollbar .vpane.files.workdir.sy -orient v -command [ list $ui_workdir yview]
3223
- pack .vpane.files.workdir.title -side top -fill x
3224
- pack .vpane.files.workdir.sx -side bottom -fill x
3225
- pack .vpane.files.workdir.sy -side right -fill y
3226
- pack $ui_workdir -side left -fill both -expand 1
3227
-
3228
3248
.vpane.files add .vpane.files.workdir
3229
3249
.vpane.files add .vpane.files.index
3230
3250
if {!$use_ttk } {
@@ -3307,7 +3327,7 @@ if {![is_enabled nocommit]} {
3307
3327
#
3308
3328
${NS} ::frame .vpane.lower.commarea.buffer
3309
3329
${NS} ::frame .vpane.lower.commarea.buffer.header
3310
- set ui_comm .vpane.lower.commarea.buffer.t
3330
+ set ui_comm .vpane.lower.commarea.buffer.frame. t
3311
3331
set ui_coml .vpane.lower.commarea.buffer.header.l
3312
3332
3313
3333
if {![ is_enabled nocommit] } {
@@ -3350,20 +3370,25 @@ if {![is_enabled nocommit]} {
3350
3370
pack .vpane.lower.commarea.buffer.header.new -side right
3351
3371
}
3352
3372
3353
- text $ui_comm -background white -foreground black \
3373
+ textframe .vpane.lower.commarea.buffer.frame
3374
+ ttext $ui_comm -background white -foreground black \
3354
3375
-borderwidth 1 \
3355
3376
-undo true \
3356
3377
-maxundo 20 \
3357
3378
-autoseparators true \
3379
+ -takefocus 1 \
3380
+ -highlightthickness 1 \
3358
3381
-relief sunken \
3359
3382
-width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \
3360
3383
-font font_diff \
3361
- -yscrollcommand {.vpane.lower.commarea.buffer.sby set}
3362
- ${NS} ::scrollbar .vpane.lower.commarea.buffer.sby \
3384
+ -yscrollcommand {.vpane.lower.commarea.buffer.frame. sby set}
3385
+ ${NS} ::scrollbar .vpane.lower.commarea.buffer.frame. sby \
3363
3386
-command [ list $ui_comm yview]
3364
- pack .vpane.lower.commarea.buffer.header -side top -fill x
3365
- pack .vpane.lower.commarea.buffer.sby -side right -fill y
3387
+
3388
+ pack .vpane.lower.commarea.buffer.frame. sby -side right -fill y
3366
3389
pack $ui_comm -side left -fill y
3390
+ pack .vpane.lower.commarea.buffer.header -side top -fill x
3391
+ pack .vpane.lower.commarea.buffer.frame -side left -fill y
3367
3392
pack .vpane.lower.commarea.buffer -side left -fill y
3368
3393
3369
3394
# -- Commit Message Buffer Context Menu
@@ -3461,12 +3486,13 @@ bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
3461
3486
3462
3487
# -- Diff Body
3463
3488
#
3464
- ${NS} ::frame .vpane.lower.diff.body
3489
+ textframe .vpane.lower.diff.body
3465
3490
set ui_diff .vpane.lower.diff.body.t
3466
- text $ui_diff -background white -foreground black \
3491
+ ttext $ui_diff -background white -foreground black \
3467
3492
-borderwidth 0 \
3468
3493
-width 80 -height 5 -wrap none \
3469
3494
-font font_diff \
3495
+ -takefocus 1 -highlightthickness 1 \
3470
3496
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
3471
3497
-yscrollcommand {.vpane.lower.diff.body.sby set} \
3472
3498
-state disabled
@@ -3821,10 +3847,10 @@ bind . <$M1B-Key-r> ui_do_rescan
3821
3847
bind . <$M1B -Key-R> ui_do_rescan
3822
3848
bind . <$M1B -Key-s> do_signoff
3823
3849
bind . <$M1B -Key-S> do_signoff
3824
- bind . <$M1B -Key-t> do_add_selection
3825
- bind . <$M1B -Key-T> do_add_selection
3826
- bind . <$M1B -Key-u> do_unstage_selection
3827
- bind . <$M1B -Key-U> do_unstage_selection
3850
+ bind . <$M1B -Key-t> { toggle_or_diff toggle %W }
3851
+ bind . <$M1B -Key-T> { toggle_or_diff toggle %W }
3852
+ bind . <$M1B -Key-u> { toggle_or_diff toggle %W }
3853
+ bind . <$M1B -Key-U> { toggle_or_diff toggle %W }
3828
3854
bind . <$M1B -Key-j> do_revert_selection
3829
3855
bind . <$M1B -Key-J> do_revert_selection
3830
3856
bind . <$M1B -Key-i> do_add_all
@@ -3836,9 +3862,11 @@ bind . <$M1B-Key-plus> {show_more_context;break}
3836
3862
bind . <$M1B -Key-KP_Add> {show_more_context;break}
3837
3863
bind . <$M1B -Key-Return> do_commit
3838
3864
foreach i [ list $ui_index $ui_workdir ] {
3839
- bind $i <Button-1> " toggle_or_diff $i %x %y; break "
3840
- bind $i <$M1B -Button-1> " add_one_to_selection $i %x %y; break "
3841
- bind $i <Shift-Button-1> " add_range_to_selection $i %x %y; break "
3865
+ bind $i <Button-1> { toggle_or_diff click %W %x %y; break }
3866
+ bind $i <$M1B -Button-1> { add_one_to_selection %W %x %y; break }
3867
+ bind $i <Shift-Button-1> { add_range_to_selection %W %x %y; break }
3868
+ bind $i <Key-Up> { toggle_or_diff up %W; break }
3869
+ bind $i <Key-Down> { toggle_or_diff down %W; break }
3842
3870
}
3843
3871
unset i
3844
3872
0 commit comments