From: oxman Date: 2005-01-16T04:51:10+09:00 Subject: Re: ruby-gnome2 : problem with signal "insert-text" So you're the developper of aeditor ? Or developper of an other text editor ? Joao Pedrosa wrote: > Hi, > > On Sun, 16 Jan 2005 04:16:10 +0900, oxman wrote: > >>I prefer a more generic way, such as : >>buffer.signal_connect_after('insert-text') do |a,iter,text,length| >> color(buffer, iter) >>end >> >>def color (buffer, iter) >> first_char = iter >> first_char.offset -= iter.line_offset >> last_char = buffer.get_iter_at_offset(first_char.offset) >> last_char.forward_to_line_end >> line_text = first_char.get_visible_text(last_char) >> f = File.open("ruby.color") >> f.each_line do |pattern| >> pattern.strip! >> if (match = Regexp.new(pattern).match(line_text)) >> length = match.pre_match.length >> start_iter = >>buffer.get_iter_at_offset(first_char.offset + length) >> length = match.post_match.length >> end_iter = >>buffer.get_iter_at_offset(last_char.offset - length) >> 2.times >>{buffer.apply_tag(buffer.tag_table.lookup("blue"), start_iter, end_iter)} >> end >> end >>end >> >>sentinel% cat ruby.color >>#.+$ >>if >>else > > > Cool. :-) > > I don't know how I'm going to use it yet. I like the syntax highlight > provided by AEditor. I'm using it already, but only for the entire > buffer when loading or on demand. Your Regexes might be great as well. > > It was cool to think about it in your example. I'm not in a hurry to > get this working, though. What I have is good enough for me (a simple > working editor)... But, I still need to provide full syntax > highlighting... hehe. > > If GtkSourceText was available on Windows, then I would use it... But > it's not. :-) > > Cheers, > Joao > >