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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/watobo/gui/csrf_token_dialog.rb', line 52 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
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 42 43 44 45 46 47 48 49 50 |
# File 'lib/watobo/gui/csrf_token_dialog.rb', line 17 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 |