Skip to content

Instantly share code, notes, and snippets.

Created December 31, 2012 01:24
Show Gist options
  • Save anonymous/4416647 to your computer and use it in GitHub Desktop.
Save anonymous/4416647 to your computer and use it in GitHub Desktop.
FXRuby FXText styled text doesn't working, and crash when you ask for #getStyle().
#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)
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment