Class: Watobo::Gui::SessionIdSettings::SidPreview

Inherits:
FXText
  • Object
show all
Defined in:
lib/watobo/gui/session_management_dialog.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, opts) ⇒ SidPreview

Returns a new instance of SidPreview.


297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/watobo/gui/session_management_dialog.rb', line 297

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


263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/watobo/gui/session_management_dialog.rb', line 263

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(index1)

      else
        #     string1 = pattern
        #     string2 = pattern
      end
    end
  rescue => bang
    puts "!!!ERROR: could not highlight pattern"
    puts bang
  end
end