* [PATCH] gitk: let you easily specify lines of context in diff view
@ 2007-07-26 7:59 Steffen Prohaska
2007-07-26 12:34 ` Paul Mackerras
0 siblings, 1 reply; 10+ messages in thread
From: Steffen Prohaska @ 2007-07-26 7:59 UTC (permalink / raw
To: git, paulus; +Cc: Steffen Prohaska
More lines of context sometimes help to better understand a diff.
This patch introduces a text field above the box displaying the
blobdiffs. You can type in the number of lines of context that
you wish to view.
Minor improvements are needed:
* The value you type in is only used on the next update.
* lines of context is initially always 3.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
gitk | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
The patch may need some polishing. I know some tcl but this is the
first time I tried tk:
* I initialized diffcontext globally, ok?
* I don't know how to update the view after entering a new value.
Steffen
diff --git a/gitk b/gitk
index 39e452a..4e9acff 100755
--- a/gitk
+++ b/gitk
@@ -500,6 +500,7 @@ proc makewindow {} {
global textfont mainfont uifont tabstop
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
+ global diffcontextstring
global maincursor textcursor curtextcursor
global rowctxmenu fakerowmenu mergemax wrapcomment
global highlight_files gdttype
@@ -714,7 +715,12 @@ proc makewindow {} {
-command changediffdisp -variable diffelide -value {0 1}
radiobutton .bleft.mid.new -text "New version" \
-command changediffdisp -variable diffelide -value {1 0}
- pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
+ label .bleft.mid.labeldiffcontext -text " Lines of context: " \
+ -font $uifont
+ entry .bleft.mid.diffcontext -width 5 -font $textfont -textvariable diffcontextstring
+ trace add variable diffcontextstring write diffcontextchange
+ lappend entries .bleft.mid.diffcontext
+ pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
set ctext .bleft.ctext
text $ctext -background $bgcolor -foreground $fgcolor \
-tabs "[expr {$tabstop * $charspc}]" \
@@ -4872,12 +4878,25 @@ proc gettreediffline {gdtf ids} {
return 0
}
+proc diffcontextchange {n1 n2 op} {
+ global diffcontextstring diffcontext
+
+ if {[string is integer $diffcontextstring]} {
+ if {$diffcontextstring > 0} {
+ set diffcontext $diffcontextstring
+# TODO: need to trigger update of diff display
+# tried dodiffindex but that corrupted the history view
+ }
+ }
+}
+
proc getblobdiffs {ids} {
global diffopts blobdifffd diffids env
global diffinhdr treediffs
+ global diffcontext
set env(GIT_DIFF_OPTS) $diffopts
- if {[catch {set bdf [open [diffcmd $ids {-p -C}] r]} err]} {
+ if {[catch {set bdf [open [diffcmd $ids "-p -C -U$diffcontext"] r]} err]} {
puts "error getting diffs: $err"
return
}
@@ -7537,6 +7556,8 @@ set markingmatches 0
set optim_delay 16
+set diffcontext 3
+
set nextviewnum 1
set curview 0
set selectedview 0
--
1.5.3.rc3.20.g06b4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] gitk: let you easily specify lines of context in diff view
2007-07-26 7:59 [PATCH] gitk: let you easily specify lines of context in diff view Steffen Prohaska
@ 2007-07-26 12:34 ` Paul Mackerras
2007-07-27 5:52 ` Steffen Prohaska
0 siblings, 1 reply; 10+ messages in thread
From: Paul Mackerras @ 2007-07-26 12:34 UTC (permalink / raw
To: Steffen Prohaska; +Cc: git
Steffen Prohaska writes:
> More lines of context sometimes help to better understand a diff.
> This patch introduces a text field above the box displaying the
> blobdiffs. You can type in the number of lines of context that
> you wish to view.
Nice idea! I suggest you use a spinbox instead of an entry though,
since that has up and down buttons, and allows you to restrict the
value to an integer.
> * I don't know how to update the view after entering a new value.
You can put a trace on the associated variable and specify a function
to be called when the variable's value changes. Grep for "trace add
variable" in gitk to see how it's done.
Paul.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gitk: let you easily specify lines of context in diff view
2007-07-26 12:34 ` Paul Mackerras
@ 2007-07-27 5:52 ` Steffen Prohaska
2007-07-27 10:31 ` Paul Mackerras
0 siblings, 1 reply; 10+ messages in thread
From: Steffen Prohaska @ 2007-07-27 5:52 UTC (permalink / raw
To: Paul Mackerras; +Cc: git
On Jul 26, 2007, at 2:34 PM, Paul Mackerras wrote:
> Steffen Prohaska writes:
>
>> More lines of context sometimes help to better understand a diff.
>> This patch introduces a text field above the box displaying the
>> blobdiffs. You can type in the number of lines of context that
>> you wish to view.
>
> Nice idea! I suggest you use a spinbox instead of an entry though,
> since that has up and down buttons, and allows you to restrict the
> value to an integer.
Thanks. Will try that.
>> * I don't know how to update the view after entering a new value.
>
> You can put a trace on the associated variable and specify a function
> to be called when the variable's value changes. Grep for "trace add
> variable" in gitk to see how it's done.
This is already included in the patch but I don't know which of gtk's
procs to call to update the view. gitk would need to execute git diff
and update the text box in the bottom left. I tried 'dodiffindex'
but this causes corruptions of the history view.
Steffen
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gitk: let you easily specify lines of context in diff view
2007-07-27 5:52 ` Steffen Prohaska
@ 2007-07-27 10:31 ` Paul Mackerras
2007-07-27 11:44 ` [PATCH v2] " Steffen Prohaska
0 siblings, 1 reply; 10+ messages in thread
From: Paul Mackerras @ 2007-07-27 10:31 UTC (permalink / raw
To: Steffen Prohaska; +Cc: git
Steffen Prohaska writes:
> This is already included in the patch but I don't know which of gtk's
> procs to call to update the view. gitk would need to execute git diff
> and update the text box in the bottom left. I tried 'dodiffindex'
> but this causes corruptions of the history view.
reselectline should do what you want.
Paul.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] gitk: let you easily specify lines of context in diff view
2007-07-27 10:31 ` Paul Mackerras
@ 2007-07-27 11:44 ` Steffen Prohaska
2007-07-28 19:18 ` [PATCH v3] " Steffen Prohaska
0 siblings, 1 reply; 10+ messages in thread
From: Steffen Prohaska @ 2007-07-27 11:44 UTC (permalink / raw
To: paulus; +Cc: git, Steffen Prohaska
More lines of context sometimes help to better understand a diff.
This patch introduces a text field above the box displaying the
blobdiffs. You can type in the number of lines of context that
you wish to view. The number of lins ines of context is initially
always set to 3.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
gitk | 41 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 39 insertions(+), 2 deletions(-)
I included the changes proposed by Paul. From my side, the patch
is ready to be applied.
Steffen
diff --git a/gitk b/gitk
index 39e452a..9de9574 100755
--- a/gitk
+++ b/gitk
@@ -500,6 +500,7 @@ proc makewindow {} {
global textfont mainfont uifont tabstop
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
+ global diffcontextstring diffcontext
global maincursor textcursor curtextcursor
global rowctxmenu fakerowmenu mergemax wrapcomment
global highlight_files gdttype
@@ -714,7 +715,16 @@ proc makewindow {} {
-command changediffdisp -variable diffelide -value {0 1}
radiobutton .bleft.mid.new -text "New version" \
-command changediffdisp -variable diffelide -value {1 0}
- pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
+ label .bleft.mid.labeldiffcontext -text " Lines of context: " \
+ -font $uifont
+ spinbox .bleft.mid.diffcontext -width 5 -font $textfont \
+ -from 1 -increment 1 -to 10000000 \
+ -validate all -validatecommand "diffcontextvalidate %P" \
+ -textvariable diffcontextstring
+ .bleft.mid.diffcontext set $diffcontext
+ trace add variable diffcontextstring write diffcontextchange
+ lappend entries .bleft.mid.diffcontext
+ pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
set ctext .bleft.ctext
text $ctext -background $bgcolor -foreground $fgcolor \
-tabs "[expr {$tabstop * $charspc}]" \
@@ -4872,12 +4882,37 @@ proc gettreediffline {gdtf ids} {
return 0
}
+# empty strings or integers accepted
+proc diffcontextvalidate {v} {
+ if {[string length $v] == 0} {
+ return 1
+ }
+ if {[string is integer $v]} {
+ if {$v > 0} {
+ return 1
+ }
+ }
+ return 0
+}
+
+proc diffcontextchange {n1 n2 op} {
+ global diffcontextstring diffcontext
+
+ if {[string is integer $diffcontextstring]} {
+ if {$diffcontextstring > 0} {
+ set diffcontext $diffcontextstring
+ reselectline
+ }
+ }
+}
+
proc getblobdiffs {ids} {
global diffopts blobdifffd diffids env
global diffinhdr treediffs
+ global diffcontext
set env(GIT_DIFF_OPTS) $diffopts
- if {[catch {set bdf [open [diffcmd $ids {-p -C}] r]} err]} {
+ if {[catch {set bdf [open [diffcmd $ids "-p -C -U$diffcontext"] r]} err]} {
puts "error getting diffs: $err"
return
}
@@ -7537,6 +7572,8 @@ set markingmatches 0
set optim_delay 16
+set diffcontext 3
+
set nextviewnum 1
set curview 0
set selectedview 0
--
1.5.3.rc3.21.g45610
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3] gitk: let you easily specify lines of context in diff view
2007-07-27 11:44 ` [PATCH v2] " Steffen Prohaska
@ 2007-07-28 19:18 ` Steffen Prohaska
2007-08-11 15:30 ` [PATCH v4, ping] " Steffen Prohaska
0 siblings, 1 reply; 10+ messages in thread
From: Steffen Prohaska @ 2007-07-28 19:18 UTC (permalink / raw
To: paulus; +Cc: git, Steffen Prohaska
More lines of context sometimes help to better understand a diff.
This patch introduces a text field above the box displaying the
blobdiffs. You can type in the number of lines of context that
you wish to view. The number of lines of context is initially
always set to 3.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
gitk | 41 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 39 insertions(+), 2 deletions(-)
rebased to the current master.
Steffen
diff --git a/gitk b/gitk
index f74ce51..670a162 100755
--- a/gitk
+++ b/gitk
@@ -517,6 +517,7 @@ proc makewindow {} {
global textfont mainfont uifont tabstop
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
+ global diffcontextstring diffcontext
global maincursor textcursor curtextcursor
global rowctxmenu fakerowmenu mergemax wrapcomment
global highlight_files gdttype
@@ -731,7 +732,16 @@ proc makewindow {} {
-command changediffdisp -variable diffelide -value {0 1}
radiobutton .bleft.mid.new -text "New version" \
-command changediffdisp -variable diffelide -value {1 0}
- pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
+ label .bleft.mid.labeldiffcontext -text " Lines of context: " \
+ -font $uifont
+ spinbox .bleft.mid.diffcontext -width 5 -font $textfont \
+ -from 1 -increment 1 -to 10000000 \
+ -validate all -validatecommand "diffcontextvalidate %P" \
+ -textvariable diffcontextstring
+ .bleft.mid.diffcontext set $diffcontext
+ trace add variable diffcontextstring write diffcontextchange
+ lappend entries .bleft.mid.diffcontext
+ pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
set ctext .bleft.ctext
text $ctext -background $bgcolor -foreground $fgcolor \
-tabs "[expr {$tabstop * $charspc}]" \
@@ -4985,12 +4995,37 @@ proc gettreediffline {gdtf ids} {
return 0
}
+# empty strings or integers accepted
+proc diffcontextvalidate {v} {
+ if {[string length $v] == 0} {
+ return 1
+ }
+ if {[string is integer $v]} {
+ if {$v > 0} {
+ return 1
+ }
+ }
+ return 0
+}
+
+proc diffcontextchange {n1 n2 op} {
+ global diffcontextstring diffcontext
+
+ if {[string is integer $diffcontextstring]} {
+ if {$diffcontextstring > 0} {
+ set diffcontext $diffcontextstring
+ reselectline
+ }
+ }
+}
+
proc getblobdiffs {ids} {
global diffopts blobdifffd diffids env
global diffinhdr treediffs
+ global diffcontext
set env(GIT_DIFF_OPTS) $diffopts
- if {[catch {set bdf [open [diffcmd $ids {-p -C --no-commit-id}] r]} err]} {
+ if {[catch {set bdf [open [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"] r]} err]} {
puts "error getting diffs: $err"
return
}
@@ -7646,6 +7681,8 @@ set markingmatches 0
set optim_delay 16
+set diffcontext 3
+
set nextviewnum 1
set curview 0
set selectedview 0
--
1.5.3.rc3.45.g4c741
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4, ping] gitk: let you easily specify lines of context in diff view
2007-07-28 19:18 ` [PATCH v3] " Steffen Prohaska
@ 2007-08-11 15:30 ` Steffen Prohaska
2007-08-12 3:17 ` Paul Mackerras
0 siblings, 1 reply; 10+ messages in thread
From: Steffen Prohaska @ 2007-08-11 15:30 UTC (permalink / raw
To: paulus; +Cc: gitster, git, Steffen Prohaska
More lines of context sometimes help to better understand a diff.
This patch introduces a text field above the box displaying the
blobdiffs. You can type in the number of lines of context that
you wish to view. The number of lines of context is initially
always set to 3.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
gitk | 41 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 39 insertions(+), 2 deletions(-)
rebased to the current master, fixed one trailing whitespace.
Any chance to get this patch applied? It works for me.
Steffen
diff --git a/gitk b/gitk
index f74ce51..2f86c7c 100755
--- a/gitk
+++ b/gitk
@@ -517,6 +517,7 @@ proc makewindow {} {
global textfont mainfont uifont tabstop
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
+ global diffcontextstring diffcontext
global maincursor textcursor curtextcursor
global rowctxmenu fakerowmenu mergemax wrapcomment
global highlight_files gdttype
@@ -731,7 +732,16 @@ proc makewindow {} {
-command changediffdisp -variable diffelide -value {0 1}
radiobutton .bleft.mid.new -text "New version" \
-command changediffdisp -variable diffelide -value {1 0}
- pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
+ label .bleft.mid.labeldiffcontext -text " Lines of context: " \
+ -font $uifont
+ spinbox .bleft.mid.diffcontext -width 5 -font $textfont \
+ -from 1 -increment 1 -to 10000000 \
+ -validate all -validatecommand "diffcontextvalidate %P" \
+ -textvariable diffcontextstring
+ .bleft.mid.diffcontext set $diffcontext
+ trace add variable diffcontextstring write diffcontextchange
+ lappend entries .bleft.mid.diffcontext
+ pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
set ctext .bleft.ctext
text $ctext -background $bgcolor -foreground $fgcolor \
-tabs "[expr {$tabstop * $charspc}]" \
@@ -4985,12 +4995,37 @@ proc gettreediffline {gdtf ids} {
return 0
}
+# empty strings or integers accepted
+proc diffcontextvalidate {v} {
+ if {[string length $v] == 0} {
+ return 1
+ }
+ if {[string is integer $v]} {
+ if {$v > 0} {
+ return 1
+ }
+ }
+ return 0
+}
+
+proc diffcontextchange {n1 n2 op} {
+ global diffcontextstring diffcontext
+
+ if {[string is integer $diffcontextstring]} {
+ if {$diffcontextstring > 0} {
+ set diffcontext $diffcontextstring
+ reselectline
+ }
+ }
+}
+
proc getblobdiffs {ids} {
global diffopts blobdifffd diffids env
global diffinhdr treediffs
+ global diffcontext
set env(GIT_DIFF_OPTS) $diffopts
- if {[catch {set bdf [open [diffcmd $ids {-p -C --no-commit-id}] r]} err]} {
+ if {[catch {set bdf [open [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"] r]} err]} {
puts "error getting diffs: $err"
return
}
@@ -7646,6 +7681,8 @@ set markingmatches 0
set optim_delay 16
+set diffcontext 3
+
set nextviewnum 1
set curview 0
set selectedview 0
--
1.5.3.rc4.31.g6adda
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4, ping] gitk: let you easily specify lines of context in diff view
2007-08-11 15:30 ` [PATCH v4, ping] " Steffen Prohaska
@ 2007-08-12 3:17 ` Paul Mackerras
2007-08-12 10:02 ` Steffen Prohaska
0 siblings, 1 reply; 10+ messages in thread
From: Paul Mackerras @ 2007-08-12 3:17 UTC (permalink / raw
To: Steffen Prohaska; +Cc: gitster, git
Steffen Prohaska writes:
> Any chance to get this patch applied? It works for me.
Some comments:
> @@ -731,7 +732,16 @@ proc makewindow {} {
> -command changediffdisp -variable diffelide -value {0 1}
> radiobutton .bleft.mid.new -text "New version" \
> -command changediffdisp -variable diffelide -value {1 0}
> - pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
Just add another pack command rather than extending this one.
> + label .bleft.mid.labeldiffcontext -text " Lines of context: " \
> + -font $uifont
This is hard to read because the continuation line isn't indented
further that the first line. Please indent continuation lines by an
extra 4 spaces.
> +# empty strings or integers accepted
> +proc diffcontextvalidate {v} {
> + if {[string length $v] == 0} {
> + return 1
> + }
> + if {[string is integer $v]} {
> + if {$v > 0} {
> + return 1
> + }
> + }
> + return 0
> +}
"string is integer" will already accept the null string and return 1.
> +proc diffcontextchange {n1 n2 op} {
> + global diffcontextstring diffcontext
> +
> + if {[string is integer $diffcontextstring]} {
> + if {$diffcontextstring > 0} {
Once again, "string is integer" returning 1 doesn't guarantee the
string is non-empty. Use "string is integer -strict" if you want
that.
> + set diffcontext $diffcontextstring
> + reselectline
Inconsistent indentation.
> +set diffcontext 3
> +
It would be nice to save diffcontext in the ~/.gitkrc.
Paul.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4, ping] gitk: let you easily specify lines of context in diff view
2007-08-12 3:17 ` Paul Mackerras
@ 2007-08-12 10:02 ` Steffen Prohaska
2007-08-12 10:05 ` [PATCH v5] " Steffen Prohaska
0 siblings, 1 reply; 10+ messages in thread
From: Steffen Prohaska @ 2007-08-12 10:02 UTC (permalink / raw
To: Paul Mackerras; +Cc: gitster, git
On Aug 12, 2007, at 5:17 AM, Paul Mackerras wrote:
> Steffen Prohaska writes:
>
>> Any chance to get this patch applied? It works for me.
>
> Some comments:
>
>> @@ -731,7 +732,16 @@ proc makewindow {} {
>> -command changediffdisp -variable diffelide -value {0 1}
>> radiobutton .bleft.mid.new -text "New version" \
>> -command changediffdisp -variable diffelide -value {1 0}
>> - pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
>
> Just add another pack command rather than extending this one.
Thanks. Didn't understand what pack does and thought it might be
needed to pack all at once into a 'single' pack.
>> + label .bleft.mid.labeldiffcontext -text " Lines of
>> context: " \
>> + -font $uifont
>
> This is hard to read because the continuation line isn't indented
> further that the first line. Please indent continuation lines by an
> extra 4 spaces.
I fixed more of them. I typically work with a no-tab rule. Hope I
spotted all other places with wrong indent, too.
>> +# empty strings or integers accepted
>> +proc diffcontextvalidate {v} {
>> + if {[string length $v] == 0} {
>> + return 1
>> + }
>> + if {[string is integer $v]} {
>> + if {$v > 0} {
>> + return 1
>> + }
>> + }
>> + return 0
>> +}
>
> "string is integer" will already accept the null string and return 1.
replaced this by a regexp.
>> +proc diffcontextchange {n1 n2 op} {
>> + global diffcontextstring diffcontext
>> +
>> + if {[string is integer $diffcontextstring]} {
>> + if {$diffcontextstring > 0} {
>
> Once again, "string is integer" returning 1 doesn't guarantee the
> string is non-empty. Use "string is integer -strict" if you want
> that.
Ah, thanks, didn't know that.
>> + set diffcontext $diffcontextstring
>> + reselectline
>
> Inconsistent indentation.
ok.
>> +set diffcontext 3
>> +
>
> It would be nice to save diffcontext in the ~/.gitkrc.
done.
Will send a patch in a minute.
Steffen
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5] gitk: let you easily specify lines of context in diff view
2007-08-12 10:02 ` Steffen Prohaska
@ 2007-08-12 10:05 ` Steffen Prohaska
0 siblings, 0 replies; 10+ messages in thread
From: Steffen Prohaska @ 2007-08-12 10:05 UTC (permalink / raw
To: paulus; +Cc: git, gitster, Steffen Prohaska
More lines of context sometimes help to better understand a diff.
This patch introduces a text field above the box displaying the
blobdiffs. You can type in the number of lines of context that
you wish to view. The number of lines of context is saved to
~/.gitk.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
gitk | 34 ++++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 1103baf..4366c7f 100755
--- a/gitk
+++ b/gitk
@@ -517,6 +517,7 @@ proc makewindow {} {
global textfont mainfont uifont tabstop
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
+ global diffcontextstring diffcontext
global maincursor textcursor curtextcursor
global rowctxmenu fakerowmenu mergemax wrapcomment
global highlight_files gdttype
@@ -731,7 +732,17 @@ proc makewindow {} {
-command changediffdisp -variable diffelide -value {0 1}
radiobutton .bleft.mid.new -text "New version" \
-command changediffdisp -variable diffelide -value {1 0}
+ label .bleft.mid.labeldiffcontext -text " Lines of context: " \
+ -font $uifont
pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
+ spinbox .bleft.mid.diffcontext -width 5 -font $textfont \
+ -from 1 -increment 1 -to 10000000 \
+ -validate all -validatecommand "diffcontextvalidate %P" \
+ -textvariable diffcontextstring
+ .bleft.mid.diffcontext set $diffcontext
+ trace add variable diffcontextstring write diffcontextchange
+ lappend entries .bleft.mid.diffcontext
+ pack .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
set ctext .bleft.ctext
text $ctext -background $bgcolor -foreground $fgcolor \
-tabs "[expr {$tabstop * $charspc}]" \
@@ -968,7 +979,7 @@ proc savestuff {w} {
global maxwidth showneartags showlocalchanges
global viewname viewfiles viewargs viewperm nextviewnum
global cmitmode wrapcomment
- global colors bgcolor fgcolor diffcolors selectbgcolor
+ global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor
if {$stuffsaved} return
if {![winfo viewable .]} return
@@ -989,6 +1000,7 @@ proc savestuff {w} {
puts $f [list set fgcolor $fgcolor]
puts $f [list set colors $colors]
puts $f [list set diffcolors $diffcolors]
+ puts $f [list set diffcontext $diffcontext]
puts $f [list set selectbgcolor $selectbgcolor]
puts $f "set geometry(main) [wm geometry .]"
@@ -4986,12 +4998,29 @@ proc gettreediffline {gdtf ids} {
return 0
}
+# empty string or positive integer
+proc diffcontextvalidate {v} {
+ return [regexp {^(|[1-9][0-9]*)$} $v]
+}
+
+proc diffcontextchange {n1 n2 op} {
+ global diffcontextstring diffcontext
+
+ if {[string is integer -strict $diffcontextstring]} {
+ if {$diffcontextstring > 0} {
+ set diffcontext $diffcontextstring
+ reselectline
+ }
+ }
+}
+
proc getblobdiffs {ids} {
global diffopts blobdifffd diffids env
global diffinhdr treediffs
+ global diffcontext
set env(GIT_DIFF_OPTS) $diffopts
- if {[catch {set bdf [open [diffcmd $ids {-p -C --no-commit-id}] r]} err]} {
+ if {[catch {set bdf [open [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"] r]} err]} {
puts "error getting diffs: $err"
return
}
@@ -7569,6 +7598,7 @@ set colors {green red blue magenta darkgrey brown orange}
set bgcolor white
set fgcolor black
set diffcolors {red "#00a000" blue}
+set diffcontext 3
set selectbgcolor gray85
catch {source ~/.gitk}
--
1.5.3.rc4.762.g17d7
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-08-12 10:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-26 7:59 [PATCH] gitk: let you easily specify lines of context in diff view Steffen Prohaska
2007-07-26 12:34 ` Paul Mackerras
2007-07-27 5:52 ` Steffen Prohaska
2007-07-27 10:31 ` Paul Mackerras
2007-07-27 11:44 ` [PATCH v2] " Steffen Prohaska
2007-07-28 19:18 ` [PATCH v3] " Steffen Prohaska
2007-08-11 15:30 ` [PATCH v4, ping] " Steffen Prohaska
2007-08-12 3:17 ` Paul Mackerras
2007-08-12 10:02 ` Steffen Prohaska
2007-08-12 10:05 ` [PATCH v5] " Steffen Prohaska
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).