Skip to content

Commit 0fb8f9c

Browse files
committed
git-gui: Flip commit message buffer and diff area.
Since Tk will only supply new space gained from growing the top level to the bottom/right most widget within a panedwindow and most users will be growing a git-gui main window for the purposes of seeing more of the currently shown diff, flipping the order around makes Tk do what the user wants by default. Of course because we also removed the paned window from the commit buffer area it is now impossible to increase the visible space for the commit message. But I don't see this as a huge concern right now as its actually very awkward to try and balance three paned window dividers within the same top level window. We could always add it back if users really want to expand the commit buffer and see more. I also corrected a number of bugs that I accidentally introduced in the last commit. Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 6b29267 commit 0fb8f9c

File tree

1 file changed

+91
-88
lines changed

1 file changed

+91
-88
lines changed

git-gui

Lines changed: 91 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ proc repository_state {hdvar ctvar} {
7070
proc update_status {{final Ready.}} {
7171
global HEAD PARENT commit_type
7272
global ui_index ui_other ui_status_value ui_comm
73-
global status_active file_states status_start
73+
global status_active file_states
7474

7575
if {$status_active || ![lock_index read]} return
7676

@@ -84,7 +84,6 @@ proc update_status {{final Ready.}} {
8484
set commit_type $new_type
8585
}
8686

87-
set status_start [clock seconds]
8887
array unset file_states
8988
foreach w [list $ui_index $ui_other] {
9089
$w conf -state normal
@@ -231,7 +230,7 @@ proc read_ls_others {fd final} {
231230
}
232231

233232
proc status_eof {fd buf final} {
234-
global status_active status_start $buf
233+
global status_active $buf
235234
global ui_fname_value ui_status_value file_states
236235

237236
if {[eof $fd]} {
@@ -241,11 +240,7 @@ proc status_eof {fd buf final} {
241240
if {[incr status_active -1] == 0} {
242241
unlock_index
243242

244-
set e1 [clock seconds]
245243
display_all_files
246-
set e2 [clock seconds]
247-
puts "TIME [expr $e1 - $status_start] + [expr $e2 - $e1] = [expr $e2 - $status_start]"
248-
249244
set ui_status_value $final
250245

251246
if {$ui_fname_value != {} && [array names file_states \
@@ -758,10 +753,10 @@ proc display_file {path state} {
758753
if {$status_active} return
759754

760755
set s $file_states($path)
761-
set old_w [mapcol $old_m $path]
762-
set new_w [mapcol $new_m $path]
763756
set new_m [lindex $s 0]
764-
set new_ico [mapicon $new_m $path]
757+
set new_w [mapcol $new_m $path]
758+
set old_w [mapcol $old_m $path]
759+
set new_icon [mapicon $new_m $path]
765760

766761
if {$new_w != $old_w} {
767762
set lno [bsearch $old_w $path]
@@ -1498,101 +1493,56 @@ pack $ui_other -side left -fill both -expand 1
14981493
$ui_index tag conf in_diff -font [concat $mainfont bold]
14991494
$ui_other tag conf in_diff -font [concat $mainfont bold]
15001495

1501-
# -- Diff Header
1502-
set ui_fname_value {}
1503-
set ui_fstatus_value {}
1504-
frame .vpane.diff -height 200 -width 400
1505-
frame .vpane.diff.header
1506-
label .vpane.diff.header.l1 -text {File:} -font $mainfont
1507-
label .vpane.diff.header.l2 -textvariable ui_fname_value \
1508-
-anchor w \
1509-
-justify left \
1510-
-font $mainfont
1511-
label .vpane.diff.header.l3 -text {Status:} -font $mainfont
1512-
label .vpane.diff.header.l4 -textvariable ui_fstatus_value \
1513-
-width $max_status_desc \
1514-
-anchor w \
1515-
-justify left \
1516-
-font $mainfont
1517-
pack .vpane.diff.header.l1 -side left
1518-
pack .vpane.diff.header.l2 -side left -fill x
1519-
pack .vpane.diff.header.l4 -side right
1520-
pack .vpane.diff.header.l3 -side right
1521-
1522-
# -- Diff Body
1523-
frame .vpane.diff.body
1524-
set ui_diff .vpane.diff.body.t
1525-
text $ui_diff -background white -borderwidth 0 \
1526-
-width 80 -height 15 -wrap none \
1527-
-font $difffont \
1528-
-xscrollcommand {.vpane.diff.body.sbx set} \
1529-
-yscrollcommand {.vpane.diff.body.sby set} \
1530-
-cursor $maincursor \
1531-
-state disabled
1532-
scrollbar .vpane.diff.body.sbx -orient horizontal \
1533-
-command [list $ui_diff xview]
1534-
scrollbar .vpane.diff.body.sby -orient vertical \
1535-
-command [list $ui_diff yview]
1536-
pack .vpane.diff.body.sbx -side bottom -fill x
1537-
pack .vpane.diff.body.sby -side right -fill y
1538-
pack $ui_diff -side left -fill both -expand 1
1539-
pack .vpane.diff.header -side top -fill x
1540-
pack .vpane.diff.body -side bottom -fill both -expand 1
1541-
.vpane add .vpane.diff -stick nsew
1542-
1543-
$ui_diff tag conf dm -foreground red
1544-
$ui_diff tag conf dp -foreground blue
1545-
$ui_diff tag conf da -font [concat $difffont bold]
1546-
$ui_diff tag conf di -foreground "#00a000"
1547-
$ui_diff tag conf dni -foreground "#a000a0"
1548-
$ui_diff tag conf bold -font [concat $difffont bold]
1549-
1550-
# -- Commit Area
1551-
frame .vpane.commarea -height 170
1552-
.vpane add .vpane.commarea -stick nsew
1496+
# -- Diff and Commit Area
1497+
frame .vpane.lower -height 400 -width 400
1498+
frame .vpane.lower.commarea
1499+
frame .vpane.lower.diff -relief sunken -borderwidth 1
1500+
pack .vpane.lower.commarea -side top -fill x
1501+
pack .vpane.lower.diff -side bottom -fill both -expand 1
1502+
.vpane add .vpane.lower -stick nsew
15531503

15541504
# -- Commit Area Buttons
1555-
frame .vpane.commarea.buttons
1556-
label .vpane.commarea.buttons.l -text {} \
1505+
frame .vpane.lower.commarea.buttons
1506+
label .vpane.lower.commarea.buttons.l -text {} \
15571507
-anchor w \
15581508
-justify left \
15591509
-font $mainfont
1560-
pack .vpane.commarea.buttons.l -side top -fill x
1561-
pack .vpane.commarea.buttons -side left -fill y
1510+
pack .vpane.lower.commarea.buttons.l -side top -fill x
1511+
pack .vpane.lower.commarea.buttons -side left -fill y
15621512

1563-
button .vpane.commarea.buttons.rescan -text {Rescan} \
1513+
button .vpane.lower.commarea.buttons.rescan -text {Rescan} \
15641514
-command do_rescan \
15651515
-font $mainfont
1566-
pack .vpane.commarea.buttons.rescan -side top -fill x
1567-
lappend disable_on_lock {.vpane.commarea.buttons.rescan conf -state}
1516+
pack .vpane.lower.commarea.buttons.rescan -side top -fill x
1517+
lappend disable_on_lock {.vpane.lower.commarea.buttons.rescan conf -state}
15681518

1569-
button .vpane.commarea.buttons.amend -text {Amend Last} \
1519+
button .vpane.lower.commarea.buttons.amend -text {Amend Last} \
15701520
-command do_amend_last \
15711521
-font $mainfont
1572-
pack .vpane.commarea.buttons.amend -side top -fill x
1573-
lappend disable_on_lock {.vpane.commarea.buttons.amend conf -state}
1522+
pack .vpane.lower.commarea.buttons.amend -side top -fill x
1523+
lappend disable_on_lock {.vpane.lower.commarea.buttons.amend conf -state}
15741524

1575-
button .vpane.commarea.buttons.ciall -text {Check-in All} \
1525+
button .vpane.lower.commarea.buttons.ciall -text {Check-in All} \
15761526
-command do_checkin_all \
15771527
-font $mainfont
1578-
pack .vpane.commarea.buttons.ciall -side top -fill x
1579-
lappend disable_on_lock {.vpane.commarea.buttons.ciall conf -state}
1528+
pack .vpane.lower.commarea.buttons.ciall -side top -fill x
1529+
lappend disable_on_lock {.vpane.lower.commarea.buttons.ciall conf -state}
15801530

1581-
button .vpane.commarea.buttons.signoff -text {Sign Off} \
1531+
button .vpane.lower.commarea.buttons.signoff -text {Sign Off} \
15821532
-command do_signoff \
15831533
-font $mainfont
1584-
pack .vpane.commarea.buttons.signoff -side top -fill x
1534+
pack .vpane.lower.commarea.buttons.signoff -side top -fill x
15851535

1586-
button .vpane.commarea.buttons.commit -text {Commit} \
1536+
button .vpane.lower.commarea.buttons.commit -text {Commit} \
15871537
-command do_commit \
15881538
-font $mainfont
1589-
pack .vpane.commarea.buttons.commit -side top -fill x
1590-
lappend disable_on_lock {.vpane.commarea.buttons.commit conf -state}
1539+
pack .vpane.lower.commarea.buttons.commit -side top -fill x
1540+
lappend disable_on_lock {.vpane.lower.commarea.buttons.commit conf -state}
15911541

15921542
# -- Commit Message Buffer
1593-
frame .vpane.commarea.buffer
1594-
set ui_comm .vpane.commarea.buffer.t
1595-
set ui_coml .vpane.commarea.buffer.l
1543+
frame .vpane.lower.commarea.buffer
1544+
set ui_comm .vpane.lower.commarea.buffer.t
1545+
set ui_coml .vpane.lower.commarea.buffer.l
15961546
label $ui_coml -text {Commit Message:} \
15971547
-anchor w \
15981548
-justify left \
@@ -1606,15 +1556,68 @@ trace add variable commit_type write {uplevel #0 {
16061556
}}
16071557
text $ui_comm -background white -borderwidth 1 \
16081558
-relief sunken \
1609-
-width 75 -height 10 -wrap none \
1559+
-width 75 -height 9 -wrap none \
16101560
-font $difffont \
1611-
-yscrollcommand {.vpane.commarea.buffer.sby set} \
1561+
-yscrollcommand {.vpane.lower.commarea.buffer.sby set} \
16121562
-cursor $maincursor
1613-
scrollbar .vpane.commarea.buffer.sby -command [list $ui_comm yview]
1563+
scrollbar .vpane.lower.commarea.buffer.sby -command [list $ui_comm yview]
16141564
pack $ui_coml -side top -fill x
1615-
pack .vpane.commarea.buffer.sby -side right -fill y
1565+
pack .vpane.lower.commarea.buffer.sby -side right -fill y
16161566
pack $ui_comm -side left -fill y
1617-
pack .vpane.commarea.buffer -side left -fill y
1567+
pack .vpane.lower.commarea.buffer -side left -fill y
1568+
1569+
# -- Diff Header
1570+
set ui_fname_value {}
1571+
set ui_fstatus_value {}
1572+
frame .vpane.lower.diff.header -background orange
1573+
label .vpane.lower.diff.header.l1 -text {File:} \
1574+
-background orange \
1575+
-font $mainfont
1576+
label .vpane.lower.diff.header.l2 -textvariable ui_fname_value \
1577+
-background orange \
1578+
-anchor w \
1579+
-justify left \
1580+
-font $mainfont
1581+
label .vpane.lower.diff.header.l3 -text {Status:} \
1582+
-background orange \
1583+
-font $mainfont
1584+
label .vpane.lower.diff.header.l4 -textvariable ui_fstatus_value \
1585+
-background orange \
1586+
-width $max_status_desc \
1587+
-anchor w \
1588+
-justify left \
1589+
-font $mainfont
1590+
pack .vpane.lower.diff.header.l1 -side left
1591+
pack .vpane.lower.diff.header.l2 -side left -fill x
1592+
pack .vpane.lower.diff.header.l4 -side right
1593+
pack .vpane.lower.diff.header.l3 -side right
1594+
1595+
# -- Diff Body
1596+
frame .vpane.lower.diff.body
1597+
set ui_diff .vpane.lower.diff.body.t
1598+
text $ui_diff -background white -borderwidth 0 \
1599+
-width 80 -height 15 -wrap none \
1600+
-font $difffont \
1601+
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
1602+
-yscrollcommand {.vpane.lower.diff.body.sby set} \
1603+
-cursor $maincursor \
1604+
-state disabled
1605+
scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
1606+
-command [list $ui_diff xview]
1607+
scrollbar .vpane.lower.diff.body.sby -orient vertical \
1608+
-command [list $ui_diff yview]
1609+
pack .vpane.lower.diff.body.sbx -side bottom -fill x
1610+
pack .vpane.lower.diff.body.sby -side right -fill y
1611+
pack $ui_diff -side left -fill both -expand 1
1612+
pack .vpane.lower.diff.header -side top -fill x
1613+
pack .vpane.lower.diff.body -side bottom -fill both -expand 1
1614+
1615+
$ui_diff tag conf dm -foreground red
1616+
$ui_diff tag conf dp -foreground blue
1617+
$ui_diff tag conf da -font [concat $difffont bold]
1618+
$ui_diff tag conf di -foreground "#00a000"
1619+
$ui_diff tag conf dni -foreground "#a000a0"
1620+
$ui_diff tag conf bold -font [concat $difffont bold]
16181621

16191622
# -- Status Bar
16201623
set ui_status_value {Initializing...}

0 commit comments

Comments
 (0)