aboutsummaryrefslogtreecommitdiff
path: root/git-gui/lib
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-11-05 10:41:09 -0700
committerJunio C Hamano <gitster@pobox.com>2010-11-05 10:41:09 -0700
commit06cfa8a8589740b9dd4820ad1c2eff4b3d968de7 (patch)
tree09e78b46f73429b587645de98fef7be3da3d8d68 /git-gui/lib
parent31731b0ea4fccf5455ce367d483feaabdc411e0a (diff)
parent8f85599aba6b569de5c559994704a416f52bc031 (diff)
downloadgit-06cfa8a8589740b9dd4820ad1c2eff4b3d968de7.tar.gz
git-06cfa8a8589740b9dd4820ad1c2eff4b3d968de7.tar.xz
Merge branch 'master' of git://repo.or.cz/git-gui
* 'master' of git://repo.or.cz/git-gui: git-gui: apply color information from git diff output git-gui: use wordprocessor tab style to ensure tabs work as expected git-gui: correct assignment of work-tree git-gui: use full dialog width for old name when renaming branch git-gui: generic version trimming git-gui: enable the Tk console when tracing/debugging on Windows git-gui: show command-line errors in a messagebox on Windows On Windows, avoid git-gui to call Cygwin's nice utility
Diffstat (limited to 'git-gui/lib')
-rw-r--r--git-gui/lib/branch_rename.tcl2
-rw-r--r--git-gui/lib/diff.tcl34
2 files changed, 34 insertions, 2 deletions
diff --git a/git-gui/lib/branch_rename.tcl b/git-gui/lib/branch_rename.tcl
index 63988773b..6e510ec2e 100644
--- a/git-gui/lib/branch_rename.tcl
+++ b/git-gui/lib/branch_rename.tcl
@@ -53,7 +53,7 @@ constructor dialog {} {
return 1
}
- grid $w.rename.oldname_l $w.rename.oldname_m -sticky w -padx {0 5}
+ grid $w.rename.oldname_l $w.rename.oldname_m -sticky we -padx {0 5}
grid $w.rename.newname_l $w.rename.newname_t -sticky we -padx {0 5}
grid columnconfigure $w.rename 1 -weight 1
pack $w.rename -anchor nw -fill x -pady 5 -padx 5
diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index c62875027..dcf0711be 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -294,7 +294,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
}
lappend cmd -p
- lappend cmd --no-color
+ lappend cmd --color
if {$repo_config(gui.diffcontext) >= 1} {
lappend cmd "-U$repo_config(gui.diffcontext)"
}
@@ -332,6 +332,23 @@ proc start_show_diff {cont_info {add_opts {}}} {
fileevent $fd readable [list read_diff $fd $cont_info]
}
+proc parse_color_line {line} {
+ set start 0
+ set result ""
+ set markup [list]
+ set regexp {\033\[((?:\d+;)*\d+)?m}
+ while {[regexp -indices -start $start $regexp $line match code]} {
+ foreach {begin end} $match break
+ append result [string range $line $start [expr {$begin - 1}]]
+ lappend markup [string length $result] \
+ [eval [linsert $code 0 string range $line]]
+ set start [incr end]
+ }
+ append result [string range $line $start end]
+ if {[llength $markup] < 4} {set markup {}}
+ return [list $result $markup]
+}
+
proc read_diff {fd cont_info} {
global ui_diff diff_active is_submodule_diff
global is_3way_diff is_conflict_diff current_diff_header
@@ -340,6 +357,9 @@ proc read_diff {fd cont_info} {
$ui_diff conf -state normal
while {[gets $fd line] >= 0} {
+ foreach {line markup} [parse_color_line $line] break
+ set line [string map {\033 ^} $line]
+
# -- Cleanup uninteresting diff header lines.
#
if {$::current_diff_inheader} {
@@ -434,11 +454,23 @@ proc read_diff {fd cont_info} {
}
}
}
+ set mark [$ui_diff index "end - 1 line linestart"]
$ui_diff insert end $line $tags
if {[string index $line end] eq "\r"} {
$ui_diff tag add d_cr {end - 2c}
}
$ui_diff insert end "\n" $tags
+
+ foreach {posbegin colbegin posend colend} $markup {
+ set prefix clr
+ foreach style [split $colbegin ";"] {
+ if {$style eq "7"} {append prefix i; continue}
+ if {$style < 30 || $style > 47} {continue}
+ set a "$mark linestart + $posbegin chars"
+ set b "$mark linestart + $posend chars"
+ catch {$ui_diff tag add $prefix$style $a $b}
+ }
+ }
}
$ui_diff conf -state disabled