Well, I wanted to make my own syntax highlighter using
Wx::StyledTextCtrl.
The easiest way to do it seemed to parse the text contents in a
content-changed-event. But it doesn’t seem to work…
I tried to edit the scintilla sample and added this event(@sci is the
StyledTextCtrl):
@sci.evt_stc_change(@sci.get_id) do
@sci.clear_document_style
@sci.start_styling(1,31)
@sci.style_set_font_attr(10, 10, "Courier", true, true, true)
@sci.set_styling(2,10)
puts 1
end
This prints out “1” when you edit the text(twice actually, which i do
not
understand), but doesn’t change the text layout. But if I put it in an
event
triggered by a button, it will work(onEOL is triggered by clicking the
“show
end of line” button in the scintilla sample):
def onEOL
@sci.clear_document_style
@sci.start_styling(1,31)
@sci.style_set_font_attr(10, 10, “Courier”, true, true, true)
@sci.set_styling(2,10)
puts 1
end
As soon as I click the button, the second and third character get
styled. I
don’t get why it doesn’t work in the text content changed event. What
happens there, is it intended not to work? What is the best way to get
it to
work?