Class: RubyDebugView

Inherits:
Object
  • Object
show all
Includes:
TkUtil
Defined in:
ext/ae-ruby-debug/ae-ruby-debug.rb

Constant Summary collapse

B_STATE_ON =
'+'
B_STATE_OFF =
'-'
B_STATE_FREEZE =
'='

Instance Method Summary collapse

Constructor Details

#initialize(_frame, _controller) ⇒ RubyDebugView

Returns a new instance of RubyDebugView.



12
13
14
15
16
17
18
19
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 12

def initialize(_frame, _controller)
  @frame = _frame
  @controller = _controller
  self.build_ui
  @controller.rdc.add_listener(self)
  @nodes_to_open = Array.new
  #@break_hash = Hash.new
end

Instance Method Details

#bnext_state(_state) ⇒ Object



176
177
178
179
180
181
182
183
184
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 176

def bnext_state(_state)
  if _state == B_STATE_ON
    return B_STATE_FREEZE
  elsif _state == B_STATE_FREEZE
    return B_STATE_OFF
  elsif _state == B_STATE_OFF
    return B_STATE_ON
  end   
end

#break_list_add(_file, _line) ⇒ Object



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 363

def break_list_add(_file, _line)
  _file_node = file2node_name(_file) 
  _line_node = line2node_name(_file_node, _line)
  if !@tree_break.exist?(_file_node)
    @tree_break.insert('end', 'root' ,_file_node, {
      'fill'=>'#8080ff',
      'open'=>true,
      'anchor'=>'w',
      'font' => @controller.conf('font.bold'),
      'text' =>  _file
    })
  end
  
  if !@tree_break.exist?(_line_node)
    @tree_break.insert('end', _file_node ,_line_node, {
      'fill'=>'#f94867',
      'open'=>true,
      'anchor'=>'w',
      'font' => @controller.conf('font.bold'),
      'text' =>  "line: #{_line}"
    })
  end
end

#break_list_del(_file, _line) ⇒ Object



387
388
389
390
391
392
393
394
395
396
397
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 387

def break_list_del(_file, _line)
  _file_node = file2node_name(_file) 
  _line_node = line2node_name(_file_node, _line)
  if @tree_break.exist?(_line_node)
    @tree_break.delete(_line_node) 
    _bro = @tree_break.nodes(_file_node)
    if _bro && _bro.length > 0 
      @tree_break.delete(_file_node) 
    end
  end
end

#break_list_freeObject



410
411
412
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 410

def break_list_free
  @tree_break.delete(@tree_break.nodes('root'))
end

#break_list_select(_file, _line) ⇒ Object



399
400
401
402
403
404
405
406
407
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 399

def break_list_select(_file, _line)
  _file_node = file2node_name(_file) 
  _line_node = line2node_name(_file_node, _line)
  @tree_break.selection_clear
  if @tree_break.exist?(_line_node)
    @tree_break.selection_add(_line_node)
    @tree_break.see(_line_node)
  end
end

#build_break_panel(_tab_breakpoint) ⇒ Object



344
345
346
347
348
349
350
351
352
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 344

def build_break_panel(_tab_breakpoint)
  @tree_break = Tk::BWidget::Tree.new(_tab_breakpoint){
    background '#FFFFFF'
    relief 'flat'
    showlines true
    linesfill '#e7de8f'
    deltay 15
  }.place('relwidth' => 1,'relheight' => '1')
end

#build_buttons_setObject



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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 21

def build_buttons_set
  _relief = 'groove'
  @debug_button_box.add(
    'name'=>'debug_over',
    'background' => 'white',
    'anchor' => 'nw',
    'command'=>proc{self.debug_send(:step_over)},
    'helptext'=>'step over',
    'image'=> TkPhotoImage.new('dat' => D_NEXT_GIF),
    'relief'=> _relief
  )
  @debug_button_box.add(
    'name'=>'debug_into',
    'background' => 'white',
    'anchor' => 'nw',
    'command'=>proc{self.debug_send(:step_into)},
    'helptext'=>'step into',
    'image'=> TkPhotoImage.new('dat' => D_STEP_INTO_GIF),
    'relief'=>_relief
  )
  @debug_button_box.add(
    'name'=>'debug_out',
    'background' => 'white',
    'anchor' => 'nw',
    'helptext'=>'step out',
    'command'=>proc{self.debug_send(:step_out)},
    'image'=> TkPhotoImage.new('dat' => D_STEP_OUT_GIF),
    'relief'=>_relief
  )
  @debug_button_box.add(
    'name'=>'debug_resume',
    'background' => 'white',
    'anchor' => 'nw',
    'helptext'=>'resume',
    'image'=> TkPhotoImage.new('dat' => D_RESUME_GIF),
    'command'=>proc{self.debug_send(:resume)},
    'relief'=>_relief
  )

  @debug_button_box.add(
    'name'=>'debug_quit',
    'background' => 'white',
    'anchor' => 'nw',
    'helptext'=>'quit',
    'image'=> TkPhotoImage.new('dat' => D_QUIT_GIF),
    'command'=>proc{self.debug_send(:quit)},
    'relief'=>_relief
  )

end

#build_process_panel(_frame) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 130

def build_process_panel(_frame)
  @tree_process = Tk::BWidget::Tree.new(_frame){
    background '#FFFFFF'
    relief 'flat'
    showlines false
    deltay 15
    place('relwidth' => 1,'relheight' => '1')
  }
  @tree_process.textbind("Double-ButtonPress-1", proc{
    _selected = @tree_process.selection_get[0]
    if @tree_process.parent(_selected)=='client'
      _text = @tree_process.itemcget(_selected, 'text')
      pos = match_position_from_stack(_text)
      if pos.length >0 
  	     Arcadia.process_event(OpenBufferEvent.new(self,'file'=>pos[0], 'row'=>pos[1]))
        #EditorContract.instance.open_file(self, 'file'=>pos[0], 'line'=>pos[1])
      end
    end
  })

end

#build_uiObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 72

def build_ui
  _y = 22
  @debug_button_box = Tk::BWidget::ButtonBox.new(@frame){
    homogeneous true
    state 'disabled'
    #background '#3d7956'
  }.place('height'=> _y)
  
  @debug_frame = TkFrame.new(@frame){ 
      border  2
      place(
        'y'=>_y,
        'height'=> -_y,
        'relheight'=> 1,
        'relwidth'=> 1
      )
  }
  
  self.build_buttons_set
  
  sf = AGTkOSplittedFrames.new(@debug_frame,70)

  #-------------------------------------------------
  build_process_panel(sf.top_frame)
  #-------------------------------------------------

  @enb = Tk::BWidget::NoteBook.new(sf.bottom_frame){
    tabbevelsize 0
    internalborderwidth 2
    activeforeground 'red'
    activebackground 'yellow'
    #background 'black'
    borderwidth 1
    side $arcadia['conf']['editor.tabs.side']
    font $arcadia['conf']['editor.tabs.font']
    place('relwidth' => 1,'relheight' => '1')
  }
  _tab_var = @enb.insert('end', 'vars' ,
    'text'=> 'Variables',
    'raisecmd'=>proc{}
  )
  _tab_breakpoint = @enb.insert('end', 'Breakpoint' ,
    'text'=> 'Breakpoints',
    'raisecmd'=>proc{}
  )
#    _tab_catchpoint = @enb.insert('end', 'catchpoint' ,
#      'text'=> 'catchpoint',
#      'raisecmd'=>proc{}
#    )
  
  build_var_panel(_tab_var)
  build_break_panel(_tab_breakpoint)

  @stack_nodes = Array.new
  @enb.raise('vars')

end

#build_var_panel(_frame) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 186

def build_var_panel(_frame)
  _open_proc = proc do |_arg|
      inspect_node(_arg) if @nodes_to_open.include?(_arg)
  end
      
  @tree_var = Tk::BWidget::Tree.new(_frame){
    background '#FFFFFF'
    relief 'flat'
    showlines true
    linesfill '#e7de8f'
    deltay 15
    opencmd _open_proc
   # pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes')
  }.place('relwidth' => 1,'relheight' => '1','bordermode' => 'inside')

  _scrollcommand = proc{|*args| @tree_var.yview(*args)}
  _scrollbar = TkScrollbar.new(_frame){|s|
    width 8
    command _scrollcommand
  }.pack('side'=>'right', 'fill'=>'y')
  @tree_var.yscrollcommand proc{|first,last| _scrollbar.set(first,last)}
  
  @local_state = B_STATE_ON
  @instance_state = B_STATE_ON
  #@class_state = B_STATE_ON
  @global_state = B_STATE_OFF
  
  _i_on = TkPhotoImage.new('dat' => ON_GIF)
  _i_off = TkPhotoImage.new('dat' => OFF_GIF)
  _i_freeze = TkPhotoImage.new('dat' => FREEZE_GIF)

  _b_relief = 'groove'
  @b_local_onoff = TkButton.new(@tree_var){
      image  _i_on
      relief _b_relief
      state 'disabled'
      anchor 'nw'
  }.bind("1",proc{
    @local_state = bnext_state(@local_state)
    if @local_state == B_STATE_ON
      @b_local_onoff.image(_i_on)
      command_enabled(false)
      Thread.new{
        update_variables('local_var', @controller.rdc.variables('local_variables')) #if @tree_var.open?('local_var')
        command_enabled(true)
      }
    elsif @local_state == B_STATE_FREEZE
      @b_local_onoff.image(_i_freeze)
    elsif @local_state == B_STATE_OFF
      @b_local_onoff.image(_i_off)
      @tree_var.delete(@tree_var.nodes('local_var'))
    end
  })

  @tree_var.insert('end', 'root' ,'local_var', {
    #'deltax' => 0,
    #'padx'=>2,
    'fill'=>'#3f941b',
    'open'=>true,
    'anchor'=>'w',
    'font' => @controller.conf('font.bold'),
    'text' =>  "Local variables",
    'window' => @b_local_onoff
  })

  @b_instance_onoff = TkButton.new(@tree_var){
      image  _i_on
      relief _b_relief
      state 'disabled'
      anchor 'nw'
  }.bind("1",proc{
    @instance_state = bnext_state(@instance_state)
    if @instance_state == B_STATE_ON
      @b_instance_onoff.image(_i_on)
      command_enabled(false)
      Thread.new{
        update_variables('instance_var', @controller.rdc.variables('instance_variables')) #if @tree_var.open?('local_var')
        command_enabled(true)
      }
    elsif @instance_state == B_STATE_FREEZE
      @b_instance_onoff.image(_i_freeze)
    elsif @instance_state == B_STATE_OFF
      @b_instance_onoff.image(_i_off)
      @tree_var.delete(@tree_var.nodes('instance_var'))
    end
  })
  @tree_var.insert('end', 'root' ,'instance_var', {
    'fill'=>'#892541',
    'open'=>true,
    'anchor'=>'w',
    'font' => @controller.conf('font.bold'),
    'text' =>  "Instance variables",
    'window' => @b_instance_onoff
  })

#    @b_class_onoff = TkButton.new(@tree_var){
#        image  _i_on
#        relief _b_relief
#        state 'disabled'
#        anchor 'nw'
#    }.bind("1",proc{
#      @class_on = !@class_on
#      if @class_on
#        @b_class_onoff.image(_i_on)
#        command_enabled(false)
#        Thread.new{
#          update_variables('class_var', @controller.rdc.variables('class_variables')) #if @tree_var.open?('local_var')
#          command_enabled(true)
#        }
#      else
#        @b_class_onoff.image(_i_off)
#        @tree_var.delete(@tree_var.nodes('class_var'))
#      end
#    })
#    @tree_var.insert('end', 'root' ,'class_var', {
#      'fill'=>'#230bd7',
#      'open'=>true,
#      'anchor'=>'w',
#      'font' => @controller.conf('font.bold'),
#      'text' =>  "Class variables",
#      'window' => @b_class_onoff
#    })


  @b_global_onoff = TkButton.new(@tree_var){
      image  _i_off
      relief _b_relief
      state 'disabled'
      anchor 'nw'
  }.bind("1",proc{
    @global_state = bnext_state(@global_state)
    if @global_state == B_STATE_ON
      @b_global_onoff.image(_i_on)
      command_enabled(false)
      Thread.new{
        update_variables('global_var', @controller.rdc.variables('global_variables')) #if @tree_var.open?('local_var')
        command_enabled(true)
      }
    elsif @global_state == B_STATE_FREEZE
      @b_global_onoff.image(_i_freeze)
    elsif @global_state == B_STATE_OFF
      @b_global_onoff.image(_i_off)
      @tree_var.delete(@tree_var.nodes('global_var'))
    end
  })
  @tree_var.insert('end', 'root' ,'global_var', {
    'fill'=>'#f94867',
    'open'=>true,
    'anchor'=>'w',
    'font' => @controller.conf('font.bold'),
    'text' =>  "Global variables",
    'window' => @b_global_onoff
  })
  
  

end

#clearObject



414
415
416
417
418
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 414

def clear
  tree_var_free
  tree_process_free
  break_list_free
end

#command_enabled(_value) ⇒ Object



612
613
614
615
616
617
618
619
620
621
622
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 612

def command_enabled(_value)
  #Arcadia.new_debug_msg(self,"command_enabled= #{_value.to_s}")
  @c_on = _value
  _value ? _state = 'normal':_state = 'disabled'
  @debug_button_box.configure(:state=>_state) 
  @b_local_onoff.configure(:state=>_state) 
  @b_instance_onoff.configure(:state=>_state) 
  #@b_class_onoff.configure(:state=>_state) 
  @b_global_onoff.configure(:state=>_state) 
  Tk.update
end

#debug_send(_command) ⇒ Object



670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 670

def debug_send(_command)
  if @controller.rdc
    begin
      command_enabled(false)
      #@debug_button_box.configure(:state=>'disabled')
      Thread.new do
        Arcadia.process_event(StepDebugEvent.new(self, 'command'=>_command))
        #@controller.rdc.send(_command)
      end
      #@controller.rdc.send(_command)
    rescue Exception => e
      Arcadia.new_debug_msg(self,"---> "+e.to_s)
    end
  end
end

#file2node_name(_file) ⇒ Object



354
355
356
357
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 354

def file2node_name(_file)
  _s = ""
  _file.gsub("/",_s).gsub(".",_s).gsub(":",_s).gsub("\\",_s).gsub("-",_s)
end

#inspect_node(_node) ⇒ Object



518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 518

def inspect_node(_node)
  command_enabled(false)
  begin
    _var = var_name(_node)
    _o = @controller.rdc.debug_dump(_var)
    if _o.class == Hash
      var_deep(_node, _o)
    else 
      var_deep_string(_node, _o)
    end
  ensure
    command_enabled(true)
  end
end

#is_simple_class?(_var) ⇒ Boolean

Returns:

  • (Boolean)


501
502
503
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 501

def is_simple_class?(_var)
  ['Numeric','Fixnum','String','FalseClass','TrueClass','NilClass'].include?(_var.value_class) && !_var.value.to_s.strip.include?("\n")
end

#line2node_name(_parent, _line) ⇒ Object



359
360
361
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 359

def line2node_name(_parent, _line)
  "#{_parent}_#{_line.to_s}"
end

#match_position_from_stack(_line) ⇒ Object



456
457
458
459
460
461
462
463
464
465
466
467
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 456

def match_position_from_stack(_line)
  ret = Array.new
  _target = _line.sub("-->",'').strip
  matchline = _target.match(/#[0-9]*.*:([0-9]*)/)
  line_no = matchline[1].to_i if !matchline.nil? && matchline.length==2
  matchfile = _target.match(/#[0-9]*.(.*):[0-9]*/)
  filename = matchfile[1].to_s if !matchfile.nil? && matchfile.length==2
  if filename && line_no
    ret << filename << line_no
  end
  ret
end

#node_name(_node, _parent) ⇒ Object



602
603
604
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 602

def node_name(_node, _parent)
  return "#{_parent}@@@#{_node.gsub('$','__S__').gsub('&','__E__').gsub(':','__D__').gsub('!','__A__')}" 
end

#rdebug_client_update(_command, _result) ⇒ Object



421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 421

def rdebug_client_update(_command, _result)
#Arcadia.new_debug_msg(self,"on command #{_command}")
  return if @controller.rdc.nil? || !@controller.rdc.is_debugging_ready?
  begin
    if _command == 'quit'
      msg = "Really quit debug ? (y/n)"
      ans = Tk.messageBox('icon' => 'question', 'type' => 'yesno',
      'title' => '(Arcadia) Debug', 'message' => msg)
      if  ans == 'yes'
        debug_send(:quit_yes)
        clear
      else
        debug_send(:quit_no)
      end
    elsif _command == 'quit_yes'
        clear
    elsif  _command == 'quit_no'
      command_enabled(true)
    elsif _command != 'where' && _command != 'quit_yes'
      begin
        update_position
        update_variables('local_var', @controller.rdc.variables('local_variables')) if @local_state == B_STATE_ON
        update_variables('instance_var', @controller.rdc.variables('instance_variables')) if @instance_state == B_STATE_ON
        #update_variables('class_var', @controller.rdc.variables('class_variables')) if @instance_on
        #Arcadia.new_debug_msg(self,"on command #{_command}:global_variables")
        update_variables('global_var', @controller.rdc.variables('global_variables')) if @global_state == B_STATE_ON
      ensure
        command_enabled(true) if !@controller.rdc.nil? && @controller.rdc.is_debugging_ready? && (!_command.include?('quit') || _command.include?('quit_no')) 
      end
    end
  rescue Exception => e
    Arcadia.new_debug_msg(self,"on command #{_command}:#{e.inspect}")
  end
end

#show_expression(_exp, _hash) ⇒ Object



505
506
507
508
509
510
511
512
513
514
515
516
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 505

def show_expression(_exp, _hash)
  if !@tree_var.exist?('eval')
    @tree_var.insert('end', 'root' ,'eval', {
      'fill'=>'#4aadf7',
      'open'=>true,
      'anchor'=>'w',
      'font' => @controller.conf('font.bold'),
      'text' =>  "Eval selection"
    })
  end
  update_variables('eval', _hash)
end

#start_process(_filename) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 152

def start_process(_filename)
  @tree_process.insert('end', 'root' ,'server', {
    'text' =>  "Server => #{File.basename(_filename)} at #{@controller.conf('server.host')}:#{@controller.conf('server.port')}",
    'font' => @controller.conf('font.bold')
  })
  @tree_process.insert('end', 'server' ,'client', {
    'font' => @controller.conf('font.bold'),
    'text' =>  "Client"
  })
  @tree_process.open_tree('server',true)
end

#tree_process_freeObject



172
173
174
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 172

def tree_process_free
  @tree_process.delete(@tree_process.nodes('root'))
end

#tree_var_freeObject



164
165
166
167
168
169
170
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 164

def tree_var_free
  @tree_var.delete(@tree_var.nodes('local_var'))
  @tree_var.delete(@tree_var.nodes('instance_var'))
  @tree_var.delete(@tree_var.nodes('global_var'))
  #@tree_var.delete(@tree_var.nodes('class_var'))
  @tree_var.delete(@tree_var.nodes('eval')) if @tree_var.exist?('eval')
end

#update_positionObject



469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 469

def update_position
  stack = @controller.rdc.where
  #Arcadia.new_debug_msg(self,stack)
  if !stack.nil?
    stack = stack.split(/\n/)
    line_no = -1
    if !stack[0].nil?
      pos = match_position_from_stack(stack[0])
    end
    if pos.length > 0
      _file = File.expand_path(pos[0])
      Arcadia.broadcast_event(DebugStepInfoEvent.new(self,'file'=> _file, 'row'=>pos[1]))
      #DebugContract.instance.debug_step(self, 'file'=> _file, 'line'=>pos[1])
      break_list_select(_file, pos[1].to_s)
    end
    i = 0
    @tree_process.delete(@stack_nodes)
    stack.each do |line| 
      _node = "c#{i.to_s}"
      @tree_process.insert('end', 'client' ,_node, {
     #   'deltax' => 0,
     #   'padx'=>2,
        'font' => @controller.conf('font'),
        'text' =>  line,
        'helptext' => line
      })
      @stack_nodes << _node
      i = i+1
    end
  end
end

#update_variables(_parent_node, _var) ⇒ Object



624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 624

def update_variables(_parent_node, _var)
  if _var.keys.sort == @tree_var.nodes(_parent_node).collect! {|x| var_name(x).to_s}.sort
    _var.each{|k,v|
      _n = node_name(k, _parent_node)
      if is_simple_class?(v)
        _text = var_format(k,v.value_class,v.value)
        _drawcross = 'auto'
      else
        _text = var_format(k,v.value_class)
        _drawcross = 'always'
        @nodes_to_open << _n if !@nodes_to_open.include?(_n)
        inspect_node(_n) if bool(@tree_var.itemcget(@tree_var.tagid(_n), 'open'))
      end
      _node = @tree_var.itemconfigure(_n, 
        'text' =>  _text, 
        'helptext' => v.value,
        'drawcross' => _drawcross
      )
    }          
  else 
    @nodes_to_open.clear
    @tree_var.delete(@tree_var.nodes(_parent_node))
    #@nodes[_parent_node].clear
    _var.keys.sort.each{|k|
        v = _var[k]
        _n = node_name(k, _parent_node)
        if is_simple_class?(v)
          _text = var_format(k,v.value_class,v.value)
          _drawcross = 'auto'
        else
          _text = var_format(k,v.value_class)
          _drawcross = 'always'
          @nodes_to_open << _n
        end
        @tree_var.insert('end', _parent_node ,_n, {
          'font' => @controller.conf('font'),
          'text' =>  _text,
          'helptext' => v.value,
          'drawcross' => _drawcross,
          'anchor'=>'w'
        })
    }
  end
  Tk.update
end

#var_deep(_var, _hash) ⇒ Object



533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 533

def var_deep(_var, _hash)
#    _var_cla = _hash['__CLASS__']
#    _var_len = _hash['__LENGTH__']
#    @tree_var.itemconfigure(_var, 'text' =>  "#{_var_cla}:#{_var_len}")
  return nil if _hash.nil? 
  return _hash.to_s if _hash.class != Hash
  if _hash['__CLASS__']=='Array'
   _sorted_keys = _hash.keys.collect!{|x| x.to_i}.sort.collect!{|x| x.to_s}
  else
   _sorted_keys = _hash.keys.sort
  end
  _sorted_keys.each{|k|
  #_hash.keys.sort.each{|k|
    v = _hash[k]
    next if k=='__CLASS__'
    _complex = v.class == Hash
    if _complex
      _text = var_format(k,v['__CLASS__'])
    elsif (k=='__LENGTH__') && v=='0'
      _text = '{}'
    elsif (k=='__LENGTH__') && v!='0'
      next
    else
      _text = var_format(k,nil,v)
    end
    _node = node_name(k, _var)
    if @tree_var.exist?(_node)
      @tree_var.itemconfigure(_node, 'text' =>  _text)
    else
      @tree_var.insert('end', _var ,_node, {
        'font' => @controller.conf('font'),
        'text' =>  _text,
        'helptext' => v,
        'anchor'=>'w'
      })
    end
    var_deep(_node,v) if _complex
  }
end

#var_deep_string(_var, _str) ⇒ Object



573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 573

def var_deep_string(_var, _str)
  @tree_var.delete(@tree_var.nodes(_var))
  return nil if _str.nil? 
  _str = _str.to_s if !_str.kind_of?(String)
  a_str = _str.split("\n")
  a_str.each_with_index{|v,i|
    _node = node_name(i.to_s, _var)
    @tree_var.insert('end', _var ,_node, {
      'font' => @controller.conf('font'),
      'text' =>  v,
      'fill' => '#79ca77',
      'anchor'=>'w'
    })
  }
end

#var_format(_name, _class, _value = nil) ⇒ Object



590
591
592
593
594
595
596
597
598
599
600
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 590

def var_format(_name, _class, _value=nil)
  if !_value.nil? && !_class.nil?
    return "#{_name.to_s.strip} => #{_value.to_s.strip} [#{_class.to_s.strip}]"
  elsif _value.nil? && !_class.nil?
    return "#{_name.to_s.strip} [#{_class.to_s.strip}]"
  elsif !_value.nil? && _class.nil?
    return "#{_name.to_s.strip} => #{_value.to_s.strip}"
  elsif _value.nil? && _class.nil?
    return "#{_name.to_s.strip} => {}"
  end
end

#var_name(_node) ⇒ Object



606
607
608
609
610
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 606

def var_name(_node)
  #_parent = @tree_var.parent(_node)
  #return _node.sub("#{_parent}_", '') 
  return _node.split('@@@')[-1].gsub('__S__','$').gsub('__E__','&').gsub('__D__',':').gsub('__A__','!')
end