@@ -2511,20 +2511,36 @@ proc force_first_diff {after} {
25112511 }
25122512}
25132513
2514- proc toggle_or_diff {w x y } {
2514+ proc toggle_or_diff {mode w args } {
25152515 global file_states file_lists current_diff_path ui_index ui_workdir
25162516 global last_clicked selected_paths
25172517
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+
25212536 set path [ lindex $file_lists($w) [expr {$lno - 1}] ]
25222537 if {$path eq {}} {
25232538 set last_clicked {}
25242539 return
25252540 }
25262541
25272542 set last_clicked [ list $w $lno ]
2543+ focus $w
25282544 array unset selected_paths
25292545 $ui_index tag remove in_sel 0.0 end
25302546 $ui_workdir tag remove in_sel 0.0 end
@@ -2604,7 +2620,7 @@ proc add_range_to_selection {w x y} {
26042620 global file_lists last_clicked selected_paths
26052621
26062622 if {[ lindex $last_clicked 0] ne $w } {
2607- toggle_or_diff $w $x $y
2623+ toggle_or_diff click $w $x $y
26082624 return
26092625 }
26102626
@@ -3184,16 +3200,38 @@ if {$use_ttk} {
31843200}
31853201pack .vpane -anchor n -side top -fill both -expand 1
31863202
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+
31873224# -- Index File List
31883225#
3189- ${NS} ::frame .vpane.files.index -height 100 -width 200
3226+ textframe .vpane.files.index -height 100 -width 200
31903227tlabel .vpane.files.index.title \
31913228 -text [ mc " Staged Changes (Will Commit)" ] \
31923229 -background lightgreen -foreground black
3193- text $ui_index -background white -foreground black \
3230+ ttext $ui_index -background white -foreground black \
31943231 -borderwidth 0 \
31953232 -width 20 -height 10 \
31963233 -wrap none \
3234+ -takefocus 1 -highlightthickness 1\
31973235 -cursor $cursor_ptr \
31983236 -xscrollcommand {.vpane.files.index.sx set} \
31993237 -yscrollcommand {.vpane.files.index.sy set} \
@@ -3205,26 +3243,8 @@ pack .vpane.files.index.sx -side bottom -fill x
32053243pack .vpane.files.index.sy -side right -fill y
32063244pack $ui_index -side left -fill both -expand 1
32073245
3208- # -- Working Directory File List
3246+ # -- Insert the workdir and index into the panes
32093247#
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-
32283248.vpane.files add .vpane.files.workdir
32293249.vpane.files add .vpane.files.index
32303250if {!$use_ttk } {
@@ -3307,7 +3327,7 @@ if {![is_enabled nocommit]} {
33073327#
33083328${NS} ::frame .vpane.lower.commarea.buffer
33093329${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
33113331set ui_coml .vpane.lower.commarea.buffer.header.l
33123332
33133333if {![ is_enabled nocommit] } {
@@ -3350,20 +3370,25 @@ if {![is_enabled nocommit]} {
33503370 pack .vpane.lower.commarea.buffer.header.new -side right
33513371}
33523372
3353- text $ui_comm -background white -foreground black \
3373+ textframe .vpane.lower.commarea.buffer.frame
3374+ ttext $ui_comm -background white -foreground black \
33543375 -borderwidth 1 \
33553376 -undo true \
33563377 -maxundo 20 \
33573378 -autoseparators true \
3379+ -takefocus 1 \
3380+ -highlightthickness 1 \
33583381 -relief sunken \
33593382 -width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \
33603383 -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 \
33633386 -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
33663389pack $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
33673392pack .vpane.lower.commarea.buffer -side left -fill y
33683393
33693394# -- Commit Message Buffer Context Menu
@@ -3461,12 +3486,13 @@ bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
34613486
34623487# -- Diff Body
34633488#
3464- ${NS} ::frame .vpane.lower.diff.body
3489+ textframe .vpane.lower.diff.body
34653490set ui_diff .vpane.lower.diff.body.t
3466- text $ui_diff -background white -foreground black \
3491+ ttext $ui_diff -background white -foreground black \
34673492 -borderwidth 0 \
34683493 -width 80 -height 5 -wrap none \
34693494 -font font_diff \
3495+ -takefocus 1 -highlightthickness 1 \
34703496 -xscrollcommand {.vpane.lower.diff.body.sbx set} \
34713497 -yscrollcommand {.vpane.lower.diff.body.sby set} \
34723498 -state disabled
@@ -3821,10 +3847,10 @@ bind . <$M1B-Key-r> ui_do_rescan
38213847bind . <$M1B -Key-R> ui_do_rescan
38223848bind . <$M1B -Key-s> do_signoff
38233849bind . <$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 }
38283854bind . <$M1B -Key-j> do_revert_selection
38293855bind . <$M1B -Key-J> do_revert_selection
38303856bind . <$M1B -Key-i> do_add_all
@@ -3836,9 +3862,11 @@ bind . <$M1B-Key-plus> {show_more_context;break}
38363862bind . <$M1B -Key-KP_Add> {show_more_context;break}
38373863bind . <$M1B -Key-Return> do_commit
38383864foreach 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 }
38423870}
38433871unset i
38443872
0 commit comments