nagai / ai.kyutech.ac.jp wrote in message news:<20020116121705N.nagai / ai.kyutech.ac.jp>... > Hi, > > From: Albert Wagner <alwagner / tcac.net> > 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 > ---------------------------------------------------- many many thx to you both i taked the code up here, to highlight it but im working on it, because it needs to long on highlighting big files but many thx, it helps a lot to get closer to ruby if you want to have a look, here are the code pieces http://www.dubios.com/tmp/rubed_v08_020122.zip (the menu isnt ready yet, and in wrong order ;) ) i guess it wasnt my last question :) thx again bye nils