Browse Source

git-gui: Automatically reopen any console closed by the user.

If the user closes a console and we get more ouptut for it then we
will get a Tcl error in the readable event handle for the file channel.
Since this loses the actual output and is quite unfriendly to the end
user instead reopen any console which the user closed prior to the
additional output arriving.
 
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
maint
Shawn O. Pearce 19 years ago
parent
commit
37af79d10d
  1. 30
      git-gui

30
git-gui

@ -1005,14 +1005,20 @@ proc hook_failed_popup {hook msg} {
set next_console_id 0 set next_console_id 0


proc new_console {short_title long_title} { proc new_console {short_title long_title} {
global next_console_id console_cr global next_console_id console_data
set w .console[incr next_console_id]
set console_data($w) [list $short_title $long_title]
return [console_init $w]
}

proc console_init {w} {
global console_cr console_data
global gitdir appname mainfont difffont global gitdir appname mainfont difffont


set w .console[incr next_console_id]
set console_cr($w) 1.0 set console_cr($w) 1.0
toplevel $w toplevel $w
frame $w.m frame $w.m
label $w.m.l1 -text "$long_title:" \ label $w.m.l1 -text "[lindex $console_data($w) 1]:" \
-anchor w \ -anchor w \
-justify left \ -justify left \
-font [concat $mainfont bold] -font [concat $mainfont bold]
@ -1041,8 +1047,7 @@ proc new_console {short_title long_title} {
pack $w.ok -side bottom pack $w.ok -side bottom


bind $w <Visibility> "focus $w" bind $w <Visibility> "focus $w"
bind $w <Destroy> break wm title $w "$appname ([file dirname [file normalize [file dirname $gitdir]]]): [lindex $console_data($w) 0]"
wm title $w "$appname ([file dirname [file normalize [file dirname $gitdir]]]): $short_title"
return $w return $w
} }


@ -1067,10 +1072,12 @@ proc console_exec {w cmd} {
} }


proc console_read {w fd} { proc console_read {w fd} {
global console_cr global console_cr console_data


$w.m.t conf -state normal
set buf [read $fd] set buf [read $fd]
if {$buf != {}} {
if {![winfo exists $w]} {console_init $w}
$w.m.t conf -state normal
set c 0 set c 0
set n [string length $buf] set n [string length $buf]
while {$c < $n} { while {$c < $n} {
@ -1094,17 +1101,22 @@ proc console_read {w fd} {
} }
$w.m.t conf -state disabled $w.m.t conf -state disabled
$w.m.t see end $w.m.t see end
}


fconfigure $fd -blocking 1 fconfigure $fd -blocking 1
if {[eof $fd]} { if {[eof $fd]} {
if {[catch {close $fd}]} { if {[catch {close $fd}]} {
if {![winfo exists $w]} {console_init $w}
$w.m.s conf -background red -text {Error: Command Failed} $w.m.s conf -background red -text {Error: Command Failed}
} else { $w.ok conf -text Close
$w.ok conf -state normal
} elseif {[winfo exists $w]} {
$w.m.s conf -background green -text {Success} $w.m.s conf -background green -text {Success}
}
$w.ok conf -text Close $w.ok conf -text Close
$w.ok conf -state normal $w.ok conf -state normal
}
array unset console_cr $w array unset console_cr $w
array unset console_data $w
return return
} }
fconfigure $fd -blocking 0 fconfigure $fd -blocking 0

Loading…
Cancel
Save