Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added possibility to search starting from selected

  • Loading branch information...
commit 6c511b9bb24449e86cebd4680983f1e8ab4068db 1 parent a28d1ce
@angal angal authored
View
10 conf/arcadia.res.rb
@@ -1325,10 +1325,10 @@
EOS
FOLDER_GIF=<<EOS
-R0lGODlhEgASAKIHAAAAAO/Tpa2qrYSCAP///4SChPfjtf///yH5BAEAAAcA
-LAAAAAASABIAAANOSLrcLsJJAlWlUcbLM/OXYShAE4mWIIrlR6wjxpovHANG
-u5w2G+iWWg/wo/V8QErgmCs2AMSh0wFdroiAwoRQRRa02ypgkAVvudDveZ0A
-ADs=
+R0lGODlhEgASAMIGAAAAAISCAISChK2qre/Tpffjtf///////yH+EUNyZWF0
+ZWQgd2l0aCBHSU1QACH5BAEAAAcALAAAAAASABIAAANSeLrcPsPJA42BCstx
+ebca431GUVhAw5ngYJqpWL4trM7vaQBFvKy5F4Dgy+CCwyLlmEuqCEEh0QEY
+Rp2SKlQKEEwOWhhR4P1qAYFu+QuuktnwBAA7
EOS
FIND_GIF=<<EOS
@@ -1631,4 +1631,4 @@
AAAAAAAAAAAAAAAAAAAAACH5BAAHAP8ALAAAAAANAA0AAAREEJhZpp2SgM13
IFgnSkZgBkh6AhVgqmpAuieKmGQg7ELKzzzf73AIDI5IJEmATCVZhgFhmppO
SQOOTCswSCqGAtgCiAAAOw==
-EOS
+EOS
View
69 ext/ae-dir-projects/ae-dir-projects.rb
@@ -102,14 +102,14 @@ def on_build(_event)
_sync_val = @sync
@sync = false
begin
- Arcadia.process_event(OpenBufferTransientEvent.new(self,'file'=>node2file(_selected)))
+ Arcadia.process_event(OpenBufferTransientEvent.new(self,'file'=>node2file(_selected)))
ensure
@sync = _sync_val
end
- elsif !_selected.nil? && @htree.open?(node2file(_selected))
- @htree.close_tree(node2file(_selected))
- elsif !_selected.nil?
- @htree.open_tree(node2file(_selected),false)
+# elsif !_selected.nil? && @htree.open?(node2file(_selected))
+# @htree.close_tree(node2file(_selected))
+# elsif !_selected.nil?
+# @htree.open_tree(node2file(_selected),false)
end
else
shure_delete_node(_selected)
@@ -170,14 +170,25 @@ def areabindinfo(*args)
_wrapper.show_v_scroll
_wrapper.show_h_scroll
self.pop_up_menu_tree
- @image_kdir = TkPhotoImage.new('dat' => BOOK_GIF)
+ @image_kdir = TkPhotoImage.new('dat' => ICON_FOLDER_OPEN_GIF)
@image_kdir_closed = TkPhotoImage.new('dat' => FOLDER_GIF)
-# @image_kfile_rb = TkPhotoImage.new('dat' => RUBY_DOCUMENT_GIF)
-# @image_kfile = TkPhotoImage.new('dat' => DOCUMENT_GIF)
self.load_projects
@htree.areabind_append('KeyPress',proc{|k|
key_press(k)
},"%K")
+
+ do_double_click = proc{
+ _selected = @htree.selection_get[0]
+ if File.ftype(node2file(_selected)) == 'directory'
+ if !_selected.nil? && @htree.open?(node2file(_selected))
+ @htree.close_tree(node2file(_selected))
+ elsif !_selected.nil?
+ @htree.open_tree(node2file(_selected),false)
+ end
+ end
+ }
+
+ @htree.textbind_append('Double-1',do_double_click)
end
def key_press(_keysym)
@@ -299,7 +310,6 @@ def pop_up_menu_tree
:hidemargin => false,
:command=> proc{
_selected = self.selected
- p _selected
if _selected
do_new_folder(_selected)
end
@@ -365,6 +375,47 @@ def pop_up_menu_tree
#-----------------
+ #----- search submenu
+ sub_ref_search = TkMenu.new(
+ :parent=>@pop_up,
+ :tearoff=>0,
+ :title => 'Ref'
+ )
+ sub_ref_search.configure(Arcadia.style('menu'))
+ sub_ref_search.insert('end',
+ :command,
+ :label=>'Find in files...',
+ :hidemargin => false,
+ :command=> proc{
+ _target = self.selected
+ if _target
+ _target = File.dirname(_target) if File.ftype(_target) == 'file'
+ Arcadia.process_event(SearchInFilesEvent.new(self,'dir'=>_target))
+ end
+ }
+ )
+
+ sub_ref_search.insert('end',
+ :command,
+ :label=>'Act in files...',
+ :hidemargin => false,
+ :command=> proc{
+ _target = self.selected
+ if _target
+ _target = File.dirname(_target) if File.ftype(_target) == 'file'
+ Arcadia.process_event(AckInFilesEvent.new(self,'dir'=>_target))
+ end
+ }
+ )
+ @pop_up_tree.insert('end',
+ :cascade,
+ :label=>'Search from here',
+ :menu=>sub_ref_search,
+ :hidemargin => false
+ )
+
+
+ #-----------------
@pop_up_tree.insert('end',
:command,
View
145 ext/ae-file-history/ae-file-history.rb
@@ -104,9 +104,6 @@ def on_build(_event)
Tk::BWidget::DynamicHelp::add(@cb_sync,
'text'=>'Link open editors with content in the Navigator')
-
-
-
do_check = proc {
if @cb_sync.cget('onvalue')==@cb_sync.cget('variable').value.to_i
sync_on
@@ -118,29 +115,15 @@ def on_build(_event)
@cb_sync.command(do_check)
do_select_item = proc{|_self|
- if _self.selection_get[0].length >0
- _selected = ""
- if String.method_defined?(:lines)
- selection_lines = _self.selection_get[0].lines
- else
- selection_lines = _self.selection_get[0].split("\n")
- end
- selection_lines.each{|_block|
- _selected = _selected + _block.to_s + "\s"
- }
- _selected = _selected.strip
- else
- _selected = _self.selection_get[0]
- end
+ _selected = self.selected
_dir, _file = _selected.sub("%%%",":").split('@@@')
if _file
_file = File.expand_path( _file , _dir )
- else
- _file = Tk.getOpenFile('initialdir'=>_dir)
+# else
+# _file = Tk.getOpenFile('initialdir'=>_dir)
end
if _file && _file.strip.length > 0
- Arcadia.process_event(OpenBufferEvent.new(self,'file'=>_file))
- #EditorContract.instance.open_file(self,'file'=>_file)
+ Arcadia.process_event(OpenBufferTransientEvent.new(self,'file'=>_file))
end
}
@@ -154,7 +137,7 @@ def on_build(_event)
@font = Arcadia.conf('treeitem.font')
@font_b = "#{Arcadia.conf('treeitem.font')} bold"
- @htree = Tk::BWidget::Tree.new(self.frame.hinner_frame, Arcadia.style('treepanel')){
+ @htree = BWidgetTreePatched.new(self.frame.hinner_frame, Arcadia.style('treepanel')){
showlines false
deltay 18
opencmd proc{|node| do_open_folder.call(node)}
@@ -171,8 +154,29 @@ def on_build(_event)
# command _scrollcommand
# }.pack('side'=>'right', 'fill'=>'y')
# @htree.yscrollcommand proc{|first,last| _scrollbar.set(first,last)}
+
+ do_double_click = proc{
+ _selected = @htree.selection_get[0]
+ _dir, _file = _selected.sub("%%%",":").split('@@@')
+ if _dir && _file.nil? && File.ftype(node2file(_dir)) == 'directory'
+ _file = Tk.getOpenFile('initialdir'=>node2file(_dir))
+ if _file && _file.strip.length > 0
+ Arcadia.process_event(OpenBufferTransientEvent.new(self,'file'=>_file))
+ end
+# if !_selected.nil? && @htree.open?(node2file(_selected))
+# @htree.close_tree(node2file(_selected))
+# elsif !_selected.nil?
+# @htree.open_tree(node2file(_selected),false)
+# do_open_folder.call(_selected)
+# end
+ end
+ }
+
+ @htree.textbind_append('Double-1',do_double_click)
- self.build_tree
+ self.build_tree
+ self.pop_up_menu_tree
+
end
def on_after_build(_event)
@@ -203,6 +207,44 @@ def on_after_open_buffer(_event)
# end
# end
+ def node2file(_node)
+ if _node[0..0]=='{' && _node[-1..-1]=='}'
+ return _node[1..-2]
+ else
+ return _node
+ end
+ end
+
+ def file2node(_file)
+ if _file.include?("\s") && _file[0..0]!='{'
+ return "{#{_file}}"
+ else
+ return _file
+ end
+ end
+
+
+ def selected
+ if @htree.selection_get[0]
+ if @htree.selection_get[0].length >0
+ _selected = ""
+ if String.method_defined?(:lines)
+ selection_lines = @htree.selection_get[0].lines
+ else
+ selection_lines = @htree.selection_get[0].split("\n")
+ end
+ selection_lines.each{|_block|
+ _selected = _selected + _block.to_s + "\s"
+ }
+ _selected = _selected.strip
+ else
+ _selected = @htree.selection_get[0]
+ end
+ end
+ return _selected
+ end
+
+
def select_file_without_event(_file)
_d, _f = File.split(File.expand_path(_file))
_d = _d.downcase if is_windows?
@@ -299,6 +341,63 @@ def build_tree
build_tree_from_node(root)
end
+ def pop_up_menu_tree
+ @pop_up_tree = TkMenu.new(
+ :parent=>@htree,
+ :tearoff=>0,
+ :title => 'Menu tree'
+ )
+ @pop_up_tree.configure(Arcadia.style('menu'))
+ #----- search submenu
+ sub_ref_search = TkMenu.new(
+ :parent=>@pop_up,
+ :tearoff=>0,
+ :title => 'Ref'
+ )
+ sub_ref_search.configure(Arcadia.style('menu'))
+ sub_ref_search.insert('end',
+ :command,
+ :label=>'Find in files...',
+ :hidemargin => false,
+ :command=> proc{
+ _target = self.selected
+ _dir, _file = _target.sub("%%%",":").split('@@@')
+ if _dir
+ Arcadia.process_event(SearchInFilesEvent.new(self,'dir'=>_dir))
+ end
+ }
+ )
+
+ sub_ref_search.insert('end',
+ :command,
+ :label=>'Act in files...',
+ :hidemargin => false,
+ :command=> proc{
+ _target = self.selected
+ _dir, _file = _target.sub("%%%",":").split('@@@')
+ if _dir
+ Arcadia.process_event(AckInFilesEvent.new(self,'dir'=>_dir))
+ end
+ }
+ )
+ @pop_up_tree.insert('end',
+ :cascade,
+ :label=>'Search from here',
+ :menu=>sub_ref_search,
+ :hidemargin => false
+ )
+
+
+ @htree.areabind_append("Button-3",
+ proc{|x,y|
+ _x = TkWinfo.pointerx(@htree)
+ _y = TkWinfo.pointery(@htree)
+ @pop_up_tree.popup(_x,_y)
+ },
+ "%x %y")
+ end
+
+
def add_to_tree(_file)
_d, _f = File.split(File.expand_path(_file))
return if _f.nil?
View
3  ext/ae-search-in-files/ae-search-in-files.rb
@@ -19,6 +19,9 @@ def initialize(_service)
def on_before_search_in_files(_event)
if _event.what.nil?
+ if _event.dir
+ @find.e_dir.text(_event.dir)
+ end
@find.show
end
end
View
4 ext/ae-search-in-files/ext/ack-in-files/ack-in-files.rb
@@ -16,9 +16,7 @@ def initialize(_service)
end
def on_before_ack_in_files(_event)
- if _event.what.nil?
- @find.show
- end
+ on_before_search_in_files(_event)
end
def do_find # overwrite
View
4 lib/a-tkcommons.rb
@@ -6,7 +6,7 @@
require "lib/a-commons"
require "tk/menu"
-class MyBwTree < Tk::BWidget::Tree
+class BWidgetTreePatched < Tk::BWidget::Tree
def open?(node)
bool(self.itemcget(tagid(node), 'open'))
@@ -1436,4 +1436,4 @@ def initialize(_parent=nil)
_wrapper.show_h_scroll
place('x'=>100,'y'=>100,'height'=> 220,'width'=> 500)
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.