Forum: Ruby-Gnome 2 How do I customize 'word ends' for TextView / add underscore to selection for double click?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andrey C. (Guest)
on 2009-04-15 17:50
(Received via mailing list)
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.
Daniel L. (Guest)
on 2009-04-17 14:35
(Received via mailing list)
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. <removed_email_address@domain.invalid>:
This topic is locked and can not be replied to.