Class: Watobo::Gui::TokenSettings::SidPreview
- Inherits:
-
FXText
- Object
- FXText
- Watobo::Gui::TokenSettings::SidPreview
- Defined in:
- lib/watobo/gui/csrf_token_dialog.rb
Instance Method Summary collapse
- #highlight(pattern) ⇒ Object
-
#initialize(parent, opts) ⇒ SidPreview
constructor
A new instance of SidPreview.
Constructor Details
#initialize(parent, opts) ⇒ SidPreview
Returns a new instance of SidPreview.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/watobo/gui/csrf_token_dialog.rb', line 43 def initialize(parent, opts) super(parent, opts) @style = 1 # default style # Construct some hilite styles hs_green = FXHiliteStyle.new hs_green.normalForeColor = FXRGBA(255,255,255,255) #FXColor::Red hs_green.normalBackColor = FXRGBA(0,255,0,1) # FXColor::White hs_green.style = FXText::STYLE_BOLD hs_red = FXHiliteStyle.new hs_red.normalForeColor = FXRGBA(255,255,255,255) #FXColor::Red hs_red.normalBackColor = FXRGBA(255,0,0,1) # FXColor::White hs_red.style = FXText::STYLE_BOLD self.styled = true # Set the styles self.hiliteStyles = [ hs_green, hs_red] self.editable = false end |
Instance Method Details
#highlight(pattern) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/watobo/gui/csrf_token_dialog.rb', line 8 def highlight(pattern) self.setText(self.to_s) begin # puts pattern if self.to_s =~ /#{pattern}/ then if $1 and $2 then # puts "MATCH (#{$1}/#{$2})" string1 = $1 string2 = $2 index1 = nil index1 = self.to_s.index(string1) if index1 then self.changeStyle(index1,string1.length,1) end index2 = nil index2 = self.to_s.index(string2) if index2 then self.changeStyle(index2,string2.length,1) end self.makePositionVisible(index2+string2.length) self.makePositionVisible(index1) else # string1 = pattern # string2 = pattern end end rescue => bang puts "!!!ERROR: could not highlight pattern" puts bang end end |