@@ -275,6 +275,10 @@ proc is_Cygwin {} {
275
275
set _iscygwin 0
276
276
} else {
277
277
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
+ }
278
282
}
279
283
} else {
280
284
set _iscygwin 0
@@ -530,28 +534,10 @@ proc _lappend_nice {cmd_var} {
530
534
}
531
535
532
536
proc 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
555
541
if {$::_trace } {
556
542
puts stderr " < $result "
557
543
}
@@ -1107,7 +1093,7 @@ git-version proc _parse_config {arr_name args} {
1107
1093
[list git_read config] \
1108
1094
$args \
1109
1095
[ list --null --list] ]
1110
- fconfigure $fd_rc -translation binary
1096
+ fconfigure $fd_rc -translation binary -encoding utf-8
1111
1097
set buf [ read $fd_rc ]
1112
1098
close $fd_rc
1113
1099
}
@@ -1616,11 +1602,13 @@ proc run_prepare_commit_msg_hook {} {
1616
1602
if {[ file isfile [gitdir MERGE_MSG] ]} {
1617
1603
set pcm_source " merge"
1618
1604
set fd_mm [ open [gitdir MERGE_MSG] r]
1605
+ fconfigure $fd_mm -encoding utf-8
1619
1606
puts -nonewline $fd_pcm [ read $fd_mm ]
1620
1607
close $fd_mm
1621
1608
} elseif {[ file isfile [gitdir SQUASH_MSG] ]} {
1622
1609
set pcm_source " squash"
1623
1610
set fd_sm [ open [gitdir SQUASH_MSG] r]
1611
+ fconfigure $fd_sm -encoding utf-8
1624
1612
puts -nonewline $fd_pcm [ read $fd_sm ]
1625
1613
close $fd_sm
1626
1614
} else {
@@ -1685,7 +1673,7 @@ proc read_diff_index {fd after} {
1685
1673
set i [ split [string range $buf_rdi $c [expr {$z1 - 2}] ] { }]
1686
1674
set p [ string range $buf_rdi $z1 [expr {$z2 - 1}] ]
1687
1675
merge_state \
1688
- [ encoding convertfrom $p ] \
1676
+ [ encoding convertfrom utf-8 $p ] \
1689
1677
[ lindex $i 4] ? \
1690
1678
[ list [lindex $i 0] [ lindex $i 2] ] \
1691
1679
[ list ]
@@ -1718,7 +1706,7 @@ proc read_diff_files {fd after} {
1718
1706
set i [ split [string range $buf_rdf $c [expr {$z1 - 2}] ] { }]
1719
1707
set p [ string range $buf_rdf $z1 [expr {$z2 - 1}] ]
1720
1708
merge_state \
1721
- [ encoding convertfrom $p ] \
1709
+ [ encoding convertfrom utf-8 $p ] \
1722
1710
?[ lindex $i 4] \
1723
1711
[ list ] \
1724
1712
[ list [lindex $i 0] [ lindex $i 2] ]
@@ -1741,7 +1729,7 @@ proc read_ls_others {fd after} {
1741
1729
set pck [ split $buf_rlo " \0 " ]
1742
1730
set buf_rlo [ lindex $pck end]
1743
1731
foreach p [ lrange $pck 0 end-1] {
1744
- set p [ encoding convertfrom $p ]
1732
+ set p [ encoding convertfrom utf-8 $p ]
1745
1733
if {[ string index $p end] eq {/}} {
1746
1734
set p [ string range $p 0 end-1]
1747
1735
}
@@ -2505,20 +2493,36 @@ proc force_first_diff {after} {
2505
2493
}
2506
2494
}
2507
2495
2508
- proc toggle_or_diff {w x y } {
2496
+ proc toggle_or_diff {mode w args } {
2509
2497
global file_states file_lists current_diff_path ui_index ui_workdir
2510
2498
global last_clicked selected_paths
2511
2499
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
+
2515
2518
set path [ lindex $file_lists($w) [expr {$lno - 1}] ]
2516
2519
if {$path eq {}} {
2517
2520
set last_clicked {}
2518
2521
return
2519
2522
}
2520
2523
2521
2524
set last_clicked [ list $w $lno ]
2525
+ focus $w
2522
2526
array unset selected_paths
2523
2527
$ui_index tag remove in_sel 0.0 end
2524
2528
$ui_workdir tag remove in_sel 0.0 end
@@ -2598,7 +2602,7 @@ proc add_range_to_selection {w x y} {
2598
2602
global file_lists last_clicked selected_paths
2599
2603
2600
2604
if {[ lindex $last_clicked 0] ne $w } {
2601
- toggle_or_diff $w $x $y
2605
+ toggle_or_diff click $w $x $y
2602
2606
return
2603
2607
}
2604
2608
@@ -3007,7 +3011,7 @@ bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
3007
3011
3008
3012
set subcommand_args {}
3009
3013
proc usage {} {
3010
- set s " usage: $::argv0 $::subcommand $::subcommand_args "
3014
+ set s " [mc usage:] $::argv0 $::subcommand $::subcommand_args "
3011
3015
if {[ tk windowingsystem] eq " win32" } {
3012
3016
wm withdraw .
3013
3017
tk_messageBox -icon info -message $s \
@@ -3139,7 +3143,7 @@ gui {
3139
3143
# fall through to setup UI for commits
3140
3144
}
3141
3145
default {
3142
- set err " usage: $argv0 \[ {blame|browser|citool}\] "
3146
+ set err " [mc usage:] $argv0 \[ {blame|browser|citool}\] "
3143
3147
if {[ tk windowingsystem] eq " win32" } {
3144
3148
wm withdraw .
3145
3149
tk_messageBox -icon error -message $err \
@@ -3178,16 +3182,38 @@ if {$use_ttk} {
3178
3182
}
3179
3183
pack .vpane -anchor n -side top -fill both -expand 1
3180
3184
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
+
3181
3206
# -- Index File List
3182
3207
#
3183
- ${NS} ::frame .vpane.files.index -height 100 -width 200
3208
+ textframe .vpane.files.index -height 100 -width 200
3184
3209
tlabel .vpane.files.index.title \
3185
3210
-text [ mc " Staged Changes (Will Commit)" ] \
3186
3211
-background lightgreen -foreground black
3187
- text $ui_index -background white -foreground black \
3212
+ ttext $ui_index -background white -foreground black \
3188
3213
-borderwidth 0 \
3189
3214
-width 20 -height 10 \
3190
3215
-wrap none \
3216
+ -takefocus 1 -highlightthickness 1\
3191
3217
-cursor $cursor_ptr \
3192
3218
-xscrollcommand {.vpane.files.index.sx set} \
3193
3219
-yscrollcommand {.vpane.files.index.sy set} \
@@ -3199,26 +3225,8 @@ pack .vpane.files.index.sx -side bottom -fill x
3199
3225
pack .vpane.files.index.sy -side right -fill y
3200
3226
pack $ui_index -side left -fill both -expand 1
3201
3227
3202
- # -- Working Directory File List
3228
+ # -- Insert the workdir and index into the panes
3203
3229
#
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
-
3222
3230
.vpane.files add .vpane.files.workdir
3223
3231
.vpane.files add .vpane.files.index
3224
3232
if {!$use_ttk } {
@@ -3301,7 +3309,7 @@ if {![is_enabled nocommit]} {
3301
3309
#
3302
3310
${NS} ::frame .vpane.lower.commarea.buffer
3303
3311
${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
3305
3313
set ui_coml .vpane.lower.commarea.buffer.header.l
3306
3314
3307
3315
if {![ is_enabled nocommit] } {
@@ -3344,20 +3352,25 @@ if {![is_enabled nocommit]} {
3344
3352
pack .vpane.lower.commarea.buffer.header.new -side right
3345
3353
}
3346
3354
3347
- text $ui_comm -background white -foreground black \
3355
+ textframe .vpane.lower.commarea.buffer.frame
3356
+ ttext $ui_comm -background white -foreground black \
3348
3357
-borderwidth 1 \
3349
3358
-undo true \
3350
3359
-maxundo 20 \
3351
3360
-autoseparators true \
3361
+ -takefocus 1 \
3362
+ -highlightthickness 1 \
3352
3363
-relief sunken \
3353
3364
-width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \
3354
3365
-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 \
3357
3368
-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
3360
3371
pack $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
3361
3374
pack .vpane.lower.commarea.buffer -side left -fill y
3362
3375
3363
3376
# -- Commit Message Buffer Context Menu
@@ -3455,12 +3468,13 @@ bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
3455
3468
3456
3469
# -- Diff Body
3457
3470
#
3458
- ${NS} ::frame .vpane.lower.diff.body
3471
+ textframe .vpane.lower.diff.body
3459
3472
set ui_diff .vpane.lower.diff.body.t
3460
- text $ui_diff -background white -foreground black \
3473
+ ttext $ui_diff -background white -foreground black \
3461
3474
-borderwidth 0 \
3462
3475
-width 80 -height 5 -wrap none \
3463
3476
-font font_diff \
3477
+ -takefocus 1 -highlightthickness 1 \
3464
3478
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
3465
3479
-yscrollcommand {.vpane.lower.diff.body.sby set} \
3466
3480
-state disabled
@@ -3815,10 +3829,10 @@ bind . <$M1B-Key-r> ui_do_rescan
3815
3829
bind . <$M1B -Key-R> ui_do_rescan
3816
3830
bind . <$M1B -Key-s> do_signoff
3817
3831
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
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 }
3822
3836
bind . <$M1B -Key-j> do_revert_selection
3823
3837
bind . <$M1B -Key-J> do_revert_selection
3824
3838
bind . <$M1B -Key-i> do_add_all
@@ -3830,9 +3844,11 @@ bind . <$M1B-Key-plus> {show_more_context;break}
3830
3844
bind . <$M1B -Key-KP_Add> {show_more_context;break}
3831
3845
bind . <$M1B -Key-Return> do_commit
3832
3846
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 "
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 }
3836
3852
}
3837
3853
unset i
3838
3854
0 commit comments