From: quillion Date: 2003-12-24T20:01:54+09:00 Subject: TkText freezes Hello all, Running On i686 Linux Pulled this code out from another app ------------------------------------------------ #! /usr/bin/env ruby # #! /usr/local/bin/ruby require 'tk' # Overriding insert in Tktext class HiText < TkText # remove any bindings that get in the way # self.bind_remove "Control-k" def insert(index,char,tag1,tag2) # set char to preference if char =~/[A-Z]/ flag = super(index,char,tag2) elsif char =~ /[a-z]/ flag = super(index,char,tag1) end end end root = TkRoot.new edit = HiText.new(root) { width 50 height 10 pack focus } # set tags to whatever... colours styles etc col2 = TkTextTag.new(edit, 'foreground'=>'red') col1 = TkTextTag.new(edit, 'foreground'=>'blue') root.title 'HiText : Control-d exits' edit.bind("KeyPress") { |event| Tk.callback_break if edit.insert('insert', event.char, col1, col2) } edit.bind "Control-d", proc{root.destroy} Tk.mainloop ------------------------------------------------------------------------ Is there a better way of doing this ? I have been using this method for some years with Tk but now find it freezing with ruby 1.8.1 (2003-12-05) [i686-linux and in the full app will sometimes segfault and dump core. Works ok with a snapshot from October ruby 1.8.0 (2003-10-02) [i686-linux] /usr/local/lib/ruby/1.8/tk.rb:762: [BUG] Segmentation fault ruby 1.8.1 (2003-12-05) [i686-linux] Happy Christmas and the best New Year to all neil