arcadia 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,8 +1,8 @@
1
1
  = Arcadia Ide
2
- version 0.9.2
2
+ version 0.9.3
3
3
 
4
4
  by Antonio Galeone
5
- on Nov 21, 2010
5
+ on Feb 12, 2011
6
6
 
7
7
 
8
8
  == About
@@ -16,11 +16,10 @@ Some of Arcadia ide project features include:
16
16
  * Working on any platform where ruby and tcl-tk work.
17
17
  * Highly extensibility architecture.
18
18
 
19
- == In this release 0.9.2
19
+ == In this release 0.9.3
20
20
 
21
21
  [Improvements]
22
- - bugs fixed in case of ruby 1.8 enviroment
23
- - supported the maximized state saving of the main window
22
+ - bugs fixed
24
23
 
25
24
  == Dependencies
26
25
  - rubygems
@@ -29,7 +28,6 @@ Some of Arcadia ide project features include:
29
28
  - ack (optional)
30
29
  - gem coderay
31
30
  - gem ruby-debug (ruby-debug19 on ruby 1.9)
32
- - gem whichr
33
31
  - gem win32-process (only on windows)
34
32
  - gem ruby-wmi (only on windows)
35
33
 
@@ -42,7 +40,7 @@ There are two way:
42
40
  b. unzip (on windows) arcadia-<version>.zip
43
41
 
44
42
  == How to run
45
- * exec on command line "ruby <path/>arcadia"
43
+ * exec on command line "arcadia" or "ruby <path/>arcadia"
46
44
 
47
45
 
48
46
  == Short User guide
@@ -54,13 +52,11 @@ for the dynamic layout functions.
54
52
 
55
53
  ==== Main Toolbar
56
54
  The toolbar button are in order:
57
- - new, open, save
58
- (relatively to edit operation)
55
+ - new, open, save, find
56
+ (relatively to edit/find operation)
59
57
  - run current, run last
60
58
  (for execute the raised file in the editor or the last runned file)
61
59
  after "run current" there is a menubutton to choose a configurated runner to apply at current file
62
- - show rad palette
63
- (for tk rad need)
64
60
  - debug current, debug last, quit debug panel
65
61
  (for debug need)
66
62
  - quit (to exit from arcadia)
@@ -102,21 +98,6 @@ It is a navigational tree:
102
98
  The last used files are organizing in tree so you can reopen them or there
103
99
  directory by clicking on the tree node.
104
100
 
105
- ==== Rad Palette (instable)
106
- It contain the wrapper components for the tk gui building.
107
- It is in very unstabled and incomplete state.
108
- The first component is a TkTopLevel wrapper, when you click on it a new form is created and a
109
- Object inspector appears.
110
- The other components must be first selected and then created by clicking on container widget.
111
- The so created widgets has a popup menu for deleting them or in the toplevel case to switch
112
- to a code view.
113
- On the palette there are also two button, one for deselect and other for copy from the selected
114
- created widget. The copy action copy also the code into the clipboard, so you can copy the
115
- code rapresenting the gui into the embedded editor or into external editor.
116
-
117
- ==== Rad Object Inspector (instable)
118
- It is for modify the widget property at runtime
119
-
120
101
  ==== Debug
121
102
  Require ruby-debug gem.
122
103
  It is created when a debug session init.
@@ -133,10 +114,11 @@ under ~/.arcadia directory. The format of property definition are:
133
114
  I have tested arcadia with ruby 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.9.1, 1.9.2 on
134
115
 
135
116
  * Archlinux
117
+ * Fedora
136
118
  * Ubuntu
137
119
  * FreeBsd6.x, FreeBsd7.x,
138
120
  * Vector linux 5.*,
139
- * Windows 2000/XP,
121
+ * Windows 2000/XP/7,
140
122
  * Cygwin (note: same page fault error on dll under cygwin may be solved in this way:
141
123
  by ash.exe exec "/bin/rebaseall").
142
124
  If you will test arcadia on other operating system sends me an e-mail.
@@ -154,6 +136,7 @@ For all questions:
154
136
  antonio-galeone@rubyforge.org
155
137
 
156
138
  For bugs, support request, features request:
157
- http://groups.google.it/group/arcadia-ruby-ide
139
+ http://github.com/angal/arcadia/issues
140
+
158
141
  Repository at:
159
142
  http://github.com/angal/arcadia/tree/master
@@ -70,7 +70,7 @@ class Breakpoints < ArcadiaExt
70
70
  # end
71
71
  # }
72
72
 
73
- @tree_break = Tk::BWidget::Tree.new(self.frame.hinner_frame, Arcadia.style('treepanel')){
73
+ @tree_break = BWidgetTreePatched.new(self.frame.hinner_frame, Arcadia.style('treepanel')){
74
74
  #showlines true
75
75
  deltay 18
76
76
  padx 25
@@ -91,18 +91,15 @@ class Breakpoints < ArcadiaExt
91
91
  end
92
92
 
93
93
  def goto_select_item
94
- _file, _line = get_tree_selection(@tree_break)
94
+ _file, _line = get_tree_selection
95
95
  if _file && _line
96
96
  Arcadia.process_event(OpenBufferEvent.new(self,'file'=>_file, 'row'=>_line))
97
97
  elsif _file
98
98
  Arcadia.process_event(OpenBufferEvent.new(self,'file'=>_file, 'row'=>0))
99
99
  end
100
100
  end
101
-
102
-
103
-
104
- def raise_clear_selected(_delete=false)
105
- _file, _line = get_tree_selection(@tree_break)
101
+
102
+ def clear_node(_file=nil, _line=nil, _delete=false)
106
103
  if _file && _line
107
104
  Arcadia.process_event(UnsetBreakpointEvent.new(self, 'file'=>_file, 'row'=>_line, 'delete'=>_delete))
108
105
  elsif _file
@@ -117,6 +114,19 @@ class Breakpoints < ArcadiaExt
117
114
  end
118
115
  end
119
116
 
117
+ def raise_clear_selected(_delete=false)
118
+ _file, _line = get_tree_selection
119
+ clear_node(_file, _line, _delete)
120
+ end
121
+
122
+ def clear_all(_delete=false)
123
+ nodes = @tree_break.nodes('root')
124
+ nodes.each{|n|
125
+ _file, _line = node2file_line(n)
126
+ clear_node(_file, _line, _delete)
127
+ }
128
+ end
129
+
120
130
  def build_popup
121
131
  _pop_up = TkMenu.new(
122
132
  :parent=>@tree_break,
@@ -135,21 +145,28 @@ class Breakpoints < ArcadiaExt
135
145
 
136
146
  _pop_up.insert('end',
137
147
  :command,
138
- :label=>'Clear breakpoint',
148
+ :label=>'Clear selected breakpoint',
139
149
  :hidemargin => false,
140
150
  :command=> proc{raise_clear_selected}
141
151
  )
142
152
 
143
153
  _pop_up.insert('end',
144
154
  :command,
145
- :label=>'Delete breakpoint',
155
+ :label=>'Delete selected breakpoint',
146
156
  :hidemargin => false,
147
157
  :command=> proc{raise_clear_selected(true)}
148
158
  )
149
159
 
150
160
  _pop_up.insert('end',
151
161
  :command,
152
- :label=>'Goto breakpoint',
162
+ :label=>'Delete all breakpoints',
163
+ :hidemargin => false,
164
+ :command=> proc{clear_all(true)}
165
+ )
166
+
167
+ _pop_up.insert('end',
168
+ :command,
169
+ :label=>'Goto selected breakpoint',
153
170
  :hidemargin => false,
154
171
  :command=> proc{goto_select_item}
155
172
  )
@@ -159,8 +176,9 @@ class Breakpoints < ArcadiaExt
159
176
  proc{|*x|
160
177
  _x = TkWinfo.pointerx(@tree_break)
161
178
  _y = TkWinfo.pointery(@tree_break)
162
- _selected = @tree_break.selection_get[0]
163
- _file, _line = get_tree_selection(@tree_break)
179
+ #_selected = @tree_break.selection_get[0]
180
+ _selected = @tree_break.selected
181
+ _file, _line = get_tree_selection
164
182
  _label = _file
165
183
  if _line
166
184
  _label << " line: #{_line}"
@@ -171,19 +189,26 @@ class Breakpoints < ArcadiaExt
171
189
  })
172
190
  end
173
191
 
174
- def get_tree_selection(_tree)
175
- _ret = Array.new
176
- _selected = _tree.selection_get[0]
192
+ def get_tree_selection
193
+ #_selected = @tree_break.selection_get[0]
194
+ _selected = @tree_break.selected
177
195
  if _selected
178
- _node_name, _line = _selected.split('_')
179
- _ret << _tree.itemcget(_node_name, 'text')
180
- _ret << _line if _line
196
+ return node2file_line(_selected)
197
+ else
198
+ return Array.new
181
199
  end
182
- _ret
183
200
  end
184
201
 
202
+ def node2file_line(_node)
203
+ _ret = Array.new
204
+ _node_name, _line = _node.split('_')
205
+ _ret << @tree_break.itemcget(_node_name, 'text')
206
+ _ret << _line if _line
207
+ _ret
208
+ end
185
209
 
186
210
  def on_debug(_event)
211
+ return if _event.file.nil?
187
212
  case _event
188
213
  when SetBreakpointEvent
189
214
  ensure_build_ui
@@ -22,7 +22,6 @@ class Project
22
22
  end
23
23
 
24
24
  class DirProjects < ArcadiaExt
25
- include Autils
26
25
  attr_reader :htree
27
26
 
28
27
  def sync_on
@@ -146,7 +145,7 @@ class DirProjects < ArcadiaExt
146
145
  },"%K")
147
146
 
148
147
  do_double_click = proc{
149
- _selected = @htree.selection_get[0]
148
+ _selected = @htree.selected
150
149
  if File.ftype(node2file(_selected)) == 'directory'
151
150
  if !_selected.nil? && @htree.open?(node2file(_selected))
152
151
  @htree.close_tree(node2file(_selected))
@@ -167,9 +166,9 @@ class DirProjects < ArcadiaExt
167
166
  @sync = false
168
167
  begin
169
168
  Arcadia.process_event(OpenBufferTransientEvent.new(self,'file'=>node2file(_selected)))
170
- ensure
169
+ ensure
171
170
  @sync = _sync_val
172
- end
171
+ end
173
172
  end
174
173
  else
175
174
  shure_delete_node(_selected)
@@ -180,7 +179,7 @@ class DirProjects < ArcadiaExt
180
179
  def key_press(_keysym)
181
180
  case _keysym
182
181
  when 'F5'
183
- _selected = self.selected
182
+ _selected = @htree.selected
184
183
  do_refresh(_selected)
185
184
  end
186
185
  end
@@ -300,7 +299,7 @@ class DirProjects < ArcadiaExt
300
299
  :label=>'New folder',
301
300
  :hidemargin => false,
302
301
  :command=> proc{
303
- _selected = self.selected
302
+ _selected = @htree.selected
304
303
  if _selected
305
304
  do_new_folder(_selected)
306
305
  end
@@ -312,7 +311,7 @@ class DirProjects < ArcadiaExt
312
311
  :label=>'New file',
313
312
  :hidemargin => false,
314
313
  :command=> proc{
315
- _selected = self.selected
314
+ _selected = @htree.selected
316
315
  if _selected
317
316
  do_new_file(_selected)
318
317
  end
@@ -339,7 +338,7 @@ class DirProjects < ArcadiaExt
339
338
  :label=>'Rename',
340
339
  :hidemargin => false,
341
340
  :command=> proc{
342
- _selected = self.selected
341
+ _selected = @htree.selected
343
342
  if _selected
344
343
  do_rename(_selected)
345
344
  end
@@ -350,7 +349,7 @@ class DirProjects < ArcadiaExt
350
349
  :label=>'Move',
351
350
  :hidemargin => false,
352
351
  :command=> proc{
353
- _selected = self.selected
352
+ _selected = @htree.selected
354
353
  if _selected
355
354
  _idir = File.split(_selected)[0]
356
355
  _dir=Tk.chooseDirectory('initialdir'=>_idir,'mustexist'=>true)
@@ -379,7 +378,7 @@ class DirProjects < ArcadiaExt
379
378
  :label=>'Find in files...',
380
379
  :hidemargin => false,
381
380
  :command=> proc{
382
- _target = self.selected
381
+ _target = @htree.selected
383
382
  if _target
384
383
  _target = File.dirname(_target) if File.ftype(_target) == 'file'
385
384
  Arcadia.process_event(SearchInFilesEvent.new(self,'dir'=>_target))
@@ -392,7 +391,7 @@ class DirProjects < ArcadiaExt
392
391
  :label=>'Act in files...',
393
392
  :hidemargin => false,
394
393
  :command=> proc{
395
- _target = self.selected
394
+ _target = @htree.selected
396
395
  if _target
397
396
  _target = File.dirname(_target) if File.ftype(_target) == 'file'
398
397
  Arcadia.process_event(AckInFilesEvent.new(self,'dir'=>_target))
@@ -420,7 +419,7 @@ class DirProjects < ArcadiaExt
420
419
  :label=>'Close Project',
421
420
  :hidemargin => false,
422
421
  :command=> proc{
423
- _selected = self.selected
422
+ _selected = @htree.selected
424
423
  if _selected
425
424
  #p _selected
426
425
  do_close_project(_selected)
@@ -432,7 +431,7 @@ class DirProjects < ArcadiaExt
432
431
  :label=>'Refresh',
433
432
  :hidemargin => false,
434
433
  :command=> proc{
435
- _selected = self.selected
434
+ _selected = @htree.selected
436
435
  do_refresh(_selected)
437
436
  }
438
437
  )
@@ -441,7 +440,7 @@ class DirProjects < ArcadiaExt
441
440
  :label=>'Delete',
442
441
  :hidemargin => false,
443
442
  :command=> proc{
444
- _selected = self.selected
443
+ _selected = @htree.selected
445
444
  if _selected
446
445
  do_delete(_selected)
447
446
  end
@@ -462,7 +461,7 @@ class DirProjects < ArcadiaExt
462
461
  shure_select_node(@current_opened_folder)
463
462
  @last_current_opened_folder = @current_opened_folder
464
463
  else
465
- _selected = self.selected
464
+ _selected = @htree.selected
466
465
  if _selected && @htree.exist?(_selected)
467
466
  _parent = @htree.parent(_selected)
468
467
  if _parent && _parent != 'root'
@@ -474,25 +473,29 @@ class DirProjects < ArcadiaExt
474
473
  end
475
474
  end
476
475
 
477
- def selected
478
- if @htree.selection_get[0]
479
- if @htree.selection_get[0].length >0
480
- _selected = ""
481
- if String.method_defined?(:lines)
482
- selection_lines = @htree.selection_get[0].lines
483
- else
484
- selection_lines = @htree.selection_get[0].split("\n")
485
- end
486
- selection_lines.each{|_block|
487
- _selected = _selected + _block.to_s + "\s"
488
- }
489
- _selected = _selected.strip
490
- else
491
- _selected = @htree.selection_get[0]
492
- end
493
- end
494
- return _selected
495
- end
476
+ # def selected
477
+ # if @htree.selection_get[0]
478
+ # if @htree.selection_get[0].length >0
479
+ # _selected = ""
480
+ # if @htree.selection_get[0].instance_of?(Array)
481
+ # selection_lines = @htree.selection_get[0]
482
+ # else
483
+ # if String.method_defined?(:lines)
484
+ # selection_lines = @htree.selection_get[0].lines
485
+ # else
486
+ # selection_lines = @htree.selection_get[0].split("\n")
487
+ # end
488
+ # end
489
+ # selection_lines.each{|_block|
490
+ # _selected = _selected + _block.to_s + "\s"
491
+ # }
492
+ # _selected = _selected.strip
493
+ # else
494
+ # _selected = @htree.selection_get[0]
495
+ # end
496
+ # end
497
+ # return _selected
498
+ # end
496
499
 
497
500
  def do_new_project(_parent_folder_node=nil)
498
501
  if _parent_folder_node.nil?
@@ -929,7 +932,7 @@ class DirProjects < ArcadiaExt
929
932
  end
930
933
 
931
934
  def on_before_save_as_buffer(_event)
932
- _selected = self.selected
935
+ _selected = @htree.selected
933
936
  if _selected
934
937
  tpy = File.ftype(node2file(_selected))
935
938
  if tpy == 'directory'
@@ -799,7 +799,8 @@ class AgEditorOutline
799
799
  sync_val = @bar.sync
800
800
  @bar.sync=false
801
801
  begin
802
- _line = _self.selection_get[0]
802
+ #_line = _self.selection_get[0]
803
+ _line = _self.selected
803
804
  _index =_line.to_s+'.0'
804
805
  _hinner_text = @tree_exp.itemcget(_line,'text').strip
805
806
  _editor_line = @editor.text.get(_index, _index+ ' lineend')
@@ -812,7 +813,8 @@ class AgEditorOutline
812
813
  build_tree(_line)
813
814
  Tk.update
814
815
  }
815
- _line = _self.selection_get[0]
816
+ #_line = _self.selection_get[0]
817
+ _line = _self.selected
816
818
  _index =_line.to_s+'.0'
817
819
  end
818
820
  @editor.text.set_focus
@@ -940,11 +942,14 @@ end
940
942
 
941
943
  class AgEditor
942
944
  attr_accessor :file
945
+ attr_accessor :line_numbers_visible
946
+ attr_accessor :id
943
947
  attr_reader :read_only
944
948
  attr_reader :page_frame
945
949
  attr_reader :text, :root
946
950
  attr_reader :outline
947
951
  attr_reader :highlighting
952
+ attr_reader :last_tmp_file
948
953
  def initialize(_controller, _page_frame)
949
954
  @controller = _controller
950
955
  @page_frame = _page_frame
@@ -962,6 +967,7 @@ class AgEditor
962
967
  @tabs_show = false
963
968
  @spaces_show = false
964
969
  @line_numbers_visible = @controller.conf('line-numbers') == 'yes'
970
+ @id = -1
965
971
  end
966
972
 
967
973
  def modified_from_opening?
@@ -1050,7 +1056,11 @@ class AgEditor
1050
1056
 
1051
1057
  def create_temp_file
1052
1058
  if @file
1053
- _file = @file+'~~'
1059
+ n=0
1060
+ while File.exist?("#{@file}#{n*'_'}~~")
1061
+ n+=1
1062
+ end
1063
+ _file = "#{@file}#{n*'_'}~~"
1054
1064
  else
1055
1065
  n=0
1056
1066
  while File.exist?(File.join(Arcadia.instance.local_dir,"buffer#{n}~~"))
@@ -1066,6 +1076,7 @@ class AgEditor
1066
1076
  ensure
1067
1077
  f.close unless f.nil?
1068
1078
  end
1079
+ @last_tmp_file = _file
1069
1080
  _file
1070
1081
  end
1071
1082
 
@@ -1889,13 +1900,16 @@ class AgEditor
1889
1900
  _i1 = _index+' linestart'
1890
1901
  _i2 = _i1+' + 2 chars'
1891
1902
 
1892
- if @controller.breakpoint_lines_on_file(@file).include?(_line)
1903
+ if @file && @controller.breakpoint_lines_on_file(@file).include?(_line)
1893
1904
  #remove_tag_breakpoint(_index)
1894
- @controller.breakpoint_del(@file, _line)
1905
+ @controller.breakpoint_del(@file, _line, @id)
1906
+ elsif @file.nil? && @controller.breakpoint_lines_on_file("__TMP__#{@id}").include?(_line)
1907
+ #remove_tag_breakpoint(_index)
1908
+ @controller.breakpoint_del(@file, _line, @id)
1895
1909
  else
1896
1910
  @text_line_num.tag_remove('current',_i1,_i2)
1897
1911
  #add_tag_breakpoint(_index)
1898
- @controller.breakpoint_add(@file, _line)
1912
+ @controller.breakpoint_add(@file, _line, @id)
1899
1913
  end
1900
1914
  end
1901
1915
  end
@@ -1993,7 +2007,6 @@ class AgEditor
1993
2007
  end
1994
2008
  end
1995
2009
 
1996
-
1997
2010
  def do_tag_configure_global(_name)
1998
2011
  h = Hash.new
1999
2012
 
@@ -2038,7 +2051,6 @@ class AgEditor
2038
2051
  end
2039
2052
  end
2040
2053
 
2041
-
2042
2054
  def pop_up_menu
2043
2055
  @pop_up = TkMenu.new(
2044
2056
  :parent=>@text,
@@ -2055,7 +2067,6 @@ class AgEditor
2055
2067
  :font => "#{Arcadia.conf('menu.font')} bold",
2056
2068
  :hidemargin => true
2057
2069
  )
2058
-
2059
2070
  #Arcadia.instance.main_menu.update_style(@pop_up)
2060
2071
  @pop_up.insert('end',
2061
2072
  :command,
@@ -2794,8 +2805,19 @@ class AgEditor
2794
2805
  line_end_chars = _line_end.to_s.length
2795
2806
  if @last_line_end_chars != line_end_chars
2796
2807
  if @line_num_rx_e.nil?
2797
- @line_num_rx_e, @line_num_ry_e, @line_num_width_e, @line_num_heigth_e = @text_line_num.bbox("0.1 lineend - 1chars");
2808
+ @line_num_rx_e, @line_num_ry_e, @line_num_width_e, @line_num_heigth_e = @text_line_num.bbox("0.1 lineend - 1 chars");
2809
+ if @line_num_rx_e.nil?
2810
+ @line_num_rx_e = 0
2811
+ end
2812
+ if @line_num_width_e.nil?
2813
+ linfo_x, linfo_y, linfo_w, linfo_h, linfo_b = @text_line_num.dlineinfo('0.1')
2814
+ if linfo_w
2815
+ @line_num_width_e = linfo_w.to_f/(line_end_chars+1.5)
2816
+ end
2817
+ end
2798
2818
  end
2819
+
2820
+
2799
2821
  if @line_num_rx_e && @line_num_width_e && line_end_chars >0
2800
2822
  actual_width = @line_num_rx_e + @line_num_width_e
2801
2823
  need_width = (line_end_chars+1)*@line_num_width_e
@@ -2947,13 +2969,17 @@ class AgEditor
2947
2969
  if file
2948
2970
  new_file_name(file)
2949
2971
  save
2950
- @controller.change_file_name(@page_frame, file)
2972
+ #@controller.change_file_name(@page_frame, file)
2973
+ @last_tmp_file = nil if @last_tmp_file != nil
2974
+ Arcadia.process_event(OpenBufferEvent.new(self,'file'=>file))
2975
+ @controller.do_buffer_raise(@controller.page_name(@page_frame))
2951
2976
  #EditorContract.instance.file_created(self, 'file'=>@file)
2952
2977
  end
2953
2978
  end
2954
2979
 
2955
2980
  def new_file_name(_new_file)
2956
2981
  @file =_new_file
2982
+ @controller.change_file_name(@page_frame, file)
2957
2983
  base_name= File.basename(_new_file)
2958
2984
  if base_name.include?('.')
2959
2985
  self.change_highlight(base_name.split('.')[-1])
@@ -3143,7 +3169,6 @@ class AgMultiEditorView
3143
3169
  end
3144
3170
  }
3145
3171
  @enb.bind_append("Map",refresh_after_map)
3146
-
3147
3172
  end
3148
3173
 
3149
3174
  end
@@ -3302,15 +3327,17 @@ end
3302
3327
 
3303
3328
 
3304
3329
  class AgMultiEditor < ArcadiaExt
3305
- include Autils
3306
3330
  include Configurable
3307
- attr_reader :breakpoints
3331
+ # attr_reader :breakpoints
3308
3332
  attr_reader :splitted_frame
3309
3333
  attr_reader :outline_bar
3310
3334
  def on_before_build(_event)
3311
3335
  @breakpoints =Array.new
3312
3336
  @tabs_file =Hash.new
3313
3337
  @tabs_editor =Hash.new
3338
+ @raw_buffer_name = Hash.new
3339
+ @editor_seq=-1
3340
+ @editors =Array.new
3314
3341
  Arcadia.attach_listener(self, BufferEvent)
3315
3342
  Arcadia.attach_listener(self, DebugEvent)
3316
3343
  # Arcadia.attach_listener(self, RunRubyFileEvent)
@@ -3450,8 +3477,10 @@ class AgMultiEditor < ArcadiaExt
3450
3477
  0.upto(i_end){|j|
3451
3478
  type = @buffer_menu.menutype(j)
3452
3479
  if type != 'separator'
3453
- label = @buffer_menu.entrycget(j,'label')
3454
- if label > _filename
3480
+ #label = @buffer_menu.entrycget(j,'label')
3481
+ #if label > _filename
3482
+ value = @buffer_menu.entrycget(j,'value')
3483
+ if value > _filename
3455
3484
  index=j
3456
3485
  break
3457
3486
  end
@@ -3459,18 +3488,20 @@ class AgMultiEditor < ArcadiaExt
3459
3488
  }
3460
3489
  end
3461
3490
 
3462
- @buffer_menu.insert(index,:command,
3463
- :label=>_filename,
3464
- :image=> Arcadia.file_icon(_filename),
3465
- :compound=>'left',
3466
- :command=>proc{
3467
- if is_file
3468
- open_file(_filename)
3469
- else
3470
- open_buffer(tab_name(_filename))
3471
- end
3472
- },
3473
- :hidemargin => true
3491
+ @buffer_menu.insert(index,:radio,
3492
+ :label=>File.basename(_filename),
3493
+ # :variable=>TkVariable.new(_filename),
3494
+ :value=>_filename,
3495
+ :image=> Arcadia.file_icon(_filename),
3496
+ :compound=>'left',
3497
+ :command=>proc{
3498
+ if is_file
3499
+ open_file(_filename)
3500
+ else
3501
+ open_buffer(tab_name(_filename))
3502
+ end
3503
+ },
3504
+ :hidemargin => true
3474
3505
  )
3475
3506
  end
3476
3507
 
@@ -3480,8 +3511,10 @@ class AgMultiEditor < ArcadiaExt
3480
3511
  0.upto(i_end){|j|
3481
3512
  type = @buffer_menu.menutype(j)
3482
3513
  if type != 'separator'
3483
- label = @buffer_menu.entrycget(j,'label')
3484
- if label == _file
3514
+ #label = @buffer_menu.entrycget(j,'label')
3515
+ #if label == _file
3516
+ value = @buffer_menu.entrycget(j,'value')
3517
+ if value == _file
3485
3518
  to_del=j
3486
3519
  break
3487
3520
  end
@@ -3672,19 +3705,34 @@ class AgMultiEditor < ArcadiaExt
3672
3705
  end
3673
3706
 
3674
3707
  def on_before_debug(_event)
3675
- "on_before_debug #{_event}"
3676
3708
  case _event
3677
3709
  when StartDebugEvent
3710
+ _event.persistent=true
3678
3711
  _filename = _event.file
3679
- if _filename.nil?
3712
+ if _filename == "*LAST"
3713
+ _event.file = Arcadia.persistent('run.file.last')
3714
+ elsif _filename.nil? || _filename == "*CURR"
3680
3715
  current_editor = self.raised
3681
- _event.file=current_editor.file if current_editor
3716
+ if current_editor
3717
+ if current_editor.file
3718
+ _event.file=current_editor.file
3719
+ else
3720
+ _event.file=current_editor.create_temp_file
3721
+ _event.id=current_editor.id
3722
+ _event.persistent=false
3723
+ end
3724
+ end
3682
3725
  end
3683
3726
  self.debug_begin
3684
3727
  when SetBreakpointEvent
3685
3728
  if _event.active == 1
3686
- @breakpoints << {:file=>_event.file,:line=>_event.row}
3687
- _e = @tabs_editor[tab_file_name(_event.file)]
3729
+ if _event.file
3730
+ @breakpoints << {:file=>_event.file,:line=>_event.row}
3731
+ _e = @tabs_editor[tab_file_name(_event.file)]
3732
+ elsif _event.id
3733
+ @breakpoints << {:file=>"__TMP__#{_event.id}",:line=>_event.row}
3734
+ _e = @editors[_event.id]
3735
+ end
3688
3736
  if _e
3689
3737
  _index =_event.row+'.0'
3690
3738
  _line = _e.text.get(_index, _index+ ' lineend')
@@ -3700,7 +3748,6 @@ class AgMultiEditor < ArcadiaExt
3700
3748
  end
3701
3749
 
3702
3750
  def on_after_debug(_event)
3703
- "on_after_debug #{_event}"
3704
3751
  case _event
3705
3752
  when StepDebugEvent
3706
3753
  if _event.command == :quit_yes
@@ -3717,8 +3764,13 @@ class AgMultiEditor < ArcadiaExt
3717
3764
  when UnsetBreakpointEvent
3718
3765
  #p "ae-editor : UnsetBreakpointEvent file : #{_event.file}"
3719
3766
  #p "ae-editor : UnsetBreakpointEvent _event.row : #{_event.row}"
3720
- @breakpoints.delete_if{|b| (b[:file]==_event.file && b[:line]==_event.row)}
3721
- _e = @tabs_editor[tab_file_name(_event.file)]
3767
+ if _event.file
3768
+ @breakpoints.delete_if{|b| (b[:file]==_event.file && b[:line]==_event.row)}
3769
+ _e = @tabs_editor[tab_file_name(_event.file)]
3770
+ elsif _event.id
3771
+ @breakpoints.delete_if{|b| (b[:file]=="__TMP__#{_event.id}" && b[:line]==_event.row)}
3772
+ _e = @editors[_event.id]
3773
+ end
3722
3774
  _e.remove_tag_breakpoint(_event.row) if _e
3723
3775
  end
3724
3776
  end
@@ -3860,12 +3912,13 @@ class AgMultiEditor < ArcadiaExt
3860
3912
  #_insert_index = editor.text.index('insert')
3861
3913
  _insert_index = editor.text.index('@0,0')
3862
3914
  _files=_files+'|' if _files.strip.length > 0
3863
- _files=_files + "#{editor.file};#{_insert_index}"
3915
+ _files=_files + "#{editor.file};#{_insert_index};#{editor.line_numbers_visible.to_s}"
3864
3916
  end
3865
3917
  #p editor.text.dump_tag('0.1',editor.text.index('end'))
3866
3918
  close_editor(editor,true)
3867
3919
  }
3868
3920
  Arcadia.persistent('editor.files.open', _files)
3921
+ clear_temp_files
3869
3922
  # _breakpoints = '';
3870
3923
  # @breakpoints.each{|point|
3871
3924
  # if point[:file] != nil
@@ -3877,22 +3930,32 @@ class AgMultiEditor < ArcadiaExt
3877
3930
  @batch_files = true
3878
3931
  end
3879
3932
 
3933
+
3934
+ def clear_temp_files
3935
+ files = Dir[File.join(Arcadia.instance.local_dir,"*")]
3936
+ files.each{|f|
3937
+ if File.stat(f).file? && f[-2..-1] == '~~'
3938
+ File.delete(f)
3939
+ end
3940
+ }
3941
+ end
3942
+
3880
3943
  def raised
3881
3944
  _page = @main_frame.enb.raise
3882
- return @tabs_editor[_page]
3945
+ return @tabs_editor[resolve_tab_name(_page)]
3883
3946
  end
3884
3947
 
3885
3948
  def close_raised
3886
- _e = @tabs_editor[@main_frame.enb.raise]
3949
+ _e = @tabs_editor[resolve_tab_name(@main_frame.enb.raise)]
3887
3950
  close_editor(_e) if _e
3888
3951
  end
3889
3952
 
3890
- def breakpoint_add(_file,_line)
3891
- Arcadia.process_event(SetBreakpointEvent.new(self, 'file'=>_file, 'row'=>_line, 'active'=>1))
3953
+ def breakpoint_add(_file,_line,_id=-1)
3954
+ Arcadia.process_event(SetBreakpointEvent.new(self, 'id'=>_id, 'file'=>_file, 'row'=>_line, 'active'=>1))
3892
3955
  end
3893
3956
 
3894
- def breakpoint_del(_file,_line)
3895
- Arcadia.process_event(UnsetBreakpointEvent.new(self, 'file'=>_file, 'row'=>_line))
3957
+ def breakpoint_del(_file,_line,_id=-1)
3958
+ Arcadia.process_event(UnsetBreakpointEvent.new(self, 'id'=>_id, 'file'=>_file, 'row'=>_line))
3896
3959
  end
3897
3960
 
3898
3961
  def breakpoint_lines_on_file(_file)
@@ -3924,11 +3987,14 @@ class AgMultiEditor < ArcadiaExt
3924
3987
  if Arcadia.persistent('editor.files.open')
3925
3988
  _files_index =Arcadia.persistent('editor.files.open').split("|")
3926
3989
  _files_index.each do |value|
3927
- _file,_index = value.split(';')
3990
+ _file,_index,_line_numbers_visible_as_string = value.split(';')
3928
3991
  if _file && _index
3929
- open_file(_file,_index,false)
3992
+ ed = open_file(_file,_index,false)
3930
3993
  else
3931
- open_file(_file)
3994
+ ed = open_file(_file)
3995
+ end
3996
+ if ed && _line_numbers_visible_as_string && ed.line_numbers_visible
3997
+ ed.line_numbers_visible = _line_numbers_visible_as_string == 'true'
3932
3998
  end
3933
3999
  end
3934
4000
  end
@@ -4036,13 +4102,33 @@ class AgMultiEditor < ArcadiaExt
4036
4102
  end
4037
4103
 
4038
4104
  def tab_title_by_tab_name(_tab_name)
4039
- @main_frame.enb.itemcget(_tab_name, 'text')
4105
+ @main_frame.enb.itemcget(resolve_tab_name(_tab_name), 'text')
4040
4106
  end
4041
4107
 
4108
+ def tab_name(_str="")
4109
+ tn = 'ff'+_str.downcase.gsub("/","_").gsub(".","__").gsub(":","___").gsub("\\","____").gsub("*","_____")
4110
+ resolve_tab_name(tn)
4111
+ end
4112
+
4113
+ def tab_file_name(_filename="")
4114
+ _fstr = File.expand_path(_filename)
4115
+ _fstr = _filename if _fstr == nil
4116
+ tab_name(_fstr)
4117
+ end
4118
+
4042
4119
  def page_name(_page_frame)
4043
- TkWinfo.appname(_page_frame).sub('f','')
4120
+ pn = TkWinfo.appname(_page_frame).sub('f','')
4121
+ resolve_tab_name(pn)
4044
4122
  end
4045
-
4123
+
4124
+ def resolve_tab_name(_tab_name)
4125
+ if @raw_buffer_name[_tab_name]
4126
+ return @raw_buffer_name[_tab_name]
4127
+ else
4128
+ return _tab_name
4129
+ end
4130
+ end
4131
+
4046
4132
  def change_tab_reset_modify(_tab)
4047
4133
  #_new_name = @main_frame.enb.itemcget(@tabs_name[_tab], 'text').gsub!("(...)",'')
4048
4134
  if @main_frame.enb.index(page_name(_tab))
@@ -4052,6 +4138,15 @@ class AgMultiEditor < ArcadiaExt
4052
4138
  end
4053
4139
  end
4054
4140
  end
4141
+
4142
+ def change_frame_caption(_new_caption)
4143
+ if @arcadia.layout.headed?
4144
+ if frame.root.title == frame.title
4145
+ frame.root.top_text(_new_caption)
4146
+ end
4147
+ frame.root.save_caption(frame.name, _new_caption)
4148
+ end
4149
+ end
4055
4150
 
4056
4151
  def change_tab_title(_tab, _new_text)
4057
4152
  @main_frame.enb.itemconfigure(page_name(_tab), 'text'=> _new_text)
@@ -4070,10 +4165,16 @@ class AgMultiEditor < ArcadiaExt
4070
4165
  end
4071
4166
 
4072
4167
  def change_file_name(_tab, _new_file)
4168
+ @tabs_file[page_name(_tab)] = _new_file
4169
+ @raw_buffer_name[tab_file_name(_new_file)]=page_name(_tab)
4073
4170
  _new_label = File.basename(_new_file)
4074
4171
  change_tab_title(_tab, _new_label)
4075
4172
  change_tab_icon(_tab, _new_label)
4076
- @tabs_file[page_name(_tab)] = _new_file
4173
+ #change_frame_caption(_new_file)
4174
+ #@tabs_editor[tab_file_name(_new_file)]=@tabs_editor[page_name(_tab)]
4175
+
4176
+ #@tabs_file[tab_file_name(_new_file)] = _new_file
4177
+ #@tabs_editor[tab_file_name(_new_file)] = editor_of(_new_file)
4077
4178
  end
4078
4179
 
4079
4180
  def debug_begin
@@ -4102,11 +4203,17 @@ class AgMultiEditor < ArcadiaExt
4102
4203
  #debug_reset
4103
4204
  if _filename && _line && File.exists?(_filename)
4104
4205
  @last_index = _line.to_s+'.0'
4105
- _editor_exist = editor_exist?(_filename)
4106
- @last_e = open_file(_filename, @last_index, false, false)
4206
+ #_editor_exist = editor_exist?(_filename)
4207
+ _editor = editor_of(_filename)
4208
+ if _editor
4209
+ @last_e = raise_editor(_editor, @last_index, false, false)
4210
+ else
4211
+ @last_e = open_file(_filename, @last_index, false, false)
4212
+ end
4107
4213
  #@last_e.hide_exp
4108
4214
  @last_e.mark_debug(@last_index) if @last_e
4109
- if !_editor_exist
4215
+ #if !_editor_exist
4216
+ if _editor.nil?
4110
4217
  @editors_in_debug << @last_e
4111
4218
  # workaround for hightlight
4112
4219
  #p "add editor for close #{_filename}"
@@ -4127,13 +4234,13 @@ class AgMultiEditor < ArcadiaExt
4127
4234
  end
4128
4235
 
4129
4236
  def do_buffer_raise(_name, _title='...')
4130
- _index = @main_frame.enb.index(_name)
4237
+ _index = @main_frame.enb.index(resolve_tab_name(_name))
4131
4238
  _new_caption = '...'
4132
4239
  if _index != -1
4133
4240
  #_name = @main_frame.enb.pages(_index)
4134
4241
  #_tab = get_tab_from_name(_name)
4135
4242
  #@main_frame.enb.raise(_name)
4136
- _e = @tabs_editor[_name]
4243
+ _e = @tabs_editor[resolve_tab_name(_name)]
4137
4244
  change_outline(_e) if _e
4138
4245
  if _e && _e.file != nil
4139
4246
  _new_caption = _e.file
@@ -4143,48 +4250,62 @@ class AgMultiEditor < ArcadiaExt
4143
4250
  _new_caption = _title
4144
4251
  end
4145
4252
  end
4146
- if @arcadia.layout.headed?
4147
- if frame.root.title == frame.title
4148
- frame.root.top_text(_new_caption)
4149
- end
4150
- frame.root.save_caption(frame.name, _new_caption)
4151
- #@arcadia.layout.domain(@arcadia['conf'][@name+'.frame'])['root'].top_text(_new_caption)
4152
- end
4253
+ change_frame_caption(_new_caption)
4153
4254
  _title = @tabs_file[_name] != nil ? File.basename(@tabs_file[_name]) :_name
4154
4255
  Arcadia.broadcast_event(BufferRaisedEvent.new(self,'title'=>_title, 'file'=>@tabs_file[_name]))
4155
4256
  #EditorContract.instance.buffer_raised(self, 'title'=>_title, 'file'=>@tabs_file[_name])
4156
4257
  end
4157
4258
 
4259
+ def editor_of(_filename)
4260
+ _ret = nil
4261
+ @editors.each{|e|
4262
+ if e.file == _filename || e.last_tmp_file == _filename
4263
+ _ret = e
4264
+ break
4265
+ end
4266
+ }
4267
+ if _ret.nil?
4268
+ _basefilename = File.basename(_filename)
4269
+ _name = self.tab_file_name(_filename)
4270
+ _index = @main_frame.enb.index(resolve_tab_name(_name))
4271
+ if _index == -1
4272
+ _name = name_read_only(_name)
4273
+ _index = @main_frame.enb.index(resolve_tab_name(_name))
4274
+ end
4275
+ if _index != -1
4276
+ _ret = @tabs_editor[resolve_tab_name(_name)]
4277
+ end
4278
+ end
4279
+ _ret
4280
+ end
4281
+
4158
4282
  def editor_exist?(_filename)
4159
4283
  _basefilename = File.basename(_filename)
4160
4284
  #_basename = _basefilename.split('.')[0]+'_'+_basefilename.split('.')[1]
4161
4285
 
4162
4286
  _name = self.tab_file_name(_filename)
4163
- _index = @main_frame.enb.index(_name)
4287
+ _index = @main_frame.enb.index(resolve_tab_name(_name))
4164
4288
  if _index == -1
4165
- _index = @main_frame.enb.index(name_read_only(_name))
4289
+ _index = @main_frame.enb.index(resolve_tab_name(name_read_only(_name)))
4290
+ end
4291
+ if _index == -1
4292
+ @editors.each{|e|
4293
+ if e.last_tmp_file == _filename
4294
+ _index = 0
4295
+ break
4296
+ end
4297
+ }
4166
4298
  end
4167
4299
  return _index != -1
4168
4300
  end
4169
4301
 
4170
- def tab_name(_str="")
4171
- #_str = _str.downcase if is_windows?
4172
- 'ff'+_str.downcase.gsub("/","_").gsub(".","__").gsub(":","___").gsub("\\","____").gsub("*","_____")
4173
- end
4174
-
4175
- def tab_file_name(_filename="")
4176
- _fstr = File.expand_path(_filename)
4177
- _fstr = _filename if _fstr == nil
4178
- tab_name(_fstr)
4179
- end
4180
-
4181
4302
  def raise_file(_filename=nil, _pos=nil)
4182
4303
  if _filename && frame_def_visible?
4183
4304
  tab_name=self.tab_file_name(_filename)
4184
4305
  if @main_frame.enb.index(tab_name) != -1
4185
- @main_frame.enb.move(tab_name,_pos) if _pos
4186
- @main_frame.enb.raise(tab_name)
4187
- @main_frame.enb.see(tab_name)
4306
+ @main_frame.enb.move(tab_name,_pos) if _pos
4307
+ @main_frame.enb.raise(tab_name)
4308
+ @main_frame.enb.see(tab_name)
4188
4309
  end
4189
4310
  end
4190
4311
  end
@@ -4193,9 +4314,9 @@ class AgMultiEditor < ArcadiaExt
4193
4314
  return if _filename == nil || !File.exist?(_filename) || File.ftype(_filename) != 'file'
4194
4315
  _basefilename = File.basename(_filename)
4195
4316
  _tab_name = self.tab_file_name(_filename)
4196
- _index = @main_frame.enb.index(_tab_name)
4197
- _exist_buffer = _index != -1
4198
-
4317
+ #_index = @main_frame.enb.index(_tab_name)
4318
+ #_exist_buffer = _index != -1
4319
+ _exist_buffer = @tabs_file[_tab_name] != nil
4199
4320
  if _exist_buffer
4200
4321
  open_buffer(_tab_name)
4201
4322
  else
@@ -4205,35 +4326,38 @@ class AgMultiEditor < ArcadiaExt
4205
4326
  begin
4206
4327
  @tabs_editor[_tab_name].load_file(_filename)
4207
4328
  rescue RuntimeError => e
4208
- p "RuntimeError : #{e.message}"
4329
+ Arcadia.dialog(self,'type'=>'ok', 'level'=>'error','title' => 'RuntimeError', 'msg'=>"RuntimeError : #{e.message}")
4330
+ #p "RuntimeError : #{e.message}"
4209
4331
  close_editor(@tabs_editor[_tab_name], true)
4210
4332
  end
4211
4333
  end
4212
-
4213
- if _text_index != nil && _text_index != '1.0' && @tabs_editor[_tab_name]
4214
- @tabs_editor[_tab_name].text_see(_text_index)
4215
- @tabs_editor[_tab_name].mark_selected(_text_index) if _mark_selected
4334
+ editor = @tabs_editor[_tab_name]
4335
+ if _text_index != nil && _text_index != '1.0' && editor
4336
+ editor.text_see(_text_index)
4337
+ editor.mark_selected(_text_index) if _mark_selected
4216
4338
  end
4217
4339
 
4218
- return @tabs_editor[_tab_name]
4340
+ return editor
4219
4341
  end
4220
4342
 
4221
4343
 
4222
4344
  def open_buffer(_buffer_name = nil, _title = nil, _filename=nil)
4223
- _index = @main_frame.enb.index(_buffer_name)
4345
+ _index = @main_frame.enb.index(resolve_tab_name(_buffer_name))
4224
4346
  if _buffer_name == nil
4225
4347
  _title_new = '*new'
4348
+ tmp_buffer_num = 0
4226
4349
  _buffer_name = tab_name(_title_new)
4227
4350
  #_buffer_name = tab_name('new')
4228
4351
  end
4229
4352
 
4230
4353
  if _index != -1
4231
- _tab = @main_frame.enb.get_frame(_buffer_name)
4232
- @main_frame.enb.raise(_buffer_name) if frame_visible?
4354
+ _tab = @main_frame.enb.get_frame(resolve_tab_name(_buffer_name))
4355
+ @main_frame.enb.raise(resolve_tab_name(_buffer_name)) if frame_visible?
4233
4356
  else
4234
4357
  _n = 1
4235
4358
  while @main_frame.enb.index(_buffer_name) != -1
4236
4359
  _title_new = '*new'+_n.to_s
4360
+ tmp_buffer_num = _n
4237
4361
  _buffer_name = tab_name(_title_new)
4238
4362
  #_buffer_name = tab_name('new')+_n.to_s
4239
4363
  _n =_n+1
@@ -4244,16 +4368,20 @@ class AgMultiEditor < ArcadiaExt
4244
4368
  _tab = @main_frame.enb.insert('end', _buffer_name ,
4245
4369
  'text'=> _title,
4246
4370
  'image'=> Arcadia.file_icon(_title),
4247
- 'background'=> Arcadia.style("tabpanel.background"),
4248
- 'foreground'=> Arcadia.style("tabpanel.foreground"),
4371
+ 'background'=> Arcadia.style("tabpanel")["background"],
4372
+ 'foreground'=> Arcadia.style("tabpanel")["foreground"],
4249
4373
  'raisecmd'=>proc{do_buffer_raise(_buffer_name, _title)}
4250
4374
  )
4375
+ @raw_buffer_name[_buffer_name]=_buffer_name
4251
4376
  if _filename
4252
4377
  add_buffer_menu_item(_filename)
4253
4378
  else
4254
4379
  add_buffer_menu_item(_title, false)
4255
4380
  end
4256
4381
  _e = AgEditor.new(self, _tab)
4382
+ @editor_seq=@editor_seq+1
4383
+ _e.id=@editor_seq
4384
+ @editors[@editor_seq]=_e
4257
4385
  ext = Arcadia.file_extension(_title)
4258
4386
  ext='rb' if ext.nil?
4259
4387
  _e.init_editing(ext)
@@ -4261,12 +4389,36 @@ class AgMultiEditor < ArcadiaExt
4261
4389
  #@tabs_file[_buffer_name]= nil
4262
4390
  @tabs_editor[_buffer_name]=_e
4263
4391
  end
4264
- @main_frame.enb.move(_buffer_name, 1)
4265
- @main_frame.enb.raise(_buffer_name) if frame_visible?
4266
- @main_frame.enb.see(_buffer_name)
4392
+ if raised != @tabs_editor[resolve_tab_name(_buffer_name)]
4393
+ @main_frame.enb.move(resolve_tab_name(_buffer_name), 1)
4394
+ @main_frame.enb.raise(resolve_tab_name(_buffer_name)) if frame_visible?
4395
+ @main_frame.enb.see(resolve_tab_name(_buffer_name))
4396
+ end
4267
4397
  return _tab
4268
4398
  end
4269
4399
 
4400
+ def raise_editor(_editor = nil, _text_index='0.0', _mark_selected=true, _exp=true)
4401
+ return if _editor == nil
4402
+ _tab_name = nil
4403
+ @tabs_editor.each{|tn,e|
4404
+ if e == _editor
4405
+ _tab_name = tn
4406
+ end
4407
+ }
4408
+ if _tab_name
4409
+ _index = @main_frame.enb.index(resolve_tab_name(_tab_name))
4410
+ _exist_buffer = _index != -1
4411
+ if _exist_buffer
4412
+ open_buffer(_tab_name)
4413
+ if _text_index != nil && _text_index != '0.0'
4414
+ _editor.text_see(_text_index)
4415
+ _editor.mark_selected(_text_index) if _mark_selected
4416
+ end
4417
+ end
4418
+ end
4419
+ return _editor
4420
+ end
4421
+
4270
4422
  def close_others_editor(_editor, _mod=true)
4271
4423
  @batch_files = true
4272
4424
  @tabs_editor.values.each do |_e|
@@ -4335,6 +4487,9 @@ class AgMultiEditor < ArcadiaExt
4335
4487
  del_buffer_menu_item(tab_title_by_tab_name(_name))
4336
4488
  end
4337
4489
  @tabs_editor.delete(_name)
4490
+ @tabs_file.delete(_name)
4491
+ @raw_buffer_name.delete_if {|key, value| value == _name }
4492
+
4338
4493
  _index = @main_frame.enb.index(_name)
4339
4494
  @main_frame.enb.delete(_name)
4340
4495
  if !@main_frame.enb.pages.empty?