@@ -275,6 +275,10 @@ proc is_Cygwin {} {
275275 set _iscygwin 0
276276 } else {
277277 set _iscygwin 1
278+ # Handle MSys2 which is only cygwin when MSYSTEM is MSYS.
279+ if {[info exists ::env(MSYSTEM)] && $::env(MSYSTEM) ne " MSYS" } {
280+ set _iscygwin 0
281+ }
278282 }
279283 } else {
280284 set _iscygwin 0
@@ -530,28 +534,10 @@ proc _lappend_nice {cmd_var} {
530534}
531535
532536proc git {args} {
533- set opt [ list ]
534-
535- while {1} {
536- switch -- [ lindex $args 0] {
537- --nice {
538- _lappend_nice opt
539- }
540-
541- default {
542- break
543- }
544-
545- }
546-
547- set args [ lrange $args 1 end]
548- }
549-
550- set cmdp [ _git_cmd [lindex $args 0] ]
551- set args [ lrange $args 1 end]
552-
553- _trace_exec [ concat $opt $cmdp $args ]
554- set result [ eval exec $opt $cmdp $args ]
537+ set fd [ eval [list git_read] $args ]
538+ fconfigure $fd -translation binary -encoding utf-8
539+ set result [ string trimright [read $fd ] " \n " ]
540+ close $fd
555541 if {$::_trace } {
556542 puts stderr " < $result "
557543 }
@@ -1107,7 +1093,7 @@ git-version proc _parse_config {arr_name args} {
11071093 [list git_read config] \
11081094 $args \
11091095 [ list --null --list] ]
1110- fconfigure $fd_rc -translation binary
1096+ fconfigure $fd_rc -translation binary -encoding utf-8
11111097 set buf [ read $fd_rc ]
11121098 close $fd_rc
11131099 }
@@ -1616,11 +1602,13 @@ proc run_prepare_commit_msg_hook {} {
16161602 if {[ file isfile [gitdir MERGE_MSG] ]} {
16171603 set pcm_source " merge"
16181604 set fd_mm [ open [gitdir MERGE_MSG] r]
1605+ fconfigure $fd_mm -encoding utf-8
16191606 puts -nonewline $fd_pcm [ read $fd_mm ]
16201607 close $fd_mm
16211608 } elseif {[ file isfile [gitdir SQUASH_MSG] ]} {
16221609 set pcm_source " squash"
16231610 set fd_sm [ open [gitdir SQUASH_MSG] r]
1611+ fconfigure $fd_sm -encoding utf-8
16241612 puts -nonewline $fd_pcm [ read $fd_sm ]
16251613 close $fd_sm
16261614 } else {
@@ -1685,7 +1673,7 @@ proc read_diff_index {fd after} {
16851673 set i [ split [string range $buf_rdi $c [expr {$z1 - 2}] ] { }]
16861674 set p [ string range $buf_rdi $z1 [expr {$z2 - 1}] ]
16871675 merge_state \
1688- [ encoding convertfrom $p ] \
1676+ [ encoding convertfrom utf-8 $p ] \
16891677 [ lindex $i 4] ? \
16901678 [ list [lindex $i 0] [ lindex $i 2] ] \
16911679 [ list ]
@@ -1718,7 +1706,7 @@ proc read_diff_files {fd after} {
17181706 set i [ split [string range $buf_rdf $c [expr {$z1 - 2}] ] { }]
17191707 set p [ string range $buf_rdf $z1 [expr {$z2 - 1}] ]
17201708 merge_state \
1721- [ encoding convertfrom $p ] \
1709+ [ encoding convertfrom utf-8 $p ] \
17221710 ?[ lindex $i 4] \
17231711 [ list ] \
17241712 [ list [lindex $i 0] [ lindex $i 2] ]
@@ -1741,7 +1729,7 @@ proc read_ls_others {fd after} {
17411729 set pck [ split $buf_rlo " \0 " ]
17421730 set buf_rlo [ lindex $pck end]
17431731 foreach p [ lrange $pck 0 end-1] {
1744- set p [ encoding convertfrom $p ]
1732+ set p [ encoding convertfrom utf-8 $p ]
17451733 if {[ string index $p end] eq {/}} {
17461734 set p [ string range $p 0 end-1]
17471735 }
@@ -2505,20 +2493,36 @@ proc force_first_diff {after} {
25052493 }
25062494}
25072495
2508- proc toggle_or_diff {w x y } {
2496+ proc toggle_or_diff {mode w args } {
25092497 global file_states file_lists current_diff_path ui_index ui_workdir
25102498 global last_clicked selected_paths
25112499
2512- set pos [ split [$w index @$x ,$y ] .]
2513- set lno [ lindex $pos 0]
2514- set col [ lindex $pos 1]
2500+ if {$mode eq " click" } {
2501+ foreach {x y} $args break
2502+ set pos [ split [$w index @$x ,$y ] .]
2503+ foreach {lno col} $pos break
2504+ } else {
2505+ if {$last_clicked ne {}} {
2506+ set lno [ lindex $last_clicked 1]
2507+ } else {
2508+ set lno [ expr {int([lindex [$w tag ranges in_diff] 0])}]
2509+ }
2510+ if {$mode eq " toggle" } {
2511+ set col 0; set y 2
2512+ } else {
2513+ incr lno [ expr {$mode eq " up" ? -1 : 1}]
2514+ set col 1
2515+ }
2516+ }
2517+
25152518 set path [ lindex $file_lists($w) [expr {$lno - 1}] ]
25162519 if {$path eq {}} {
25172520 set last_clicked {}
25182521 return
25192522 }
25202523
25212524 set last_clicked [ list $w $lno ]
2525+ focus $w
25222526 array unset selected_paths
25232527 $ui_index tag remove in_sel 0.0 end
25242528 $ui_workdir tag remove in_sel 0.0 end
@@ -2598,7 +2602,7 @@ proc add_range_to_selection {w x y} {
25982602 global file_lists last_clicked selected_paths
25992603
26002604 if {[ lindex $last_clicked 0] ne $w } {
2601- toggle_or_diff $w $x $y
2605+ toggle_or_diff click $w $x $y
26022606 return
26032607 }
26042608
@@ -3007,7 +3011,7 @@ bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
30073011
30083012set subcommand_args {}
30093013proc usage {} {
3010- set s " usage: $::argv0 $::subcommand $::subcommand_args "
3014+ set s " [mc usage:] $::argv0 $::subcommand $::subcommand_args "
30113015 if {[ tk windowingsystem] eq " win32" } {
30123016 wm withdraw .
30133017 tk_messageBox -icon info -message $s \
@@ -3139,7 +3143,7 @@ gui {
31393143 # fall through to setup UI for commits
31403144}
31413145default {
3142- set err " usage: $argv0 \[ {blame|browser|citool}\] "
3146+ set err " [mc usage:] $argv0 \[ {blame|browser|citool}\] "
31433147 if {[ tk windowingsystem] eq " win32" } {
31443148 wm withdraw .
31453149 tk_messageBox -icon error -message $err \
@@ -3178,16 +3182,38 @@ if {$use_ttk} {
31783182}
31793183pack .vpane -anchor n -side top -fill both -expand 1
31803184
3185+ # -- Working Directory File List
3186+
3187+ textframe .vpane.files.workdir -height 100 -width 200
3188+ tlabel .vpane.files.workdir.title -text [ mc " Unstaged Changes" ] \
3189+ -background lightsalmon -foreground black
3190+ ttext $ui_workdir -background white -foreground black \
3191+ -borderwidth 0 \
3192+ -width 20 -height 10 \
3193+ -wrap none \
3194+ -takefocus 1 -highlightthickness 1\
3195+ -cursor $cursor_ptr \
3196+ -xscrollcommand {.vpane.files.workdir.sx set} \
3197+ -yscrollcommand {.vpane.files.workdir.sy set} \
3198+ -state disabled
3199+ ${NS} ::scrollbar .vpane.files.workdir.sx -orient h -command [ list $ui_workdir xview]
3200+ ${NS} ::scrollbar .vpane.files.workdir.sy -orient v -command [ list $ui_workdir yview]
3201+ pack .vpane.files.workdir.title -side top -fill x
3202+ pack .vpane.files.workdir.sx -side bottom -fill x
3203+ pack .vpane.files.workdir.sy -side right -fill y
3204+ pack $ui_workdir -side left -fill both -expand 1
3205+
31813206# -- Index File List
31823207#
3183- ${NS} ::frame .vpane.files.index -height 100 -width 200
3208+ textframe .vpane.files.index -height 100 -width 200
31843209tlabel .vpane.files.index.title \
31853210 -text [ mc " Staged Changes (Will Commit)" ] \
31863211 -background lightgreen -foreground black
3187- text $ui_index -background white -foreground black \
3212+ ttext $ui_index -background white -foreground black \
31883213 -borderwidth 0 \
31893214 -width 20 -height 10 \
31903215 -wrap none \
3216+ -takefocus 1 -highlightthickness 1\
31913217 -cursor $cursor_ptr \
31923218 -xscrollcommand {.vpane.files.index.sx set} \
31933219 -yscrollcommand {.vpane.files.index.sy set} \
@@ -3199,26 +3225,8 @@ pack .vpane.files.index.sx -side bottom -fill x
31993225pack .vpane.files.index.sy -side right -fill y
32003226pack $ui_index -side left -fill both -expand 1
32013227
3202- # -- Working Directory File List
3228+ # -- Insert the workdir and index into the panes
32033229#
3204- ${NS} ::frame .vpane.files.workdir -height 100 -width 200
3205- tlabel .vpane.files.workdir.title -text [ mc " Unstaged Changes" ] \
3206- -background lightsalmon -foreground black
3207- text $ui_workdir -background white -foreground black \
3208- -borderwidth 0 \
3209- -width 20 -height 10 \
3210- -wrap none \
3211- -cursor $cursor_ptr \
3212- -xscrollcommand {.vpane.files.workdir.sx set} \
3213- -yscrollcommand {.vpane.files.workdir.sy set} \
3214- -state disabled
3215- ${NS} ::scrollbar .vpane.files.workdir.sx -orient h -command [ list $ui_workdir xview]
3216- ${NS} ::scrollbar .vpane.files.workdir.sy -orient v -command [ list $ui_workdir yview]
3217- pack .vpane.files.workdir.title -side top -fill x
3218- pack .vpane.files.workdir.sx -side bottom -fill x
3219- pack .vpane.files.workdir.sy -side right -fill y
3220- pack $ui_workdir -side left -fill both -expand 1
3221-
32223230.vpane.files add .vpane.files.workdir
32233231.vpane.files add .vpane.files.index
32243232if {!$use_ttk } {
@@ -3301,7 +3309,7 @@ if {![is_enabled nocommit]} {
33013309#
33023310${NS} ::frame .vpane.lower.commarea.buffer
33033311${NS} ::frame .vpane.lower.commarea.buffer.header
3304- set ui_comm .vpane.lower.commarea.buffer.t
3312+ set ui_comm .vpane.lower.commarea.buffer.frame. t
33053313set ui_coml .vpane.lower.commarea.buffer.header.l
33063314
33073315if {![ is_enabled nocommit] } {
@@ -3344,20 +3352,25 @@ if {![is_enabled nocommit]} {
33443352 pack .vpane.lower.commarea.buffer.header.new -side right
33453353}
33463354
3347- text $ui_comm -background white -foreground black \
3355+ textframe .vpane.lower.commarea.buffer.frame
3356+ ttext $ui_comm -background white -foreground black \
33483357 -borderwidth 1 \
33493358 -undo true \
33503359 -maxundo 20 \
33513360 -autoseparators true \
3361+ -takefocus 1 \
3362+ -highlightthickness 1 \
33523363 -relief sunken \
33533364 -width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \
33543365 -font font_diff \
3355- -yscrollcommand {.vpane.lower.commarea.buffer.sby set}
3356- ${NS} ::scrollbar .vpane.lower.commarea.buffer.sby \
3366+ -yscrollcommand {.vpane.lower.commarea.buffer.frame. sby set}
3367+ ${NS} ::scrollbar .vpane.lower.commarea.buffer.frame. sby \
33573368 -command [ list $ui_comm yview]
3358- pack .vpane.lower.commarea.buffer.header -side top -fill x
3359- pack .vpane.lower.commarea.buffer.sby -side right -fill y
3369+
3370+ pack .vpane.lower.commarea.buffer.frame. sby -side right -fill y
33603371pack $ui_comm -side left -fill y
3372+ pack .vpane.lower.commarea.buffer.header -side top -fill x
3373+ pack .vpane.lower.commarea.buffer.frame -side left -fill y
33613374pack .vpane.lower.commarea.buffer -side left -fill y
33623375
33633376# -- Commit Message Buffer Context Menu
@@ -3455,12 +3468,13 @@ bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
34553468
34563469# -- Diff Body
34573470#
3458- ${NS} ::frame .vpane.lower.diff.body
3471+ textframe .vpane.lower.diff.body
34593472set ui_diff .vpane.lower.diff.body.t
3460- text $ui_diff -background white -foreground black \
3473+ ttext $ui_diff -background white -foreground black \
34613474 -borderwidth 0 \
34623475 -width 80 -height 5 -wrap none \
34633476 -font font_diff \
3477+ -takefocus 1 -highlightthickness 1 \
34643478 -xscrollcommand {.vpane.lower.diff.body.sbx set} \
34653479 -yscrollcommand {.vpane.lower.diff.body.sby set} \
34663480 -state disabled
@@ -3815,10 +3829,10 @@ bind . <$M1B-Key-r> ui_do_rescan
38153829bind . <$M1B -Key-R> ui_do_rescan
38163830bind . <$M1B -Key-s> do_signoff
38173831bind . <$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
3832+ bind . <$M1B -Key-t> { toggle_or_diff toggle %W }
3833+ bind . <$M1B -Key-T> { toggle_or_diff toggle %W }
3834+ bind . <$M1B -Key-u> { toggle_or_diff toggle %W }
3835+ bind . <$M1B -Key-U> { toggle_or_diff toggle %W }
38223836bind . <$M1B -Key-j> do_revert_selection
38233837bind . <$M1B -Key-J> do_revert_selection
38243838bind . <$M1B -Key-i> do_add_all
@@ -3830,9 +3844,11 @@ bind . <$M1B-Key-plus> {show_more_context;break}
38303844bind . <$M1B -Key-KP_Add> {show_more_context;break}
38313845bind . <$M1B -Key-Return> do_commit
38323846foreach 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 "
3847+ bind $i <Button-1> { toggle_or_diff click %W %x %y; break }
3848+ bind $i <$M1B -Button-1> { add_one_to_selection %W %x %y; break }
3849+ bind $i <Shift-Button-1> { add_range_to_selection %W %x %y; break }
3850+ bind $i <Key-Up> { toggle_or_diff up %W; break }
3851+ bind $i <Key-Down> { toggle_or_diff down %W; break }
38363852}
38373853unset i
38383854
0 commit comments