Scintilla event problem in new wxRuby – kinda solved

The onStyleNeeded method in scintilla.rb used to look like this:

def onStyleNeeded(evt)
    self.styleWithPos(self.get_current_pos - 1, evt.get_position)
  end

After upgrading my wxRuby to the latest version it started segfaulting, throwing something about evt.get_position being a Wx::Point instead of an integer, but only on some occasions, not always (don’t ask me why). At first I tried the below code with evt.get_position.get.last (a wxPython document on wx.point revealed a Get method returning x and y as a tuple). That didn’t work though, “undefined method”.

Life is short and the below code just works by styling from the current position to the end of the document, highly wasteful but I don’t have time for more bullshit searching for answers in obscure documents on some dusty shelf of the Internet.

def onStyleNeeded(evt)
    position = evt.get_position.is_a?(Integer) ? evt.get_position : self.get_text_length
    self.styleWithPos(self.get_current_pos - 1, position)
  end

Related Posts

Tags: ,