{"thread":{"id":"28666","subject":"[RFC/PATCH 4/4] git-gui: incremental goto line in blame view","startedAt":"2011-10-13T13:48:12Z","lastAt":"2011-10-16T10:32:47Z","messageCount":10,"participants":["Bert Wesarg","Pat Thoyts"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"177553","messageId":"1d1c91fdaa0bfd31067fd2e06f3f1ecf5597b8d3.1318513492.git.bert.wesarg@googlemail.com","threadId":"28666","inReplyTo":null,"subject":"[PATCH 1/4] git-gui: search and linenumber input are mutual exclusive in the blame view","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-10-13T13:48:12Z","receivedAt":"2011-10-13T13:48:12Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"It was possible to open the search input (Ctrl+S) and the goto-line input\n(Ctrl+G) at the same time. Prevent this.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/blame.tcl |   22 ++++++++++++++++------\n 1 files changed, 16 insertions(+), 6 deletions(-)\n\ndiff --git a/lib/blame.tcl b/lib/blame.tcl\nindex 2099776..691941e 100644\n--- a/lib/blame.tcl\n+++ b/lib/blame.tcl\n@@ -280,11 +280,11 @@ constructor new {i_commit i_path i_jump} {\n \t$w.ctxm add command \\\n \t\t-label [mc \"Find Text...\"] \\\n \t\t-accelerator F7 \\\n-\t\t-command [list searchbar::show $finder]\n+\t\t-command [cb _show_finder]\n \t$w.ctxm add command \\\n \t\t-label [mc \"Goto Line...\"] \\\n \t\t-accelerator \"Ctrl-G\" \\\n-\t\t-command [list linebar::show $gotoline]\n+\t\t-command [cb _show_linebar]\n \tmenu $w.ctxm.enc\n \tbuild_encoding_menu $w.ctxm.enc [cb _setencoding]\n \t$w.ctxm add cascade \\\n@@ -351,13 +351,13 @@ constructor new {i_commit i_path i_jump} {\n \tbind $w_cviewer <Tab>       \"[list focus $w_file];break\"\n \tbind $w_cviewer <Button-1>   [list focus $w_cviewer]\n \tbind $w_file    <Visibility> [cb _focus_search $w_file]\n-\tbind $top       <F7>         [list searchbar::show $finder]\n-\tbind $top       <Key-slash>  [list searchbar::show $finder]\n-\tbind $top    <Control-Key-s> [list searchbar::show $finder]\n+\tbind $top       <F7>         [cb _show_finder]\n+\tbind $top       <Key-slash>  [cb _show_finder]\n+\tbind $top    <Control-Key-s> [cb _show_finder]\n \tbind $top       <Escape>     [list searchbar::hide $finder]\n \tbind $top       <F3>         [list searchbar::find_next $finder]\n \tbind $top       <Shift-F3>   [list searchbar::find_prev $finder]\n-\tbind $top    <Control-Key-g> [list linebar::show $gotoline]\n+\tbind $top    <Control-Key-g> [cb _show_linebar]\n \tcatch { bind $top <Shift-Key-XF86_Switch_VT_3> [list searchbar::find_prev $finder] }\n \n \tgrid configure $w.header -sticky ew\n@@ -1349,4 +1349,14 @@ method _resize {new_height} {\n \tset old_height $new_height\n }\n \n+method _show_finder {} {\n+\tlinebar::hide $gotoline\n+\tsearchbar::show $finder\n+}\n+\n+method _show_linebar {} {\n+\tsearchbar::hide $finder\n+\tlinebar::show $gotoline\n+}\n+\n }\n-- \n1.7.6.789.gb4599\n"},{"id":"177555","messageId":"a59d40509d4f80a6dae99bae5ef6311bb607bd34.1318513492.git.bert.wesarg@googlemail.com","threadId":"28666","inReplyTo":"1d1c91fdaa0bfd31067fd2e06f3f1ecf5597b8d3.1318513492.git.bert.wesarg@googlemail.com","subject":"[PATCH 2/4] git-gui: clear the goto line input when hiding","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-10-13T13:48:13Z","receivedAt":"2011-10-13T13:48:13Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/line.tcl |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/lib/line.tcl b/lib/line.tcl\nindex 4913bdd..692485a 100644\n--- a/lib/line.tcl\n+++ b/lib/line.tcl\n@@ -41,6 +41,7 @@ method show {} {\n \n method hide {} {\n \tif {[visible $this]} {\n+\t\t$w.ent delete 0 end\n \t\tfocus $ctext\n \t\tgrid remove $w\n \t}\n-- \n1.7.6.789.gb4599\n"},{"id":"177554","messageId":"fbfb3f3ba4db190f8956eea4f78419a1b81573a6.1318513492.git.bert.wesarg@googlemail.com","threadId":"28666","inReplyTo":"a59d40509d4f80a6dae99bae5ef6311bb607bd34.1318513492.git.bert.wesarg@googlemail.com","subject":"[PATCH 3/4] git-gui: only except numbers in the goto-line input","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-10-13T13:48:14Z","receivedAt":"2011-10-13T13:48:14Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/line.tcl |   16 ++++++++++++++--\n 1 files changed, 14 insertions(+), 2 deletions(-)\n\ndiff --git a/lib/line.tcl b/lib/line.tcl\nindex 692485a..70785e1 100644\n--- a/lib/line.tcl\n+++ b/lib/line.tcl\n@@ -15,7 +15,11 @@ constructor new {i_w i_text args} {\n \n \t${NS}::frame  $w\n \t${NS}::label  $w.l       -text [mc \"Goto Line:\"]\n-\tentry  $w.ent -textvariable ${__this}::linenum -background lightgreen\n+\tentry  $w.ent \\\n+\t\t-textvariable ${__this}::linenum \\\n+\t\t-background lightgreen \\\n+\t\t-validate key \\\n+\t\t-validatecommand [cb _validate %P]\n \t${NS}::button $w.bn      -text [mc Go] -command [cb _incrgoto]\n \n \tpack   $w.l   -side left\n@@ -26,7 +30,7 @@ constructor new {i_w i_text args} {\n \tgrid remove $w\n \n \tbind $w.ent <Return> [cb _incrgoto]\n-\tbind $w.ent <Escape> [list linebar::hide $this]\n+\tbind $w.ent <Escape> [cb hide]\n \n \tbind $w <Destroy> [list delete_this $this]\n \treturn $this\n@@ -55,6 +59,14 @@ method editor {} {\n \treturn $w.ent\n }\n \n+method _validate {P} {\n+\t# only accept numbers as input\n+\tif {[regexp {\\d*} $P]} {\n+\t\treturn 1\n+\t}\n+\treturn 0\n+}\n+\n method _incrgoto {} {\n \tif {$linenum ne {}} {\n \t\t$ctext see $linenum.0\n-- \n1.7.6.789.gb4599\n"},{"id":"177552","messageId":"7a9760b8cf85274b17c7233f61f59bb59cd18578.1318513492.git.bert.wesarg@googlemail.com","threadId":"28666","inReplyTo":"fbfb3f3ba4db190f8956eea4f78419a1b81573a6.1318513492.git.bert.wesarg@googlemail.com","subject":"[RFC/PATCH 4/4] git-gui: incremental goto line in blame view","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-10-13T13:48:15Z","receivedAt":"2011-10-13T13:48:15Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"The view jumps now to the given line number after each key press.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n\nI didn't know this before, but gedits goto-line-dialog works this way.\n\n lib/line.tcl |   15 +++++++++++----\n 1 files changed, 11 insertions(+), 4 deletions(-)\n\ndiff --git a/lib/line.tcl b/lib/line.tcl\nindex 70785e1..0113e06 100644\n--- a/lib/line.tcl\n+++ b/lib/line.tcl\n@@ -20,7 +20,7 @@ constructor new {i_w i_text args} {\n \t\t-background lightgreen \\\n \t\t-validate key \\\n \t\t-validatecommand [cb _validate %P]\n-\t${NS}::button $w.bn      -text [mc Go] -command [cb _incrgoto]\n+\t${NS}::button $w.bn      -text [mc Go] -command [cb _goto]\n \n \tpack   $w.l   -side left\n \tpack   $w.bn  -side right\n@@ -29,7 +29,8 @@ constructor new {i_w i_text args} {\n \teval grid conf $w -sticky we $args\n \tgrid remove $w\n \n-\tbind $w.ent <Return> [cb _incrgoto]\n+\ttrace add variable linenum write [cb _goto_cb]\n+\tbind $w.ent <Return> [cb _goto]\n \tbind $w.ent <Escape> [cb hide]\n \n \tbind $w <Destroy> [list delete_this $this]\n@@ -67,10 +68,16 @@ method _validate {P} {\n \treturn 0\n }\n \n-method _incrgoto {} {\n+method _goto_cb {name ix op} {\n+\tafter idle [cb _goto 1]\n+}\n+\n+method _goto {{nohide {0}}} {\n \tif {$linenum ne {}} {\n \t\t$ctext see $linenum.0\n-\t\thide $this\n+\t\tif {!$nohide} {\n+\t\t\thide $this\n+\t\t}\n \t}\n }\n \n-- \n1.7.6.789.gb4599\n"},{"id":"177748","messageId":"87fwitkihn.fsf@fox.patthoyts.tk","threadId":"28666","inReplyTo":"fbfb3f3ba4db190f8956eea4f78419a1b81573a6.1318513492.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH 3/4] git-gui: only except numbers in the goto-line input","fromName":"Pat Thoyts","fromEmail":"patthoyts@users.sourceforge.net","sentAt":"2011-10-15T22:17:08Z","receivedAt":"2011-10-15T22:17:08Z","isPatch":true,"sender":{"key":"patthoyts@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/30739?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>---\n> lib/line.tcl |   16 ++++++++++++++--\n> 1 files changed, 14 insertions(+), 2 deletions(-)\n>\n>diff --git a/lib/line.tcl b/lib/line.tcl\n>index 692485a..70785e1 100644\n>--- a/lib/line.tcl\n>+++ b/lib/line.tcl\n>@@ -15,7 +15,11 @@ constructor new {i_w i_text args} {\n> \n> \t${NS}::frame  $w\n> \t${NS}::label  $w.l       -text [mc \"Goto Line:\"]\n>-\tentry  $w.ent -textvariable ${__this}::linenum -background lightgreen\n>+\tentry  $w.ent \\\n>+\t\t-textvariable ${__this}::linenum \\\n>+\t\t-background lightgreen \\\n>+\t\t-validate key \\\n>+\t\t-validatecommand [cb _validate %P]\n> \t${NS}::button $w.bn      -text [mc Go] -command [cb _incrgoto]\n> \n> \tpack   $w.l   -side left\n>@@ -26,7 +30,7 @@ constructor new {i_w i_text args} {\n> \tgrid remove $w\n> \n> \tbind $w.ent <Return> [cb _incrgoto]\n>-\tbind $w.ent <Escape> [list linebar::hide $this]\n>+\tbind $w.ent <Escape> [cb hide]\n> \n> \tbind $w <Destroy> [list delete_this $this]\n> \treturn $this\n>@@ -55,6 +59,14 @@ method editor {} {\n> \treturn $w.ent\n> }\n> \n>+method _validate {P} {\n>+\t# only accept numbers as input\n>+\tif {[regexp {\\d*} $P]} {\n>+\t\treturn 1\n>+\t}\n>+\treturn 0\n>+}\n>+\n> method _incrgoto {} {\n> \tif {$linenum ne {}} {\n> \t\t$ctext see $linenum.0\n\nThis one doesn't actually work when I try it it accepts alphanumeric\ninput. However, replacing the validate body with\n  string is integer $P\nfixes it to operate as intended so I'll replace it with this.\nLooks like it needs theming too but that can be a separate patch.\n-- \nPat Thoyts                            http://www.patthoyts.tk/\nPGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD\n"},{"id":"177750","messageId":"87bothkibf.fsf@fox.patthoyts.tk","threadId":"28666","inReplyTo":"a59d40509d4f80a6dae99bae5ef6311bb607bd34.1318513492.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH 2/4] git-gui: clear the goto line input when hiding","fromName":"Pat Thoyts","fromEmail":"patthoyts@users.sourceforge.net","sentAt":"2011-10-15T22:20:52Z","receivedAt":"2011-10-15T22:20:52Z","isPatch":true,"sender":{"key":"patthoyts@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/30739?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>---\n> lib/line.tcl |    1 +\n> 1 files changed, 1 insertions(+), 0 deletions(-)\n>\n>diff --git a/lib/line.tcl b/lib/line.tcl\n>index 4913bdd..692485a 100644\n>--- a/lib/line.tcl\n>+++ b/lib/line.tcl\n>@@ -41,6 +41,7 @@ method show {} {\n> \n> method hide {} {\n> \tif {[visible $this]} {\n>+\t\t$w.ent delete 0 end\n> \t\tfocus $ctext\n> \t\tgrid remove $w\n> \t}\n\nYou don't say why this one gets cleared but the search box is not\ncleared.\n\n-- \nPat Thoyts                            http://www.patthoyts.tk/\nPGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD\n"},{"id":"177751","messageId":"877h45ki95.fsf@fox.patthoyts.tk","threadId":"28666","inReplyTo":"1d1c91fdaa0bfd31067fd2e06f3f1ecf5597b8d3.1318513492.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH 1/4] git-gui: search and linenumber input are mutual exclusive in the blame view","fromName":"Pat Thoyts","fromEmail":"patthoyts@users.sourceforge.net","sentAt":"2011-10-15T22:22:14Z","receivedAt":"2011-10-15T22:22:14Z","isPatch":true,"sender":{"key":"patthoyts@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/30739?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n>It was possible to open the search input (Ctrl+S) and the goto-line input\n>(Ctrl+G) at the same time. Prevent this.\n>\n>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>---\n> lib/blame.tcl |   22 ++++++++++++++++------\n> 1 files changed, 16 insertions(+), 6 deletions(-)\n>\n>diff --git a/lib/blame.tcl b/lib/blame.tcl\n>index 2099776..691941e 100644\n>--- a/lib/blame.tcl\n>+++ b/lib/blame.tcl\n>@@ -280,11 +280,11 @@ constructor new {i_commit i_path i_jump} {\n> \t$w.ctxm add command \\\n> \t\t-label [mc \"Find Text...\"] \\\n> \t\t-accelerator F7 \\\n>-\t\t-command [list searchbar::show $finder]\n>+\t\t-command [cb _show_finder]\n> \t$w.ctxm add command \\\n> \t\t-label [mc \"Goto Line...\"] \\\n> \t\t-accelerator \"Ctrl-G\" \\\n>-\t\t-command [list linebar::show $gotoline]\n>+\t\t-command [cb _show_linebar]\n> \tmenu $w.ctxm.enc\n> \tbuild_encoding_menu $w.ctxm.enc [cb _setencoding]\n> \t$w.ctxm add cascade \\\n>@@ -351,13 +351,13 @@ constructor new {i_commit i_path i_jump} {\n> \tbind $w_cviewer <Tab>       \"[list focus $w_file];break\"\n> \tbind $w_cviewer <Button-1>   [list focus $w_cviewer]\n> \tbind $w_file    <Visibility> [cb _focus_search $w_file]\n>-\tbind $top       <F7>         [list searchbar::show $finder]\n>-\tbind $top       <Key-slash>  [list searchbar::show $finder]\n>-\tbind $top    <Control-Key-s> [list searchbar::show $finder]\n>+\tbind $top       <F7>         [cb _show_finder]\n>+\tbind $top       <Key-slash>  [cb _show_finder]\n>+\tbind $top    <Control-Key-s> [cb _show_finder]\n> \tbind $top       <Escape>     [list searchbar::hide $finder]\n> \tbind $top       <F3>         [list searchbar::find_next $finder]\n> \tbind $top       <Shift-F3>   [list searchbar::find_prev $finder]\n>-\tbind $top    <Control-Key-g> [list linebar::show $gotoline]\n>+\tbind $top    <Control-Key-g> [cb _show_linebar]\n> \tcatch { bind $top <Shift-Key-XF86_Switch_VT_3> [list searchbar::find_prev $finder] }\n> \n> \tgrid configure $w.header -sticky ew\n>@@ -1349,4 +1349,14 @@ method _resize {new_height} {\n> \tset old_height $new_height\n> }\n> \n>+method _show_finder {} {\n>+\tlinebar::hide $gotoline\n>+\tsearchbar::show $finder\n>+}\n>+\n>+method _show_linebar {} {\n>+\tsearchbar::hide $finder\n>+\tlinebar::show $gotoline\n>+}\n>+\n> }\n\nLooks good. Will apply.\n\n-- \nPat Thoyts                            http://www.patthoyts.tk/\nPGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD\n"},{"id":"177752","messageId":"8739etki1l.fsf@fox.patthoyts.tk","threadId":"28666","inReplyTo":"7a9760b8cf85274b17c7233f61f59bb59cd18578.1318513492.git.bert.wesarg@googlemail.com","subject":"Re: [RFC/PATCH 4/4] git-gui: incremental goto line in blame view","fromName":"Pat Thoyts","fromEmail":"patthoyts@users.sourceforge.net","sentAt":"2011-10-15T22:26:46Z","receivedAt":"2011-10-15T22:26:46Z","isPatch":true,"sender":{"key":"patthoyts@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/30739?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n>The view jumps now to the given line number after each key press.\n>\n>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>---\n>\n>I didn't know this before, but gedits goto-line-dialog works this way.\n>\n> lib/line.tcl |   15 +++++++++++----\n> 1 files changed, 11 insertions(+), 4 deletions(-)\n>\n>diff --git a/lib/line.tcl b/lib/line.tcl\n>index 70785e1..0113e06 100644\n>--- a/lib/line.tcl\n>+++ b/lib/line.tcl\n>@@ -20,7 +20,7 @@ constructor new {i_w i_text args} {\n> \t\t-background lightgreen \\\n> \t\t-validate key \\\n> \t\t-validatecommand [cb _validate %P]\n>-\t${NS}::button $w.bn      -text [mc Go] -command [cb _incrgoto]\n>+\t${NS}::button $w.bn      -text [mc Go] -command [cb _goto]\n> \n> \tpack   $w.l   -side left\n> \tpack   $w.bn  -side right\n>@@ -29,7 +29,8 @@ constructor new {i_w i_text args} {\n> \teval grid conf $w -sticky we $args\n> \tgrid remove $w\n> \n>-\tbind $w.ent <Return> [cb _incrgoto]\n>+\ttrace add variable linenum write [cb _goto_cb]\n>+\tbind $w.ent <Return> [cb _goto]\n> \tbind $w.ent <Escape> [cb hide]\n> \n> \tbind $w <Destroy> [list delete_this $this]\n>@@ -67,10 +68,16 @@ method _validate {P} {\n> \treturn 0\n> }\n> \n>-method _incrgoto {} {\n>+method _goto_cb {name ix op} {\n>+\tafter idle [cb _goto 1]\n>+}\n>+\n>+method _goto {{nohide {0}}} {\n> \tif {$linenum ne {}} {\n> \t\t$ctext see $linenum.0\n>-\t\thide $this\n>+\t\tif {!$nohide} {\n>+\t\t\thide $this\n>+\t\t}\n> \t}\n> }\n\nWorks fine. Will apply.\n\nOK These 4 patches are applied and pushed to master branch - with\nmodifications made to 'only accept numbers in the goto-line input' made\nas mentioned.\n\nThanks,\n\n-- \nPat Thoyts                            http://www.patthoyts.tk/\nPGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD\n"},{"id":"177772","messageId":"CAKPyHN2RK89nnZS5rv6Q=3_UXZFCovqPVCbn6zDDE+SN_=ZxAQ@mail.gmail.com","threadId":"28666","inReplyTo":"87bothkibf.fsf@fox.patthoyts.tk","subject":"Re: [PATCH 2/4] git-gui: clear the goto line input when hiding","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-10-16T10:29:57Z","receivedAt":"2011-10-16T10:29:57Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Hi,\n\nOn Sun, Oct 16, 2011 at 00:20, Pat Thoyts\n<patthoyts@users.sourceforge.net> wrote:\n> Bert Wesarg <bert.wesarg@googlemail.com> writes:\n>\n>>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>>---\n>> lib/line.tcl |    1 +\n>> 1 files changed, 1 insertions(+), 0 deletions(-)\n>>\n>>diff --git a/lib/line.tcl b/lib/line.tcl\n>>index 4913bdd..692485a 100644\n>>--- a/lib/line.tcl\n>>+++ b/lib/line.tcl\n>>@@ -41,6 +41,7 @@ method show {} {\n>>\n>> method hide {} {\n>>       if {[visible $this]} {\n>>+              $w.ent delete 0 end\n>>               focus $ctext\n>>               grid remove $w\n>>       }\n>\n> You don't say why this one gets cleared but the search box is not\n> cleared.\n\nBecause thats a different patch series. Which I already send to you.\nStarting with \"[PATCH 1/4] git-gui: handle config booleans without\nvalue\".\n\nBert\n\n>\n> --\n> Pat Thoyts                            http://www.patthoyts.tk/\n> PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD\n>\n"},{"id":"177773","messageId":"CAKPyHN0r9VF9nS35+YZWbMb-DW4Xgt-MzN5JX2DH8eji7SZRpw@mail.gmail.com","threadId":"28666","inReplyTo":"87fwitkihn.fsf@fox.patthoyts.tk","subject":"Re: [PATCH 3/4] git-gui: only except numbers in the goto-line input","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-10-16T10:32:47Z","receivedAt":"2011-10-16T10:32:47Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Hi,\n\nOn Sun, Oct 16, 2011 at 00:17, Pat Thoyts\n<patthoyts@users.sourceforge.net> wrote:\n> Bert Wesarg <bert.wesarg@googlemail.com> writes:\n>\n>>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>>---\n>> lib/line.tcl |   16 ++++++++++++++--\n>> 1 files changed, 14 insertions(+), 2 deletions(-)\n>>\n>>diff --git a/lib/line.tcl b/lib/line.tcl\n>>index 692485a..70785e1 100644\n>>--- a/lib/line.tcl\n>>+++ b/lib/line.tcl\n>>@@ -15,7 +15,11 @@ constructor new {i_w i_text args} {\n>>\n>>       ${NS}::frame  $w\n>>       ${NS}::label  $w.l       -text [mc \"Goto Line:\"]\n>>-      entry  $w.ent -textvariable ${__this}::linenum -background lightgreen\n>>+      entry  $w.ent \\\n>>+              -textvariable ${__this}::linenum \\\n>>+              -background lightgreen \\\n>>+              -validate key \\\n>>+              -validatecommand [cb _validate %P]\n>>       ${NS}::button $w.bn      -text [mc Go] -command [cb _incrgoto]\n>>\n>>       pack   $w.l   -side left\n>>@@ -26,7 +30,7 @@ constructor new {i_w i_text args} {\n>>       grid remove $w\n>>\n>>       bind $w.ent <Return> [cb _incrgoto]\n>>-      bind $w.ent <Escape> [list linebar::hide $this]\n>>+      bind $w.ent <Escape> [cb hide]\n>>\n>>       bind $w <Destroy> [list delete_this $this]\n>>       return $this\n>>@@ -55,6 +59,14 @@ method editor {} {\n>>       return $w.ent\n>> }\n>>\n>>+method _validate {P} {\n>>+      # only accept numbers as input\n>>+      if {[regexp {\\d*} $P]} {\n>>+              return 1\n>>+      }\n>>+      return 0\n>>+}\n>>+\n>> method _incrgoto {} {\n>>       if {$linenum ne {}} {\n>>               $ctext see $linenum.0\n>\n> This one doesn't actually work when I try it it accepts alphanumeric\n> input. However, replacing the validate body with\n>  string is integer $P\n> fixes it to operate as intended so I'll replace it with this.\n\nSorry, the correct regexp would have been {^\\d*$}. But your [string is\ninteger] should completely suffice. Thanks.\n\n> Looks like it needs theming too but that can be a separate patch.\n\nTheming is not my field, sorry.\n\nBert\n\n> --\n> Pat Thoyts                            http://www.patthoyts.tk/\n> PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD\n>\n"}]}