Howto: Enable regular expression highlighting in LimeChat

Gravatar
Posted by apokalyptik

in LimeChat.app/Contents/Resources/logrenderer.rb around line 419… WFM. IANAL. YMMV. RTFM. OMGWTF. WTL. GTFO. ETC.

    words.each do |w|
      next if w.empty?
      s = body
      offset = 0
# <edit was="rex = Regexp.new(Regexp.escape(w), true)">
      rex = Regexp.new(w, true)
# </edit>
      while rex =~ s
# <edit>
        begin
# </edit>
          left = $~.begin(0)
          right = $~.end(0)
          pre = $~.pre_match
          post = $~.post_match
          ok = true
 
          if exact_word_match
            if !pre.empty? && alphabetic?(w.first_char) && alphabetic?(pre.last_char)
              ok = false
            elsif !post.empty? && alphabetic?(w.last_char) && alphabetic?(post.first_char)
              ok = false
            end
          end
 
          if ok
            keywords < < { :pos => offset+left, :len => right-left }
          end
          s = post
          offset += right
# <edit>
        rescue
          next
        end
# </edit>
      end
    end

Trackback URL for this entry