From: nagai@... Date: 2002-01-16T12:17:11+09:00 Subject: Re: questions: TkText, TkTextTag, etc Hi, From: Albert Wagner Subject: Re: questions: TkText, TkTextTag, etc Date: Wed, 16 Jan 2002 11:43:34 +0900 Message-ID: <20020116023938.FPL16424.europa@there> > This code wasn't tested. I tried to leave your logic intact and only > demonstrate a few interators. And, here is an another script. :-) The important point is that you can use *Ruby's* regular expressions (*NOT* Tcl/Tk's regular expressions) for search on TkText widget. ---------------------------------------------------- require 'tk' r = TkRoot.new(){ title 'test' } tag = Hash.new text2check = "if( x==1 ) {\n\t$foo = \"bla\";\n\tfor( $x=0; $x < 20; $x++) {\n\t\t$foo=\"hello\";\n\t}\n}" e = TkText.new( r).pack("side"=>"top") def e.checkSyntax tag, pattern tail = '1.0' until (range = search_with_length(pattern, tail, 'end'))[0].empty? range = search_with_length(pattern, tail, 'end') tail = range[0] + ' + ' + range[1].to_s + 'chars' tag.add(range[0], tail) end end e.insert("end", text2check ) tag["Symb"] = TkTextTag.new(e, 'foreground'=>'blue' ) symb = /([$}{]|={1,2})/ e.checkSyntax tag["Symb"], symb e2 = TkText.new( r, "height"=>"4", "bd"=>"0").pack("side"=>"bottom") Tk.mainloop ---------------------------------------------------- -- 永井 秀利 (九工大 知能情報) nagai@ai.kyutech.ac.jp