How do I customize 'word ends' for TextView / add underscore to selection for double click?

Hi,

I tried doing it with the code below and for the example from the
distribution (pango/samples/break.rb) it worked: underscore
was then similar to an ordinary letter. I mean word_end for
underscore became true. But this doesn’t work when I’m trying
to double-click a word with an underscore - it always selects a
part to the left or to the right of it. Any help is appreciated.

module Pango
alias :super_break :break
module_function :super_break

def self.break s, analysis
  #puts "intercepted"
  r = super_break s, analysis
  # TODO: fix for ruby 1.9
  #puts s
  chars = s.unpack("U*")
  for i in 0...chars.length
    c = chars[i]
    #print c.chr
    r[i].word_end = false if c == 95 # _
  end
  r
end

end

Thanks,
A.

Your snippet works for Ruby code but won’t affect other Gtk widgets
that depend on the C version of Pango, like GtkTextBuffer.

I too would love to know how to customize this kind of thing in Pango,
but I’m not sure if it’s possible, based on my Google searchigns.
Perhaps there is a Pango mailing list or irc channel we could ask in?

Please post back here if you do find a solution.

best,
Dan


Daniel Benjamin Lucraft

www.daniellucraft.com/blog
twitter.com/danlucraft

2009/4/15 Andrey C. [email protected]: