arcadia 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,20 +9,12 @@ re.link=>>>
9
9
  re_op.to_line_end=comment
10
10
  re_op.only_first=operator
11
11
 
12
- #hightlight.comment.foreground=#007F00
13
- #hightlight.key.foreground=#9c342c
14
- #hightlight.key.style=bold
15
- #hightlight.value.foreground=#69a0b6
16
- #hightlight.value.style=bold
17
- #hightlight.operator.foreground=red
18
- #hightlight.operator.style=bold
19
-
20
- re.hightlight.comment.foreground=>>>hightlight.11.foreground
21
- re.hightlight.key.foreground=>>>hightlight.5.foreground
12
+ re.hightlight.comment.foreground=>>>hightlight.comment.foreground
13
+ re.hightlight.key.foreground=>>>hightlight.symbol.foreground
22
14
  re.hightlight.key.style=bold
23
- re.hightlight.value.foreground=>>>hightlight.6.foreground
15
+ re.hightlight.value.foreground=>>>hightlight.constant.foreground
24
16
  re.hightlight.value.style=bold
25
- re.hightlight.operator.foreground=>>>hightlight.14.foreground
17
+ re.hightlight.operator.foreground=>>>hightlight.operator.foreground
26
18
  re.hightlight.operator.style=bold
27
- re.hightlight.link.foreground=>>>hightlight.12.foreground
19
+ re.hightlight.link.foreground=>>>hightlight.string.foreground
28
20
  re.hightlight.link.style=bold
@@ -24,7 +24,7 @@ class OutputView
24
24
  pack('side' =>'top', 'anchor'=>'n',:padx=>0, :pady=>0)
25
25
  }
26
26
 
27
- @text = TkScrollText.new(right_frame,
27
+ @text = TkArcadiaText.new(right_frame,
28
28
  {'wrap'=> 'none'}.update(Arcadia.style('edit'))
29
29
  )
30
30
  @text.show
@@ -2427,7 +2427,7 @@ class AGTkToplevel < AGTkContainer
2427
2427
  if ans =='yes'
2428
2428
  form2code
2429
2429
  elsif ans =='no'
2430
- keep_me
2430
+ keep_me
2431
2431
  end
2432
2432
  end
2433
2433
 
@@ -42,14 +42,16 @@ class SearchInFilesListener
42
42
  enter_proc = proc {|e|
43
43
  case e.keysym
44
44
  when 'Return'
45
- update_all_combo
46
- do_find
45
+ if @find.visible?
46
+ update_all_combo
47
+ do_find
48
+ end
47
49
  Tk.callback_break
48
50
  end
49
51
  }
50
52
 
51
53
  for method in [:e_what_entry, :e_filter_entry, :e_dir_entry] do
52
- @find.send(method).bind_append('KeyRelease') { |*args| enter_proc.call *args } # ltodo why can't we pass it in like &enter_proc?
54
+ @find.send(method).bind_append('KeyPress') { |*args| enter_proc.call *args } # ltodo why can't we pass it in like &enter_proc?
53
55
  end
54
56
  @find.title(title)
55
57
  end
@@ -177,8 +179,8 @@ class SearchOutput
177
179
  # @found_color='#3f941b'
178
180
  # @not_found_color= 'red'
179
181
  # @item_color='#6fc875'
180
- @found_color=Arcadia.conf('hightlight.5.foreground')
181
- @not_found_color= Arcadia.conf('hightlight.6.foreground')
182
+ @found_color=Arcadia.conf('activeforeground')
183
+ @not_found_color= Arcadia.conf('hightlight.comment.foreground')
182
184
  @item_color=Arcadia.conf('treeitem.fill')
183
185
  end
184
186
 
data/lib/a-commons.rb CHANGED
@@ -541,7 +541,6 @@ module Configurable
541
541
  end
542
542
  Hash.new.update(@@conf_groups[_group])
543
543
  end
544
-
545
544
 
546
545
  def resolve_link(_value, _hash_source, _link_symbol='>>>', _add_symbol='+++')
547
546
  if _value.length > 0
@@ -563,9 +562,9 @@ module Configurable
563
562
  _hash_target.each{|k,value|
564
563
  loop_level = 0
565
564
  if value.length > 0
566
- v, vadd = value.split(_add_symbol)
565
+ v, vadd = value.split(_add_symbol)
567
566
  else
568
- v= value
567
+ v= value
569
568
  end
570
569
  # p "value=#{value} class=#{value.class}"
571
570
  # p "v=#{v} class=#{v.class}"
@@ -597,6 +596,14 @@ module Configurable
597
596
  end
598
597
  end
599
598
 
599
+ def make_value(_self_context=self, _value='')
600
+ value = _value.strip
601
+ if value[0..0]=='!'
602
+ value=_self_context.instance_eval(value[1..-1])
603
+ end
604
+ value
605
+ end
606
+
600
607
  end
601
608
 
602
609
  module Persistable
@@ -658,6 +665,8 @@ class Application
658
665
  # read in the settings'
659
666
  publish('conf', properties_file2hash(self['applicationParams'].config_file)) if self['applicationParams'].config_file
660
667
  publish('origin_conf', Hash.new.update(self['conf'])) if self['conf']
668
+ publish('local_conf', Hash.new)
669
+ publish('conf_without_local', Hash.new.update(self['conf'])) if self['conf']
661
670
  publish('pers', properties_file2hash(self['applicationParams'].persistent_file)) if self['applicationParams'].persistent_file
662
671
  yield(self) if block_given?
663
672
  end
@@ -694,11 +703,11 @@ class Application
694
703
  @@conf_groups[_group]
695
704
  end
696
705
 
697
- def Application.del_conf_group(_group)
706
+ def Application.del_conf_group(_conf_hash, _group)
698
707
  glen=_group.length
699
- @@instance['conf'].keys.sort.each{|k|
708
+ _conf_hash.keys.sort.each{|k|
700
709
  if k[0..glen] == "#{_group}."
701
- @@instance['conf'].delete(k)
710
+ _conf_hash.delete(k)
702
711
  end
703
712
  }
704
713
  end
@@ -730,13 +739,13 @@ class Application
730
739
  f = File.new(local_file_config, "w")
731
740
  begin
732
741
  if f
733
- p = self['conf']
734
- if p
735
- p.keys.sort.each{|key|
736
- if self['origin_conf'][key] == self['conf'][key]
737
- f.syswrite('#'+key+'='+self['conf'][key]+"\n") # write it as a comment since it isn't a real change
738
- else
739
- f.syswrite(key+'='+self['conf'][key]+"\n")
742
+ properties = self['conf']
743
+ if properties
744
+ properties.keys.sort.each{|key|
745
+ if self['conf_without_local'][key] == self['conf'][key] || (self['origin_conf'][key] && self['origin_conf'][key].include?('>>>')) # || self['local_conf'][key].nil?
746
+ f.syswrite("# #{key}=#{self['origin_conf'][key]}\n") # write it as a comment since it isn't a real change
747
+ elsif self['conf'][key]
748
+ f.syswrite("#{key}=#{self['conf'][key]}\n")
740
749
  end
741
750
  }
742
751
  end
@@ -751,7 +760,8 @@ class Application
751
760
  # this method load config file from local directory for personalizations
752
761
  def load_local_config(_create_if_not_exist=true)
753
762
  if FileTest.exist?(local_file_config)
754
- self['conf'].update(self.properties_file2hash(local_file_config))
763
+ self['local_conf']= self.properties_file2hash(local_file_config)
764
+ self['conf'].update(self['local_conf'])
755
765
  elsif _create_if_not_exist
756
766
  if FileTest.writable?(local_dir)
757
767
  f = File.new(local_file_config, "w")
@@ -778,7 +788,9 @@ class Application
778
788
  def load_theme(_name=nil)
779
789
  _theme_file = "conf/theme-#{_name}.conf" if !_name.nil?
780
790
  if _theme_file && File.exist?(_theme_file)
781
- self['conf'].update(self.properties_file2hash(_theme_file))
791
+ self['conf_theme'] = self.properties_file2hash(_theme_file)
792
+ self['conf'].update(self['conf_theme'])
793
+ self['conf_without_local'].update(self['conf_theme'])
782
794
  _theme_res_file = "conf/theme-#{_name}.res.rb"
783
795
  if _theme_res_file && File.exist?(_theme_res_file)
784
796
  begin
data/lib/a-contracts.rb CHANGED
@@ -242,6 +242,12 @@ end
242
242
  class CutTextEvent < FocusEvent; end
243
243
  class CopyTextEvent < FocusEvent; end
244
244
  class PasteTextEvent < FocusEvent; end
245
+ class UndoTextEvent < FocusEvent; end
246
+ class RedoTextEvent < FocusEvent; end
247
+ class SelectAllTextEvent < FocusEvent; end
248
+ class InvertSelectionTextEvent < FocusEvent; end
249
+ class UpperCaseTextEvent < FocusEvent; end
250
+ class LowerCaseTextEvent < FocusEvent; end
245
251
 
246
252
  #class VirtualKeyboardEvent < ArcadiaEvent
247
253
  #end
data/lib/a-core.rb CHANGED
@@ -21,13 +21,15 @@ class Arcadia < TkApplication
21
21
  super(
22
22
  ApplicationParams.new(
23
23
  'arcadia',
24
- '0.8.0',
24
+ '0.8.1',
25
25
  'conf/arcadia.conf',
26
26
  'conf/arcadia.pers'
27
27
  )
28
28
  )
29
29
  load_config
30
- set_sysdefaultproperty
30
+ if self['conf']['encoding']
31
+ Tk.encoding=self['conf']['encoding']
32
+ end
31
33
  ArcadiaDialogManager.new(self)
32
34
  ArcadiaActionDispatcher.new(self)
33
35
  ArcadiaGemsWizard.new(self)
@@ -47,6 +49,7 @@ class Arcadia < TkApplication
47
49
  iconphoto(TkPhotoImage.new('dat'=>ARCADIA_RING_GIF))
48
50
  }
49
51
 
52
+
50
53
  @on_event = Hash.new
51
54
 
52
55
  @main_menu_bar = TkMenubar.new(
@@ -189,6 +192,7 @@ class Arcadia < TkApplication
189
192
  end
190
193
  self['conf'].update(conf_hash2)
191
194
  self['origin_conf'].update(conf_hash2)
195
+ self['conf_without_local'].update(conf_hash2)
192
196
  load_exts_conf_from("#{ext_dir}/ext",name)
193
197
  }
194
198
  end
@@ -224,11 +228,13 @@ class Arcadia < TkApplication
224
228
  EventWatcherForGem.new(eval(event_str),args)
225
229
  }
226
230
  else
231
+ @splash.withdraw if @splash
227
232
  _event = Arcadia.process_event(NeedRubyGemWizardEvent.new(self, args))
228
233
  ret = ret && Arcadia.gem_available?(gem)
229
234
  # if _event && _event.results
230
235
  # ret = ret && _event.results[0].installed
231
236
  # end
237
+ @splash.deiconify if @splash
232
238
  end
233
239
  break if !ret
234
240
  end
@@ -381,6 +387,7 @@ class Arcadia < TkApplication
381
387
  suf1 = suf+'.'+group
382
388
  begin
383
389
  property = self['conf'][suf1]
390
+ #next if property.nil?
384
391
  c = property.split('c')
385
392
  if c && c.length == 2
386
393
  pt = c[0].split('.')
@@ -428,11 +435,12 @@ class Arcadia < TkApplication
428
435
  self.load_exts_conf
429
436
  self.load_local_config
430
437
  self.load_theme(self['conf']['theme'])
438
+ self.load_sysdefaultproperty
431
439
  self.resolve_properties_link(self['conf'],self['conf'])
432
- self.resolve_properties_link(self['origin_conf'],self['origin_conf'])
440
+ self.resolve_properties_link(self['conf_without_local'],self['conf_without_local'])
433
441
  end
434
442
 
435
- def set_sysdefaultproperty
443
+ def load_sysdefaultproperty
436
444
  Tk.tk_call "eval","option add *background #{self['conf']['background']}"
437
445
  Tk.tk_call "eval","option add *foreground #{self['conf']['foreground']}"
438
446
  #Tk.tk_call "eval","option add *font #{self['conf']['font']}"
@@ -484,16 +492,48 @@ class Arcadia < TkApplication
484
492
  load_user_control(@main_menu)
485
493
  load_user_control(@main_toolbar)
486
494
  #Extension control
495
+ load_key_binding
487
496
  @exts.each{|ext|
488
497
  @splash.next_step("... load #{ext} user controls ") if @splash
489
498
  load_user_control(@main_menu, ext)
490
499
  load_user_control(@main_toolbar, ext)
500
+ load_key_binding(ext)
491
501
  }
492
502
  load_user_control(@main_menu,"","e")
493
503
  load_user_control(@main_toolbar,"","e")
494
504
  #@layout.build_invert_menu
495
505
  end
496
506
 
507
+ def load_key_binding(_ext='')
508
+ return unless _ext && ext_active?(_ext)
509
+ if _ext.length > 0
510
+ if self[_ext]
511
+ _self_on_eval = self[_ext]
512
+ else
513
+ _self_on_eval = self
514
+ end
515
+ suf = "#{_ext}.keybinding"
516
+ else
517
+ _self_on_eval = self
518
+ suf = "keybinding"
519
+ end
520
+ keybs=Arcadia.conf_group(suf)
521
+ keybs.each{|k,v|
522
+ value = v.strip
523
+ key_dits = k.split('[')
524
+ next if k.length == 0
525
+ key_event=key_dits[0]
526
+ if key_dits[1]
527
+ key_sym=key_dits[1][0..-2]
528
+ end
529
+ @root.bind_append(key_event){|e|
530
+ if key_sym == e.keysym
531
+ Arcadia.process_event(_self_on_eval.instance_eval(value))
532
+ end
533
+ }
534
+ }
535
+ end
536
+
497
537
  def load_user_control(_user_control, _ext='', _pre='')
498
538
  return unless _ext && ext_active?(_ext)
499
539
 
@@ -518,26 +558,25 @@ class Arcadia < TkApplication
518
558
  begin
519
559
  context_path = self['conf']["#{suf1}.context_path"]
520
560
  context_underline = self['conf']["#{suf1}.context_underline"]
521
- # property = proc{|_str, _suf| self['conf']["#{_suf}.#{_str}"]}
522
- # property_to_eval = proc{|_str, _suf|
523
- # p = self['conf']["#{_suf}.#{_str}"]
524
- # _self_on_eval.instance_eval(p) if p
525
- # }
526
561
  items = self['conf'][suf1].split(',')
527
562
  items.each{|item|
528
563
  suf2 = suf1+'.'+item
529
564
  disabled = !self['conf']["#{suf2}.disabled"].nil?
530
565
  iprops=Arcadia.conf_group(suf2)
531
566
  item_args = Hash.new
567
+
532
568
  iprops.each{|k,v|
533
- value = v.strip
534
- if value[0..0]=='!'
535
- item_args[k]=_self_on_eval.instance_eval(value[1..-1])
536
- else
537
- item_args[k]=value
538
- end
569
+ item_args[k]= make_value(_self_on_eval, v)
539
570
  }
540
- # item_args['caption'] = item if item_args['caption'].nil?
571
+
572
+ # iprops.each{|k,v|
573
+ # value = v.strip
574
+ # if value[0..0]=='!'
575
+ # item_args[k]=_self_on_eval.instance_eval(value[1..-1])
576
+ # else
577
+ # item_args[k]=value
578
+ # end
579
+ # }
541
580
  item_args['name'] = item if item_args['name'].nil?
542
581
  item_args['context'] = group
543
582
  item_args['context_path'] = context_path
@@ -550,7 +589,7 @@ class Arcadia < TkApplication
550
589
  msg = "Loading #{groups} ->#{items} (#{$!.class.to_s} : #{$!.to_s} at : #{$@.to_s})"
551
590
  if Arcadia.dialog(self,
552
591
  'type'=>'ok_cancel',
553
- 'title' => '(Arcadia) Toolbar',
592
+ 'title' => "(Arcadia) #{_user_control.class::SUF}",
554
593
  'msg'=>msg,
555
594
  'level'=>'error')=='cancel'
556
595
  raise
@@ -584,7 +623,7 @@ class Arcadia < TkApplication
584
623
 
585
624
  def save_layout
586
625
  self['conf']['geometry']= TkWinfo.geometry(@root)
587
- Arcadia.del_conf_group('layout')
626
+ Arcadia.del_conf_group(self['conf'],'layout')
588
627
  # resizing
589
628
  @exts_i.each{|e|
590
629
  found = false
@@ -655,7 +694,6 @@ class Arcadia < TkApplication
655
694
  else
656
695
  self['conf']['user_toolbar_show']='no'
657
696
  end
658
-
659
697
  end
660
698
 
661
699
  def do_finalize
@@ -1089,6 +1127,12 @@ class ArcadiaMainMenu < ArcadiaUserControl
1089
1127
  ['Cut', proc{Arcadia.process_event(CutTextEvent.new(self))}, 2],
1090
1128
  ['Copy', proc{Arcadia.process_event(CopyTextEvent.new(self))}, 0],
1091
1129
  ['Paste', proc{Arcadia.process_event(PasteTextEvent.new(self))}, 0],
1130
+ ['Undo', proc{Arcadia.process_event(UndoTextEvent.new(self))}, 0],
1131
+ ['Redo', proc{Arcadia.process_event(RedoTextEvent.new(self))}, 0],
1132
+ ['Select all', proc{Arcadia.process_event(SelectAllTextEvent.new(self))}, 0],
1133
+ ['Invert selection', proc{Arcadia.process_event(InvertSelectionTextEvent.new(self))}, 0],
1134
+ ['Uppercase', proc{Arcadia.process_event(UpperCaseTextEvent.new(self))}, 0],
1135
+ ['Lowercase', proc{Arcadia.process_event(LowerCaseTextEvent.new(self))}, 0],
1092
1136
  ['Prettify Current', proc{Arcadia.process_event(PrettifyTextEvent.new(self))}, 0]]
1093
1137
 
1094
1138
  menu_spec_search = [['Search', 0],
@@ -1183,7 +1227,7 @@ class ArcadiaAboutSplash < TkToplevel
1183
1227
  place('width' => '120','x' => 150,'y' => 65,'height' => 19)
1184
1228
  }
1185
1229
  @tkLabel21 = TkLabel.new(self){
1186
- text 'by Antonio Galeone - 2004/2009'
1230
+ text 'by Antonio Galeone - 2004/2010'
1187
1231
  background _bgcolor
1188
1232
  foreground '#ffffff'
1189
1233
  font Arcadia.instance['conf']['splash.credits.font']
@@ -2935,6 +2979,18 @@ class FocusEventManager
2935
2979
  do_copy(_event.focus_widget)
2936
2980
  when PasteTextEvent
2937
2981
  do_paste(_event.focus_widget)
2982
+ when UndoTextEvent
2983
+ do_undo(_event.focus_widget)
2984
+ when RedoTextEvent
2985
+ do_redo(_event.focus_widget)
2986
+ when SelectAllTextEvent
2987
+ do_select_all(_event.focus_widget)
2988
+ when InvertSelectionTextEvent
2989
+ do_invert_selection(_event.focus_widget)
2990
+ when UpperCaseTextEvent
2991
+ do_upper_case(_event.focus_widget)
2992
+ when LowerCaseTextEvent
2993
+ do_lower_case(_event.focus_widget)
2938
2994
  end
2939
2995
  end
2940
2996
 
@@ -2949,5 +3005,53 @@ class FocusEventManager
2949
3005
  def do_paste(_focused_widget)
2950
3006
  _focused_widget.text_paste if _focused_widget.respond_to?(:text_paste)
2951
3007
  end
3008
+
3009
+ def do_undo(_focused_widget)
3010
+ begin
3011
+ _focused_widget.edit_undo if _focused_widget.respond_to?(:edit_undo)
3012
+ rescue RuntimeError => e
3013
+ throw e unless e.to_s.include? "nothing to undo" # this is ok--we've done undo back to the beginning
3014
+ end
3015
+ end
3016
+
3017
+ def do_redo(_focused_widget)
3018
+ begin
3019
+ _focused_widget.edit_redo if _focused_widget.respond_to?(:edit_redo)
3020
+ rescue RuntimeError => e
3021
+ throw e unless e.to_s.include? "nothing to redo" # this is ok--we've done redo back to the beginning
3022
+ end
3023
+ end
3024
+
3025
+ def do_select_all(_focused_widget)
3026
+ _focused_widget.tag_add('sel','1.0','end') if _focused_widget.respond_to?(:tag_add)
3027
+ end
3028
+
3029
+ def do_invert_selection(_focused_widget)
3030
+ if _focused_widget.respond_to?(:tag_ranges)
3031
+ r = _focused_widget.tag_ranges('sel')
3032
+ _focused_widget.tag_add('sel','1.0','end') if _focused_widget.respond_to?(:tag_add)
3033
+ _focused_widget.tag_remove('sel',r[0][0],r[0][1]) if _focused_widget.respond_to?(:tag_remove) && r && r[0]
3034
+ end
3035
+ end
3036
+
3037
+ def do_upper_case(_focused_widget)
3038
+ _replace_sel(_focused_widget, :upcase)
3039
+ end
3040
+
3041
+ def do_lower_case(_focused_widget)
3042
+ _replace_sel(_focused_widget, :downcase)
3043
+ end
2952
3044
 
3045
+ def _replace_sel(_focused_widget, _method)
3046
+ if _focused_widget.respond_to?(:tag_ranges)
3047
+ r = _focused_widget.tag_ranges('sel')
3048
+ if _focused_widget.respond_to?(:get) && r && r[0]
3049
+ target_text = _focused_widget.get(r[0][0],r[0][1])
3050
+ if target_text
3051
+ _focused_widget.delete(r[0][0],r[0][1])
3052
+ _focused_widget.insert(r[0][0],target_text.send(_method))
3053
+ end
3054
+ end
3055
+ end
3056
+ end
2953
3057
  end