]> asedeno.scripts.mit.edu Git - git.git/blobdiff - lib/console.tcl
git-gui: avoid mis-encoding the copyright message on Windows.
[git.git] / lib / console.tcl
index c0e6fb3cc2fe9cb66e114d4998b2e91d65548980..1f3248ffd11353200c64bdbde630b4147dc96c0a 100644 (file)
@@ -27,26 +27,28 @@ constructor embed {path title} {
 }
 
 method _init {} {
-       global M1B
+       global M1B use_ttk NS
 
        if {$is_toplevel} {
-               make_toplevel top w -autodelete 0
+               make_dialog top w -autodelete 0
                wm title $top "[appname] ([reponame]): $t_short"
        } else {
-               frame $w
+               ${NS}::frame $w
        }
 
        set console_cr 1.0
        set w_t $w.m.t
 
-       frame $w.m
-       label $w.m.l1 \
+       ${NS}::frame $w.m
+       ${NS}::label $w.m.l1 \
                -textvariable @t_long  \
                -anchor w \
                -justify left \
                -font font_uibold
        text $w_t \
-               -background white -borderwidth 1 \
+               -background white \
+               -foreground black \
+               -borderwidth 1 \
                -relief sunken \
                -width 80 -height 10 \
                -wrap none \
@@ -76,7 +78,7 @@ method _init {} {
                "
 
        if {$is_toplevel} {
-               button $w.ok -text [mc "Close"] \
+               ${NS}::button $w.ok -text [mc "Close"] \
                        -state disabled \
                        -command [list destroy $w]
                pack $w.ok -side bottom -anchor e -pady 10 -padx 10
@@ -120,7 +122,7 @@ method _read {fd after} {
                        } else {
                                $w_t delete $console_cr end
                                $w_t insert end "\n"
-                               $w_t insert end [string range $buf $c $cr]
+                               $w_t insert end [string range $buf $c [expr {$cr - 1}]]
                                set c $cr
                                incr c
                        }
@@ -180,7 +182,8 @@ method done {ok} {
        if {$ok} {
                if {[winfo exists $w.m.s]} {
                        bind $w.m.s <Destroy> [list delete_this $this]
-                       $w.m.s conf -background green -text [mc "Success"]
+                       $w.m.s conf -background green -foreground black \
+                               -text [mc "Success"]
                        if {$is_toplevel} {
                                $w.ok conf -state normal
                                focus $w.ok
@@ -193,7 +196,8 @@ method done {ok} {
                        _init $this
                }
                bind $w.m.s <Destroy> [list delete_this $this]
-               $w.m.s conf -background red -text [mc "Error: Command Failed"]
+               $w.m.s conf -background red -foreground black \
+                       -text [mc "Error: Command Failed"]
                if {$is_toplevel} {
                        $w.ok conf -state normal
                        focus $w.ok
@@ -202,23 +206,18 @@ method done {ok} {
 }
 
 method _sb_set {sb orient first last} {
-       if {$first == 0 && $last == 1} {
-               if {[winfo exists $sb]} {
-                       destroy $sb
-               }
-               return
-       }
-
+       global NS
        if {![winfo exists $sb]} {
+               if {$first == $last || ($first == 0 && $last == 1)} return
                if {$orient eq {h}} {
-                       scrollbar $sb -orient h -command [list $w_t xview]
+                       ${NS}::scrollbar $sb -orient h -command [list $w_t xview]
                        pack $sb -fill x -side bottom -before $w_t
                } else {
-                       scrollbar $sb -orient v -command [list $w_t yview]
+                       ${NS}::scrollbar $sb -orient v -command [list $w_t yview]
                        pack $sb -fill y -side right -before $w_t
                }
        }
-       catch {$sb set $first $last}
+       $sb set $first $last
 }
 
 }