Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save larskanis/4433842 to your computer and use it in GitHub Desktop.
Save larskanis/4433842 to your computer and use it in GitHub Desktop.
#encoding: utf-8
require 'fox16'
include Fox
class HelloWindow < FXMainWindow
def initialize(app)
ventana = super(app, "Hello, World!", width: 600, height: 400)
MiFXText.new(ventana)
end
def create
super
show(PLACEMENT_SCREEN)
end
end
######################################################################################
class MiFXText < FXText
def initialize(widget_padre)
super(widget_padre, opts: TEXT_READONLY|TEXT_WORDWRAP|TEXT_AUTOINDENT|LAYOUT_FILL|LAYOUT_FIX_WIDTH, width: 550)
self.styled = true
appendStyledText('Observaciones: ', FXText::STYLE_UNDERLINE, true)
insertStyledText(4, 'LALA', FXText::STYLE_BOLD)
appendText('The text widget supports editing of multiple lines of text. An optional style table can provide text coloring based on the contents of an optional parallel style buffer, which is maintained as text is edited. In a typical scenario, the contents of the style buffer is either directly written when the text is added to the widget, or is continually modified by editing the text via syntax-based highlighting engine which colors the text based on syntactical patterns.')
changeStyle(0, 5, FXText::STYLE_UNDERLINE)
#p styled?
p getStyle(54) #HERE! EVERYTHING CRASH!, the other comments are for seeing purpose, make it code and you will see what happen
#p textStyle
#p FXText::STYLE_UNDERLINE
#p FXText::STYLE_BOLD
#textStyle=(4)
#p textStyle
#styled=(true)
end
end
######################################################################################
if __FILE__ == $0
FXApp.new do |app|
HelloWindow.new(app)
app.create
app.run
end
end
@larskanis
Copy link
Author

This is actually a bug in the fox toolkit. If you set the FXText to styled=true, then the memory needed for getStyle is allocated. If not libfox crashes.

May you open a bug report on fox-toolkit? I'm a bit busy currently.

@damian-m-g
Copy link

Yes Lars, don't worry...

@damian-m-g
Copy link

Hi Lars, I've been aside of FXRuby for a while, was giving a walk across here and see this open yet. Jeroen answered that this is fixed en 1.7.* version. Since we are using 1.6.* here(not very sure) this will continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment