Class: RegexpDebuggerFrame
- Inherits:
-
Wx::Frame
- Object
- Wx::Frame
- RegexpDebuggerFrame
- Defined in:
- lib/regexp_debugger.rb
Instance Method Summary collapse
-
#initialize(title, pos, size, style = Wx::DEFAULT_FRAME_STYLE) ⇒ RegexpDebuggerFrame
constructor
A new instance of RegexpDebuggerFrame.
- #on_test(event) ⇒ Object
Constructor Details
#initialize(title, pos, size, style = Wx::DEFAULT_FRAME_STYLE) ⇒ RegexpDebuggerFrame
Returns a new instance of RegexpDebuggerFrame.
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 42 43 44 45 46 |
# File 'lib/regexp_debugger.rb', line 12 def initialize(title, pos, size, style = Wx::DEFAULT_FRAME_STYLE) super(nil,-1,title,pos,size,style) Wx::StaticText.new(self, -1, "/", Wx::Point.new(20, 0)) Wx::StaticText.new(self, -1, "/", Wx::Point.new(440, 0)) @reg = Wx::TextCtrl.new( self, -1, "", Wx::Point.new(30,0), Wx::Size.new(400,-1)) @exp = Wx::TextCtrl.new( self, -1, "", Wx::Point.new(450,0), Wx::Size.new(80,-1)) @txt = Wx::StyledTextCtrl.new( self, -1, Wx::Point.new(30, 30), Wx::Size.new(500,300)) @btn = Wx::Button.new( self, Wx::ID_HIGHEST + 1, " Test ", Wx::Point.new(405, 340) ) ( Wx::ID_HIGHEST + 1) {|event| on_test(event)} @out = [] 9.times do |i| Wx::StaticText.new(self, -1, "$#{i + 1}", Wx::Point.new(10,380 + 30 * i)) @out << Wx::TextCtrl.new( self, -1, "", Wx::Point.new(30,380 + 30 * i), Wx::Size.new(500,-1)) end (1, Wx::ST_SIZEGRIP) set_status_text("Welcome to the Regexp Debugger!") end |
Instance Method Details
#on_test(event) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/regexp_debugger.rb', line 48 def on_test(event) regexp = eval("/" + @reg.get_value + "/" + @exp.get_value) match = @txt.get_text.match(regexp) if match set_status_text("match!") @out.each_with_index {|out, index| out.set_value(match[index + 1].to_s) } @btn.set_label(" test(match!) ") @btn.set_background_colour(Wx::BLUE) else set_status_text("dismatch!!!") @btn.set_label("test(dismatch!!!)") @btn.set_background_colour(Wx::RED) end puts @btn.methods.sort rescue Exception => excep dlg = Wx::MessageDialog.new( self, excep.to_s, 'Find String Not Found in Demo File', Wx::OK | Wx::ICON_ERROR ) dlg.show_modal dlg.destroy end |