{"thread":{"id":"9238","subject":"[PATCH] gitk: let you easily specify lines of context in diff view","startedAt":"2007-07-26T07:59:29Z","lastAt":"2007-08-12T10:05:46Z","messageCount":10,"participants":["Steffen Prohaska","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"48676","messageId":"11854367692095-git-send-email-prohaska@zib.de","threadId":"9238","inReplyTo":null,"subject":"[PATCH] gitk: let you easily specify lines of context in diff view","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-07-26T07:59:29Z","receivedAt":"2007-07-26T07:59:29Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"More lines of context sometimes help to better understand a diff.\nThis patch introduces a text field above the box displaying the\nblobdiffs. You can type in the number of lines of context that\nyou wish to view.\n\nMinor improvements are needed:\n   * The value you type in is only used on the next update.\n   * lines of context is initially always 3.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n gitk |   25 +++++++++++++++++++++++--\n 1 files changed, 23 insertions(+), 2 deletions(-)\n\nThe patch may need some polishing. I know some tcl but this is the \nfirst time I tried tk:\n   * I initialized diffcontext globally, ok?\n   * I don't know how to update the view after entering a new value. \n  \n    Steffen\n\ndiff --git a/gitk b/gitk\nindex 39e452a..4e9acff 100755\n--- a/gitk\n+++ b/gitk\n@@ -500,6 +500,7 @@ proc makewindow {} {\n     global textfont mainfont uifont tabstop\n     global findtype findtypemenu findloc findstring fstring geometry\n     global entries sha1entry sha1string sha1but\n+    global diffcontextstring\n     global maincursor textcursor curtextcursor\n     global rowctxmenu fakerowmenu mergemax wrapcomment\n     global highlight_files gdttype\n@@ -714,7 +715,12 @@ proc makewindow {} {\n \t-command changediffdisp -variable diffelide -value {0 1}\n     radiobutton .bleft.mid.new -text \"New version\" \\\n \t-command changediffdisp -variable diffelide -value {1 0}\n-    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left\n+    label .bleft.mid.labeldiffcontext -text \"      Lines of context: \" \\\n+    -font $uifont\n+    entry .bleft.mid.diffcontext -width 5 -font $textfont -textvariable diffcontextstring\n+    trace add variable diffcontextstring write diffcontextchange\n+    lappend entries .bleft.mid.diffcontext\n+    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left\n     set ctext .bleft.ctext\n     text $ctext -background $bgcolor -foreground $fgcolor \\\n \t-tabs \"[expr {$tabstop * $charspc}]\" \\\n@@ -4872,12 +4878,25 @@ proc gettreediffline {gdtf ids} {\n     return 0\n }\n \n+proc diffcontextchange {n1 n2 op} {\n+    global diffcontextstring diffcontext\n+\n+    if {[string is integer $diffcontextstring]} {\n+        if {$diffcontextstring > 0} {\n+            set diffcontext $diffcontextstring\n+# TODO: need to trigger update of diff display\n+# tried dodiffindex but that corrupted the history view\n+        }\n+    }\n+}\n+\n proc getblobdiffs {ids} {\n     global diffopts blobdifffd diffids env\n     global diffinhdr treediffs\n+    global diffcontext\n \n     set env(GIT_DIFF_OPTS) $diffopts\n-    if {[catch {set bdf [open [diffcmd $ids {-p -C}] r]} err]} {\n+    if {[catch {set bdf [open [diffcmd $ids \"-p -C -U$diffcontext\"] r]} err]} {\n \tputs \"error getting diffs: $err\"\n \treturn\n     }\n@@ -7537,6 +7556,8 @@ set markingmatches 0\n \n set optim_delay 16\n \n+set diffcontext 3 \n+\n set nextviewnum 1\n set curview 0\n set selectedview 0\n-- \n1.5.3.rc3.20.g06b4\n"},{"id":"48744","messageId":"18088.38093.876993.410483@cargo.ozlabs.ibm.com","threadId":"9238","inReplyTo":"11854367692095-git-send-email-prohaska@zib.de","subject":"Re: [PATCH] gitk: let you easily specify lines of context in diff view","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2007-07-26T12:34:21Z","receivedAt":"2007-07-26T12:34:21Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Steffen Prohaska writes:\n\n> More lines of context sometimes help to better understand a diff.\n> This patch introduces a text field above the box displaying the\n> blobdiffs. You can type in the number of lines of context that\n> you wish to view.\n\nNice idea!  I suggest you use a spinbox instead of an entry though,\nsince that has up and down buttons, and allows you to restrict the\nvalue to an integer.\n\n>    * I don't know how to update the view after entering a new value. \n\nYou can put a trace on the associated variable and specify a function\nto be called when the variable's value changes.  Grep for \"trace add\nvariable\" in gitk to see how it's done.\n\nPaul.\n"},{"id":"48771","messageId":"6EA8D0EC-6E64-4F0E-BEDB-A8C5C91AAB53@zib.de","threadId":"9238","inReplyTo":"18088.38093.876993.410483@cargo.ozlabs.ibm.com","subject":"Re: [PATCH] gitk: let you easily specify lines of context in diff view","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-07-27T05:52:28Z","receivedAt":"2007-07-27T05:52:28Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jul 26, 2007, at 2:34 PM, Paul Mackerras wrote:\n\n> Steffen Prohaska writes:\n>\n>> More lines of context sometimes help to better understand a diff.\n>> This patch introduces a text field above the box displaying the\n>> blobdiffs. You can type in the number of lines of context that\n>> you wish to view.\n>\n> Nice idea!  I suggest you use a spinbox instead of an entry though,\n> since that has up and down buttons, and allows you to restrict the\n> value to an integer.\n\nThanks. Will try that.\n\n\n>>    * I don't know how to update the view after entering a new value.\n>\n> You can put a trace on the associated variable and specify a function\n> to be called when the variable's value changes.  Grep for \"trace add\n> variable\" in gitk to see how it's done.\n\nThis is already included in the patch but I don't know which of gtk's\nprocs to call to update the view. gitk would need to execute git diff\nand update the text box in the bottom left. I tried 'dodiffindex'\nbut this causes corruptions of the history view.\n\n\tSteffen\n"},{"id":"48784","messageId":"18089.51584.704957.310331@cargo.ozlabs.ibm.com","threadId":"9238","inReplyTo":"6EA8D0EC-6E64-4F0E-BEDB-A8C5C91AAB53@zib.de","subject":"Re: [PATCH] gitk: let you easily specify lines of context in diff view","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2007-07-27T10:31:28Z","receivedAt":"2007-07-27T10:31:28Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Steffen Prohaska writes:\n\n> This is already included in the patch but I don't know which of gtk's\n> procs to call to update the view. gitk would need to execute git diff\n> and update the text box in the bottom left. I tried 'dodiffindex'\n> but this causes corruptions of the history view.\n\nreselectline should do what you want.\n\nPaul.\n"},{"id":"48791","messageId":"11855366703782-git-send-email-prohaska@zib.de","threadId":"9238","inReplyTo":"18089.51584.704957.310331@cargo.ozlabs.ibm.com","subject":"[PATCH v2] gitk: let you easily specify lines of context in diff view","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-07-27T11:44:30Z","receivedAt":"2007-07-27T11:44:30Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"More lines of context sometimes help to better understand a diff.\nThis patch introduces a text field above the box displaying the\nblobdiffs. You can type in the number of lines of context that\nyou wish to view. The number of lins ines of context is initially\nalways set to 3.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n gitk |   41 +++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 39 insertions(+), 2 deletions(-)\n\nI included the changes proposed by Paul. From my side, the patch\nis ready to be applied.\n\n    Steffen\n\ndiff --git a/gitk b/gitk\nindex 39e452a..9de9574 100755\n--- a/gitk\n+++ b/gitk\n@@ -500,6 +500,7 @@ proc makewindow {} {\n     global textfont mainfont uifont tabstop\n     global findtype findtypemenu findloc findstring fstring geometry\n     global entries sha1entry sha1string sha1but\n+    global diffcontextstring diffcontext\n     global maincursor textcursor curtextcursor\n     global rowctxmenu fakerowmenu mergemax wrapcomment\n     global highlight_files gdttype\n@@ -714,7 +715,16 @@ proc makewindow {} {\n \t-command changediffdisp -variable diffelide -value {0 1}\n     radiobutton .bleft.mid.new -text \"New version\" \\\n \t-command changediffdisp -variable diffelide -value {1 0}\n-    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left\n+    label .bleft.mid.labeldiffcontext -text \"      Lines of context: \" \\\n+    -font $uifont\n+    spinbox .bleft.mid.diffcontext -width 5 -font $textfont \\\n+    -from 1 -increment 1 -to 10000000 \\\n+    -validate all -validatecommand \"diffcontextvalidate %P\" \\\n+    -textvariable diffcontextstring\n+    .bleft.mid.diffcontext set $diffcontext\n+    trace add variable diffcontextstring write diffcontextchange\n+    lappend entries .bleft.mid.diffcontext\n+    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left\n     set ctext .bleft.ctext\n     text $ctext -background $bgcolor -foreground $fgcolor \\\n \t-tabs \"[expr {$tabstop * $charspc}]\" \\\n@@ -4872,12 +4882,37 @@ proc gettreediffline {gdtf ids} {\n     return 0\n }\n \n+# empty strings or integers accepted\n+proc diffcontextvalidate {v} {\n+    if {[string length $v] == 0} {\n+\treturn 1\n+    }\n+    if {[string is integer $v]} {\n+\tif {$v > 0} {\n+\t    return 1\n+\t}\n+    }\n+    return 0\n+}\n+\n+proc diffcontextchange {n1 n2 op} {\n+    global diffcontextstring diffcontext\n+\n+    if {[string is integer $diffcontextstring]} {\n+        if {$diffcontextstring > 0} {\n+            set diffcontext $diffcontextstring\n+\t\t    reselectline\n+        }\n+    }\n+}\n+\n proc getblobdiffs {ids} {\n     global diffopts blobdifffd diffids env\n     global diffinhdr treediffs\n+    global diffcontext\n \n     set env(GIT_DIFF_OPTS) $diffopts\n-    if {[catch {set bdf [open [diffcmd $ids {-p -C}] r]} err]} {\n+    if {[catch {set bdf [open [diffcmd $ids \"-p -C -U$diffcontext\"] r]} err]} {\n \tputs \"error getting diffs: $err\"\n \treturn\n     }\n@@ -7537,6 +7572,8 @@ set markingmatches 0\n \n set optim_delay 16\n \n+set diffcontext 3 \n+\n set nextviewnum 1\n set curview 0\n set selectedview 0\n-- \n1.5.3.rc3.21.g45610\n"},{"id":"48921","messageId":"11856503182381-git-send-email-prohaska@zib.de","threadId":"9238","inReplyTo":"11855366703782-git-send-email-prohaska@zib.de","subject":"[PATCH v3] gitk: let you easily specify lines of context in diff view","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-07-28T19:18:38Z","receivedAt":"2007-07-28T19:18:38Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"More lines of context sometimes help to better understand a diff.\nThis patch introduces a text field above the box displaying the\nblobdiffs. You can type in the number of lines of context that\nyou wish to view. The number of lines of context is initially\nalways set to 3.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n gitk |   41 +++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 39 insertions(+), 2 deletions(-)\n\nrebased to the current master.\n\n    Steffen\n\ndiff --git a/gitk b/gitk\nindex f74ce51..670a162 100755\n--- a/gitk\n+++ b/gitk\n@@ -517,6 +517,7 @@ proc makewindow {} {\n     global textfont mainfont uifont tabstop\n     global findtype findtypemenu findloc findstring fstring geometry\n     global entries sha1entry sha1string sha1but\n+    global diffcontextstring diffcontext\n     global maincursor textcursor curtextcursor\n     global rowctxmenu fakerowmenu mergemax wrapcomment\n     global highlight_files gdttype\n@@ -731,7 +732,16 @@ proc makewindow {} {\n \t-command changediffdisp -variable diffelide -value {0 1}\n     radiobutton .bleft.mid.new -text \"New version\" \\\n \t-command changediffdisp -variable diffelide -value {1 0}\n-    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left\n+    label .bleft.mid.labeldiffcontext -text \"      Lines of context: \" \\\n+    -font $uifont\n+    spinbox .bleft.mid.diffcontext -width 5 -font $textfont \\\n+    -from 1 -increment 1 -to 10000000 \\\n+    -validate all -validatecommand \"diffcontextvalidate %P\" \\\n+    -textvariable diffcontextstring\n+    .bleft.mid.diffcontext set $diffcontext\n+    trace add variable diffcontextstring write diffcontextchange\n+    lappend entries .bleft.mid.diffcontext\n+    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left\n     set ctext .bleft.ctext\n     text $ctext -background $bgcolor -foreground $fgcolor \\\n \t-tabs \"[expr {$tabstop * $charspc}]\" \\\n@@ -4985,12 +4995,37 @@ proc gettreediffline {gdtf ids} {\n     return 0\n }\n \n+# empty strings or integers accepted\n+proc diffcontextvalidate {v} {\n+    if {[string length $v] == 0} {\n+\treturn 1\n+    }\n+    if {[string is integer $v]} {\n+\tif {$v > 0} {\n+\t    return 1\n+\t}\n+    }\n+    return 0\n+}\n+\n+proc diffcontextchange {n1 n2 op} {\n+    global diffcontextstring diffcontext\n+\n+    if {[string is integer $diffcontextstring]} {\n+        if {$diffcontextstring > 0} {\n+            set diffcontext $diffcontextstring\n+\t\t    reselectline\n+        }\n+    }\n+}\n+\n proc getblobdiffs {ids} {\n     global diffopts blobdifffd diffids env\n     global diffinhdr treediffs\n+    global diffcontext\n \n     set env(GIT_DIFF_OPTS) $diffopts\n-    if {[catch {set bdf [open [diffcmd $ids {-p -C --no-commit-id}] r]} err]} {\n+    if {[catch {set bdf [open [diffcmd $ids \"-p -C --no-commit-id -U$diffcontext\"] r]} err]} {\n \tputs \"error getting diffs: $err\"\n \treturn\n     }\n@@ -7646,6 +7681,8 @@ set markingmatches 0\n \n set optim_delay 16\n \n+set diffcontext 3 \n+\n set nextviewnum 1\n set curview 0\n set selectedview 0\n-- \n1.5.3.rc3.45.g4c741\n"},{"id":"50484","messageId":"11868462503722-git-send-email-prohaska@zib.de","threadId":"9238","inReplyTo":"11856503182381-git-send-email-prohaska@zib.de","subject":"[PATCH v4, ping] gitk: let you easily specify lines of context in diff view","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-08-11T15:30:50Z","receivedAt":"2007-08-11T15:30:50Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"More lines of context sometimes help to better understand a diff.\nThis patch introduces a text field above the box displaying the\nblobdiffs. You can type in the number of lines of context that\nyou wish to view. The number of lines of context is initially\nalways set to 3.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n gitk |   41 +++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 39 insertions(+), 2 deletions(-)\n\nrebased to the current master, fixed one trailing whitespace.\n\nAny chance to get this patch applied? It works for me.\n\n    Steffen\n\ndiff --git a/gitk b/gitk\nindex f74ce51..2f86c7c 100755\n--- a/gitk\n+++ b/gitk\n@@ -517,6 +517,7 @@ proc makewindow {} {\n     global textfont mainfont uifont tabstop\n     global findtype findtypemenu findloc findstring fstring geometry\n     global entries sha1entry sha1string sha1but\n+    global diffcontextstring diffcontext\n     global maincursor textcursor curtextcursor\n     global rowctxmenu fakerowmenu mergemax wrapcomment\n     global highlight_files gdttype\n@@ -731,7 +732,16 @@ proc makewindow {} {\n \t-command changediffdisp -variable diffelide -value {0 1}\n     radiobutton .bleft.mid.new -text \"New version\" \\\n \t-command changediffdisp -variable diffelide -value {1 0}\n-    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left\n+    label .bleft.mid.labeldiffcontext -text \"      Lines of context: \" \\\n+    -font $uifont\n+    spinbox .bleft.mid.diffcontext -width 5 -font $textfont \\\n+    -from 1 -increment 1 -to 10000000 \\\n+    -validate all -validatecommand \"diffcontextvalidate %P\" \\\n+    -textvariable diffcontextstring\n+    .bleft.mid.diffcontext set $diffcontext\n+    trace add variable diffcontextstring write diffcontextchange\n+    lappend entries .bleft.mid.diffcontext\n+    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left\n     set ctext .bleft.ctext\n     text $ctext -background $bgcolor -foreground $fgcolor \\\n \t-tabs \"[expr {$tabstop * $charspc}]\" \\\n@@ -4985,12 +4995,37 @@ proc gettreediffline {gdtf ids} {\n     return 0\n }\n \n+# empty strings or integers accepted\n+proc diffcontextvalidate {v} {\n+    if {[string length $v] == 0} {\n+\treturn 1\n+    }\n+    if {[string is integer $v]} {\n+\tif {$v > 0} {\n+\t    return 1\n+\t}\n+    }\n+    return 0\n+}\n+\n+proc diffcontextchange {n1 n2 op} {\n+    global diffcontextstring diffcontext\n+\n+    if {[string is integer $diffcontextstring]} {\n+        if {$diffcontextstring > 0} {\n+            set diffcontext $diffcontextstring\n+\t\t    reselectline\n+        }\n+    }\n+}\n+\n proc getblobdiffs {ids} {\n     global diffopts blobdifffd diffids env\n     global diffinhdr treediffs\n+    global diffcontext\n \n     set env(GIT_DIFF_OPTS) $diffopts\n-    if {[catch {set bdf [open [diffcmd $ids {-p -C --no-commit-id}] r]} err]} {\n+    if {[catch {set bdf [open [diffcmd $ids \"-p -C --no-commit-id -U$diffcontext\"] r]} err]} {\n \tputs \"error getting diffs: $err\"\n \treturn\n     }\n@@ -7646,6 +7681,8 @@ set markingmatches 0\n \n set optim_delay 16\n \n+set diffcontext 3\n+\n set nextviewnum 1\n set curview 0\n set selectedview 0\n-- \n1.5.3.rc4.31.g6adda\n"},{"id":"50535","messageId":"18110.31705.747583.463206@cargo.ozlabs.ibm.com","threadId":"9238","inReplyTo":"11868462503722-git-send-email-prohaska@zib.de","subject":"Re: [PATCH v4, ping] gitk: let you easily specify lines of context in diff view","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2007-08-12T03:17:45Z","receivedAt":"2007-08-12T03:17:45Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Steffen Prohaska writes:\n\n> Any chance to get this patch applied? It works for me.\n\nSome comments:\n\n> @@ -731,7 +732,16 @@ proc makewindow {} {\n>  \t-command changediffdisp -variable diffelide -value {0 1}\n>      radiobutton .bleft.mid.new -text \"New version\" \\\n>  \t-command changediffdisp -variable diffelide -value {1 0}\n> -    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left\n\nJust add another pack command rather than extending this one.\n\n> +    label .bleft.mid.labeldiffcontext -text \"      Lines of context: \" \\\n> +    -font $uifont\n\nThis is hard to read because the continuation line isn't indented\nfurther that the first line.  Please indent continuation lines by an\nextra 4 spaces.\n\n> +# empty strings or integers accepted\n> +proc diffcontextvalidate {v} {\n> +    if {[string length $v] == 0} {\n> +\treturn 1\n> +    }\n> +    if {[string is integer $v]} {\n> +\tif {$v > 0} {\n> +\t    return 1\n> +\t}\n> +    }\n> +    return 0\n> +}\n\n\"string is integer\" will already accept the null string and return 1.\n\n> +proc diffcontextchange {n1 n2 op} {\n> +    global diffcontextstring diffcontext\n> +\n> +    if {[string is integer $diffcontextstring]} {\n> +        if {$diffcontextstring > 0} {\n\nOnce again, \"string is integer\" returning 1 doesn't guarantee the\nstring is non-empty.  Use \"string is integer -strict\" if you want\nthat.\n\n> +            set diffcontext $diffcontextstring\n> +\t\t    reselectline\n\nInconsistent indentation.\n\n> +set diffcontext 3\n> +\n\nIt would be nice to save diffcontext in the ~/.gitkrc.\n\nPaul.\n"},{"id":"50541","messageId":"AC6A824F-E268-41AE-823B-2C01D78FAF30@zib.de","threadId":"9238","inReplyTo":"18110.31705.747583.463206@cargo.ozlabs.ibm.com","subject":"Re: [PATCH v4, ping] gitk: let you easily specify lines of context in diff view","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-08-12T10:02:53Z","receivedAt":"2007-08-12T10:02:53Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Aug 12, 2007, at 5:17 AM, Paul Mackerras wrote:\n\n> Steffen Prohaska writes:\n>\n>> Any chance to get this patch applied? It works for me.\n>\n> Some comments:\n>\n>> @@ -731,7 +732,16 @@ proc makewindow {} {\n>>  \t-command changediffdisp -variable diffelide -value {0 1}\n>>      radiobutton .bleft.mid.new -text \"New version\" \\\n>>  \t-command changediffdisp -variable diffelide -value {1 0}\n>> -    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left\n>\n> Just add another pack command rather than extending this one.\n\nThanks. Didn't understand what pack does and thought it might be\nneeded to pack all at once into a 'single' pack.\n\n\n>> +    label .bleft.mid.labeldiffcontext -text \"      Lines of  \n>> context: \" \\\n>> +    -font $uifont\n>\n> This is hard to read because the continuation line isn't indented\n> further that the first line.  Please indent continuation lines by an\n> extra 4 spaces.\n\nI fixed more of them. I typically work with a no-tab rule. Hope I\nspotted all other places with wrong indent, too.\n\n\n>> +# empty strings or integers accepted\n>> +proc diffcontextvalidate {v} {\n>> +    if {[string length $v] == 0} {\n>> +\treturn 1\n>> +    }\n>> +    if {[string is integer $v]} {\n>> +\tif {$v > 0} {\n>> +\t    return 1\n>> +\t}\n>> +    }\n>> +    return 0\n>> +}\n>\n> \"string is integer\" will already accept the null string and return 1.\n\nreplaced this by a regexp.\n\n\n>> +proc diffcontextchange {n1 n2 op} {\n>> +    global diffcontextstring diffcontext\n>> +\n>> +    if {[string is integer $diffcontextstring]} {\n>> +        if {$diffcontextstring > 0} {\n>\n> Once again, \"string is integer\" returning 1 doesn't guarantee the\n> string is non-empty.  Use \"string is integer -strict\" if you want\n> that.\n\nAh, thanks, didn't know that.\n\n\n>> +            set diffcontext $diffcontextstring\n>> +\t\t    reselectline\n>\n> Inconsistent indentation.\n\nok.\n\n\n>> +set diffcontext 3\n>> +\n>\n> It would be nice to save diffcontext in the ~/.gitkrc.\n\ndone.\n\nWill send a patch in a minute.\n\n\tSteffen\n"},{"id":"50542","messageId":"11869131461127-git-send-email-prohaska@zib.de","threadId":"9238","inReplyTo":"AC6A824F-E268-41AE-823B-2C01D78FAF30@zib.de","subject":"[PATCH v5] gitk: let you easily specify lines of context in diff view","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-08-12T10:05:46Z","receivedAt":"2007-08-12T10:05:46Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"More lines of context sometimes help to better understand a diff.\nThis patch introduces a text field above the box displaying the\nblobdiffs. You can type in the number of lines of context that\nyou wish to view. The number of lines of context is saved to\n~/.gitk.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n gitk |   34 ++++++++++++++++++++++++++++++++--\n 1 files changed, 32 insertions(+), 2 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 1103baf..4366c7f 100755\n--- a/gitk\n+++ b/gitk\n@@ -517,6 +517,7 @@ proc makewindow {} {\n     global textfont mainfont uifont tabstop\n     global findtype findtypemenu findloc findstring fstring geometry\n     global entries sha1entry sha1string sha1but\n+    global diffcontextstring diffcontext\n     global maincursor textcursor curtextcursor\n     global rowctxmenu fakerowmenu mergemax wrapcomment\n     global highlight_files gdttype\n@@ -731,7 +732,17 @@ proc makewindow {} {\n \t-command changediffdisp -variable diffelide -value {0 1}\n     radiobutton .bleft.mid.new -text \"New version\" \\\n \t-command changediffdisp -variable diffelide -value {1 0}\n+    label .bleft.mid.labeldiffcontext -text \"      Lines of context: \" \\\n+\t-font $uifont\n     pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left\n+    spinbox .bleft.mid.diffcontext -width 5 -font $textfont \\\n+\t-from 1 -increment 1 -to 10000000 \\\n+\t-validate all -validatecommand \"diffcontextvalidate %P\" \\\n+\t-textvariable diffcontextstring\n+    .bleft.mid.diffcontext set $diffcontext\n+    trace add variable diffcontextstring write diffcontextchange\n+    lappend entries .bleft.mid.diffcontext\n+    pack .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left\n     set ctext .bleft.ctext\n     text $ctext -background $bgcolor -foreground $fgcolor \\\n \t-tabs \"[expr {$tabstop * $charspc}]\" \\\n@@ -968,7 +979,7 @@ proc savestuff {w} {\n     global maxwidth showneartags showlocalchanges\n     global viewname viewfiles viewargs viewperm nextviewnum\n     global cmitmode wrapcomment\n-    global colors bgcolor fgcolor diffcolors selectbgcolor\n+    global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor\n \n     if {$stuffsaved} return\n     if {![winfo viewable .]} return\n@@ -989,6 +1000,7 @@ proc savestuff {w} {\n \tputs $f [list set fgcolor $fgcolor]\n \tputs $f [list set colors $colors]\n \tputs $f [list set diffcolors $diffcolors]\n+\tputs $f [list set diffcontext $diffcontext]\n \tputs $f [list set selectbgcolor $selectbgcolor]\n \n \tputs $f \"set geometry(main) [wm geometry .]\"\n@@ -4986,12 +4998,29 @@ proc gettreediffline {gdtf ids} {\n     return 0\n }\n \n+# empty string or positive integer\n+proc diffcontextvalidate {v} {\n+    return [regexp {^(|[1-9][0-9]*)$} $v]\n+}\n+\n+proc diffcontextchange {n1 n2 op} {\n+    global diffcontextstring diffcontext\n+\n+    if {[string is integer -strict $diffcontextstring]} {\n+\tif {$diffcontextstring > 0} {\n+\t    set diffcontext $diffcontextstring\n+\t    reselectline\n+\t}\n+    }\n+}\n+\n proc getblobdiffs {ids} {\n     global diffopts blobdifffd diffids env\n     global diffinhdr treediffs\n+    global diffcontext\n \n     set env(GIT_DIFF_OPTS) $diffopts\n-    if {[catch {set bdf [open [diffcmd $ids {-p -C --no-commit-id}] r]} err]} {\n+    if {[catch {set bdf [open [diffcmd $ids \"-p -C --no-commit-id -U$diffcontext\"] r]} err]} {\n \tputs \"error getting diffs: $err\"\n \treturn\n     }\n@@ -7569,6 +7598,7 @@ set colors {green red blue magenta darkgrey brown orange}\n set bgcolor white\n set fgcolor black\n set diffcolors {red \"#00a000\" blue}\n+set diffcontext 3\n set selectbgcolor gray85\n \n catch {source ~/.gitk}\n-- \n1.5.3.rc4.762.g17d7\n"}]}