From: Shawn O. Pearce Date: Tue, 10 Jul 2007 01:19:13 +0000 (-0400) Subject: Merge branch 'maint' X-Git-Tag: v1.5.3-rc1~16^2~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0a84b3d94ff8c29a5d3b738d4f08d1344305b619?ds=inline;hp=-c Merge branch 'maint' * maint: git-gui: Don't linewrap within console windows git-gui: Correct ls-tree buffering problem in browser --- 0a84b3d94ff8c29a5d3b738d4f08d1344305b619 diff --combined lib/browser.tcl index 4d33052ab5,e612247c9e..911e5af7f4 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@@ -11,6 -11,8 +11,8 @@@ field browser_status {Starting... field browser_stack {} field browser_busy 1 + field ls_buf {}; # Buffered record output from ls-tree + constructor new {commit} { global cursor_ptr M1B make_toplevel top w @@@ -160,7 -162,7 +162,7 @@@ method _click {was_double_click pos} } method _ls {tree_id {name {}}} { - set browser_buffer {} + set ls_buf {} set browser_files {} set browser_busy 1 @@@ -178,23 -180,26 +180,25 @@@ lappend browser_stack [list $tree_id $name] $w conf -state disabled - set cmd [list git ls-tree -z $tree_id] - set fd [open "| $cmd" r] + set fd [git_read ls-tree -z $tree_id] fconfigure $fd -blocking 0 -translation binary -encoding binary fileevent $fd readable [cb _read $fd] } method _read {fd} { - append browser_buffer [read $fd] - set pck [split $browser_buffer "\0"] - set browser_buffer [lindex $pck end] + append ls_buf [read $fd] + set pck [split $ls_buf "\0"] + set ls_buf [lindex $pck end] set n [llength $browser_files] $w conf -state normal foreach p [lrange $pck 0 end-1] { - set info [split $p "\t"] - set path [lindex $info 1] - set info [split [lindex $info 0] { }] - set type [lindex $info 1] + set tab [string first "\t" $p] + if {$tab == -1} continue + + set info [split [string range $p 0 [expr {$tab - 1}]] { }] + set path [string range $p [expr {$tab + 1}] end] + set type [lindex $info 1] set object [lindex $info 2] switch -- $type { @@@ -224,7 -229,7 +228,7 @@@ close $fd set browser_status Ready. set browser_busy 0 - unset browser_buffer + set ls_buf {} if {$n > 0} { $w tag add in_sel 1.0 2.0 focus -force $w diff --combined lib/console.tcl index 03d0354d5e,34de5d4859..6f718fbac3 --- a/lib/console.tcl +++ b/lib/console.tcl @@@ -7,7 -7,6 +7,7 @@@ field t_shor field t_long field w field console_cr +field is_toplevel 1; # are we our own window? constructor new {short_title long_title} { set t_short $short_title @@@ -16,25 -15,10 +16,25 @@@ return $this } +constructor embed {path title} { + set t_short {} + set t_long $title + set w $path + set is_toplevel 0 + _init $this + return $this +} + method _init {} { global M1B - make_toplevel top w -autodelete 0 - wm title $top "[appname] ([reponame]): $t_short" + + if {$is_toplevel} { + make_toplevel top w -autodelete 0 + wm title $top "[appname] ([reponame]): $t_short" + } else { + frame $w + } + set console_cr 1.0 frame $w.m @@@ -47,16 -31,20 +47,20 @@@ -background white -borderwidth 1 \ -relief sunken \ -width 80 -height 10 \ + -wrap none \ -font font_diff \ -state disabled \ + -xscrollcommand [list $w.m.sbx set] \ -yscrollcommand [list $w.m.sby set] label $w.m.s -text {Working... please wait...} \ -anchor w \ -justify left \ -font font_uibold + scrollbar $w.m.sbx -command [list $w.m.t xview] -orient h scrollbar $w.m.sby -command [list $w.m.t yview] pack $w.m.l1 -side top -fill x pack $w.m.s -side bottom -fill x + pack $w.m.sbx -side bottom -fill x pack $w.m.sby -side right -fill y pack $w.m.t -side left -fill both -expand 1 pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10 @@@ -73,26 -61,31 +77,26 @@@ $w.m.t tag remove sel 0.0 end " - button $w.ok -text {Close} \ - -state disabled \ - -command "destroy $w" - pack $w.ok -side bottom -anchor e -pady 10 -padx 10 + if {$is_toplevel} { + button $w.ok -text {Close} \ + -state disabled \ + -command [list destroy $w] + pack $w.ok -side bottom -anchor e -pady 10 -padx 10 + bind $w [list focus $w] + } bind_button3 $w.m.t "tk_popup $w.ctxm %X %Y" bind $w.m.t <$M1B-Key-a> "$w.m.t tag add sel 0.0 end;break" bind $w.m.t <$M1B-Key-A> "$w.m.t tag add sel 0.0 end;break" - bind $w "focus $w" } method exec {cmd {after {}}} { - # -- Cygwin's Tcl tosses the enviroment when we exec our child. - # But most users need that so we have to relogin. :-( - # - if {[is_Cygwin]} { - set cmd [list sh --login -c "cd \"[pwd]\" && [join $cmd { }]"] + if {[lindex $cmd 0] eq {git}} { + set fd_f [eval git_read --stderr [lrange $cmd 1 end]] + } else { + lappend cmd 2>@1 + set fd_f [_open_stdout_stderr $cmd] } - - # -- Tcl won't let us redirect both stdout and stderr to - # the same pipe. So pass it through cat... - # - set cmd [concat | $cmd |& cat] - - set fd_f [open $cmd r] fconfigure $fd_f -blocking 0 -translation binary fileevent $fd_f readable [cb _read $fd_f $after] } @@@ -166,32 -159,20 +170,32 @@@ method chain {cmdlist {ok 1}} } } +method insert {txt} { + if {![winfo exists $w.m.t]} {_init $this} + $w.m.t conf -state normal + $w.m.t insert end "$txt\n" + set console_cr [$w.m.t index {end -1c}] + $w.m.t conf -state disabled +} + method done {ok} { if {$ok} { if {[winfo exists $w.m.s]} { $w.m.s conf -background green -text {Success} - $w.ok conf -state normal - focus $w.ok + if {$is_toplevel} { + $w.ok conf -state normal + focus $w.ok + } } } else { if {![winfo exists $w.m.s]} { _init $this } $w.m.s conf -background red -text {Error: Command Failed} - $w.ok conf -state normal - focus $w.ok + if {$is_toplevel} { + $w.ok conf -state normal + focus $w.ok + } } delete_this }