niklas-vimmate 0.8.0.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.
- data/.autotest +10 -0
- data/CHANGELOG +108 -0
- data/COPYING +20 -0
- data/README +221 -0
- data/Rakefile +97 -0
- data/TODO +21 -0
- data/bin/vimmate +95 -0
- data/config/environment.rb +33 -0
- data/controllers/file_filter_controller.rb +85 -0
- data/controllers/file_popup_menu_controller.rb +40 -0
- data/controllers/vim_controller.rb +28 -0
- data/controllers/vim_mate_controller.rb +76 -0
- data/images/file.png +0 -0
- data/images/file_green.png +0 -0
- data/images/file_orange.png +0 -0
- data/images/file_red.png +0 -0
- data/images/folder.png +0 -0
- data/images/folder_green.png +0 -0
- data/images/folder_orange.png +0 -0
- data/images/folder_red.png +0 -0
- data/images/processing.png +0 -0
- data/images/svn_added.png +0 -0
- data/images/svn_conflict.png +0 -0
- data/images/svn_deleted.png +0 -0
- data/images/svn_locked.png +0 -0
- data/images/svn_modified.png +0 -0
- data/images/svn_normal.png +0 -0
- data/images/svn_readonly.png +0 -0
- data/images/vimmate16.png +0 -0
- data/images/vimmate32.png +0 -0
- data/images/vimmate48.png +0 -0
- data/lib/active_window.rb +8 -0
- data/lib/active_window/active_column.rb +218 -0
- data/lib/active_window/active_tree_store.rb +13 -0
- data/lib/active_window/active_tree_store/columns.rb +88 -0
- data/lib/active_window/active_tree_store/extentions.rb +81 -0
- data/lib/active_window/active_tree_store/index.rb +53 -0
- data/lib/active_window/application.rb +133 -0
- data/lib/active_window/controller.rb +58 -0
- data/lib/active_window/dot_file.rb +29 -0
- data/lib/active_window/filtered_active_tree_store.rb +114 -0
- data/lib/active_window/listed_item.rb +127 -0
- data/lib/active_window/signal.rb +46 -0
- data/lib/config_window.rb +90 -0
- data/lib/file_tree_store.rb +73 -0
- data/lib/filtered_file_tree_store.rb +34 -0
- data/lib/gtk_thread_helper.rb +73 -0
- data/lib/listed_directory.rb +43 -0
- data/lib/listed_file.rb +67 -0
- data/lib/try.rb +9 -0
- data/lib/vim/buffers.rb +18 -0
- data/lib/vim/integration.rb +36 -0
- data/lib/vim/netbeans.rb +156 -0
- data/lib/vim/source.vim +18 -0
- data/lib/vim_mate/config.rb +132 -0
- data/lib/vim_mate/dummy_window.rb +14 -0
- data/lib/vim_mate/files_menu.rb +110 -0
- data/lib/vim_mate/icons.rb +156 -0
- data/lib/vim_mate/nice_singleton.rb +53 -0
- data/lib/vim_mate/plugins.rb +6 -0
- data/lib/vim_mate/plugins/inotify/init.rb +4 -0
- data/lib/vim_mate/plugins/inotify/lib/INotify.rb +206 -0
- data/lib/vim_mate/plugins/inotify/lib/directory.rb +58 -0
- data/lib/vim_mate/plugins/subversion/init.rb +7 -0
- data/lib/vim_mate/plugins/subversion/lib/file.rb +59 -0
- data/lib/vim_mate/plugins/subversion/lib/menu.rb +96 -0
- data/lib/vim_mate/plugins/subversion/lib/subversion.rb +157 -0
- data/lib/vim_mate/requirer.rb +68 -0
- data/lib/vim_mate/search_window.rb +227 -0
- data/lib/vim_mate/tags_window.rb +167 -0
- data/lib/vim_mate/terminals_window.rb +163 -0
- data/lib/vim_mate/version.rb +29 -0
- data/lib/vim_mate/vim_widget.rb +150 -0
- data/spec/active_window/active_column_spec.rb +41 -0
- data/spec/active_window/active_tree_store_spec.rb +312 -0
- data/spec/active_window/controller_spec.rb +6 -0
- data/spec/lib/file_tree_store_spec.rb +40 -0
- data/spec/lib/listed_directory_spec.rb +26 -0
- data/spec/lib/listed_file_spec.rb +53 -0
- data/spec/nice_singleton_spec.rb +23 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +10 -0
- data/views/vim_mate.glade +308 -0
- data/vimmate.gemspec +131 -0
- metadata +168 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
=begin
|
2
|
+
= VimMate: Vim graphical add-on
|
3
|
+
Copyright (c) 2006 Guillaume Benny
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
10
|
+
so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
=end
|
23
|
+
|
24
|
+
module VimMate
|
25
|
+
|
26
|
+
# This module contains methods to help when requiring files that
|
27
|
+
# could not be installed on the user computer.
|
28
|
+
module Requirer
|
29
|
+
|
30
|
+
# Runs the provided block if the file can be required. If it can't,
|
31
|
+
# return the value of to_return_on_error
|
32
|
+
def self.require_if(file, to_return_on_error = false)
|
33
|
+
begin
|
34
|
+
require file
|
35
|
+
rescue LoadError
|
36
|
+
to_return_on_error
|
37
|
+
else
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Runs the provided block if the file cannot be required. If it can,
|
43
|
+
# return the value of to_return_on_success
|
44
|
+
def self.require_not_if(file, to_return_on_success = false)
|
45
|
+
begin
|
46
|
+
require file
|
47
|
+
rescue LoadError
|
48
|
+
yield
|
49
|
+
else
|
50
|
+
to_return_on_success
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Exit the program with a nice message if the specified file cannot
|
55
|
+
# be required
|
56
|
+
def self.require_exit(file)
|
57
|
+
require file
|
58
|
+
rescue LoadError
|
59
|
+
puts "Module #{file} is required to run this program"
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
|
63
|
+
# Raise a LoadError if the provided block returns true
|
64
|
+
def self.raise_load_error_if
|
65
|
+
raise LoadError, "Requirer cannot continue" if yield
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
=begin
|
2
|
+
= VimMate: Vim graphical add-on
|
3
|
+
Copyright (c) 2006 Guillaume Benny
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
10
|
+
so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'gtk2'
|
25
|
+
require 'set'
|
26
|
+
|
27
|
+
module VimMate
|
28
|
+
|
29
|
+
# A window that can be used to search for files
|
30
|
+
class SearchWindow
|
31
|
+
|
32
|
+
# Column for the file name
|
33
|
+
NAME = 0
|
34
|
+
# Column for the full path of the file
|
35
|
+
PATH = 1
|
36
|
+
|
37
|
+
# Create the SearchWindow
|
38
|
+
def initialize(file_tree)
|
39
|
+
@open_signal = Set.new
|
40
|
+
@menu_signal = Set.new
|
41
|
+
@file_tree = file_tree
|
42
|
+
@filter = /.*/
|
43
|
+
|
44
|
+
# File name, Path
|
45
|
+
@gtk_list_model = Gtk::ListStore.new(String, String)
|
46
|
+
@gtk_list_model.set_sort_column_id(PATH)
|
47
|
+
@gtk_filtered_list_model = Gtk::TreeModelFilter.new(@gtk_list_model)
|
48
|
+
@gtk_filtered_list_model.set_visible_func do |model, iter|
|
49
|
+
if iter[NAME] =~ @filter
|
50
|
+
true
|
51
|
+
else
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
@gtk_list_view = Gtk::TreeView.new(@gtk_filtered_list_model)
|
57
|
+
@gtk_list_view.selection.mode = Gtk::SELECTION_SINGLE
|
58
|
+
@gtk_list_view.headers_visible = false
|
59
|
+
|
60
|
+
# Double-click, Enter, Space: Signal to open the file
|
61
|
+
@gtk_list_view.signal_connect("row-activated") do |view, path, column|
|
62
|
+
path = @gtk_filtered_list_model.get_iter(path)[PATH]
|
63
|
+
@open_signal.each do |signal|
|
64
|
+
signal.call(path,
|
65
|
+
Config[:files_default_open_in_tabs] ? :tab_open : :open)
|
66
|
+
end
|
67
|
+
@gtk_entry.text = ""
|
68
|
+
end
|
69
|
+
|
70
|
+
# Left-click: Select and Signal to open the menu
|
71
|
+
@gtk_list_view.signal_connect("button_press_event") do |widget, event|
|
72
|
+
if event.kind_of? Gdk::EventButton and event.button == 3
|
73
|
+
path = @gtk_list_view.get_path_at_pos(event.x, event.y)
|
74
|
+
@gtk_list_view.selection.select_path(path[NAME]) if path
|
75
|
+
|
76
|
+
selected = @gtk_list_view.selection.selected
|
77
|
+
if selected
|
78
|
+
@menu_signal.each do |signal|
|
79
|
+
signal.call(selected[PATH])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Same thing as Left-click, but with the keyboard
|
86
|
+
@gtk_list_view.signal_connect("popup_menu") do
|
87
|
+
selected = @gtk_list_view.selection.selected
|
88
|
+
if selected
|
89
|
+
@menu_signal.each do |signal|
|
90
|
+
signal.call(selected[PATH])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Add the columns
|
96
|
+
column = Gtk::TreeViewColumn.new
|
97
|
+
column.title = "Files"
|
98
|
+
|
99
|
+
# File name
|
100
|
+
text_cell_renderer = Gtk::CellRendererText.new
|
101
|
+
if Config[:files_use_ellipsis]
|
102
|
+
text_cell_renderer.ellipsize = Pango::Layout::EllipsizeMode::MIDDLE
|
103
|
+
end
|
104
|
+
column.pack_start(text_cell_renderer, true)
|
105
|
+
column.set_attributes(text_cell_renderer, :text => NAME)
|
106
|
+
|
107
|
+
@gtk_list_view.append_column(column)
|
108
|
+
|
109
|
+
# Put the tree view in a scroll window
|
110
|
+
@gtk_scrolled_window = Gtk::ScrolledWindow.new
|
111
|
+
@gtk_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC,
|
112
|
+
Gtk::POLICY_AUTOMATIC)
|
113
|
+
@gtk_scrolled_window.add(@gtk_list_view)
|
114
|
+
|
115
|
+
# Create a label to show the path of the file
|
116
|
+
gtk_label = Gtk::Label.new
|
117
|
+
gtk_label.ellipsize = Pango::Layout::EllipsizeMode::START
|
118
|
+
|
119
|
+
# When a selection is changed in the list view, we change the label
|
120
|
+
# to show the path of the file and which characters matches in the
|
121
|
+
# file name
|
122
|
+
@gtk_list_view.selection.signal_connect("changed") do
|
123
|
+
gtk_label.markup = ""
|
124
|
+
# Nothing to do if there are no selections or if the entry
|
125
|
+
# is empty
|
126
|
+
next if (selected_row = @gtk_list_view.selection.selected).nil?
|
127
|
+
next if @gtk_entry.text.empty?
|
128
|
+
# Build a regexp to add markup information on the file name
|
129
|
+
match = []
|
130
|
+
Regexp.escape(@gtk_entry.text).gsub(/\\.|./) {|c| match << c}
|
131
|
+
match_regexp = Regexp.new(match.join("|"), Config[:files_search_ignore_case])
|
132
|
+
file_name_markup = selected_row[NAME].gsub(match_regexp) do |c|
|
133
|
+
"<b><i>#{c}</i></b>"
|
134
|
+
end
|
135
|
+
# Join the path and the file name with the markup
|
136
|
+
gtk_label.markup = File.join(File.dirname(selected_row[PATH]), file_name_markup)
|
137
|
+
end
|
138
|
+
|
139
|
+
# Build a box to contain the entry for the filter
|
140
|
+
gtk_filter_box = Gtk::HBox.new
|
141
|
+
gtk_filter_box.spacing = 10
|
142
|
+
gtk_filter_box.border_width = 10
|
143
|
+
gtk_filter_box.add(@gtk_entry = Gtk::Entry.new)
|
144
|
+
|
145
|
+
# When the filter changes, create a new regex to filter the file names
|
146
|
+
@gtk_entry.signal_connect("changed") do
|
147
|
+
@filter = Regexp.new(".*" + Regexp.escape(@gtk_entry.text).gsub(/\\.|./) {|c| "#{c}.*"},
|
148
|
+
Config[:files_search_ignore_case])
|
149
|
+
# Unselect everything, filter and reselect the first row
|
150
|
+
@gtk_list_view.selection.unselect_all
|
151
|
+
@gtk_filtered_list_model.refilter
|
152
|
+
if first_row = @gtk_filtered_list_model.iter_first
|
153
|
+
@gtk_list_view.selection.select_iter(first_row)
|
154
|
+
end
|
155
|
+
# Scroll at the top
|
156
|
+
@gtk_scrolled_window.vscrollbar.value = @gtk_scrolled_window.vscrollbar.adjustment.lower
|
157
|
+
end
|
158
|
+
|
159
|
+
# When we press Enter in the entry, open the first file of the list
|
160
|
+
@gtk_entry.signal_connect("activate") do
|
161
|
+
next if (first_row = @gtk_filtered_list_model.iter_first).nil?
|
162
|
+
@open_signal.each do |signal|
|
163
|
+
signal.call(first_row[PATH],
|
164
|
+
Config[:files_default_open_in_tabs] ? :tab_open : :open)
|
165
|
+
end
|
166
|
+
@gtk_entry.text = ""
|
167
|
+
end
|
168
|
+
|
169
|
+
# Add the components in a box
|
170
|
+
@gtk_container_box = Gtk::VBox.new
|
171
|
+
@gtk_container_box.pack_start(gtk_filter_box, false, false)
|
172
|
+
@gtk_container_box.pack_start(@gtk_scrolled_window, true, true)
|
173
|
+
@gtk_container_box.pack_start(gtk_label, false, false)
|
174
|
+
|
175
|
+
|
176
|
+
# TODO put this into file_tree_controller
|
177
|
+
# Process file tree event
|
178
|
+
#@file_tree.add_refresh_signal do |method, file|
|
179
|
+
# next if file.instance_of? ListedDirectory
|
180
|
+
# case method
|
181
|
+
# when :add
|
182
|
+
# # Add the new file
|
183
|
+
# new_row = @gtk_list_model.append
|
184
|
+
# new_row[NAME] = file.name
|
185
|
+
# new_row[PATH] = file.path
|
186
|
+
# when :remove
|
187
|
+
# # A file is removed. Find it and remove it
|
188
|
+
# to_remove = []
|
189
|
+
# @gtk_list_model.each do |model,path,iter|
|
190
|
+
# if iter[PATH] == file.path
|
191
|
+
# to_remove << Gtk::TreeRowReference.new(model, path)
|
192
|
+
# break
|
193
|
+
# end
|
194
|
+
# end
|
195
|
+
# to_remove.each do |element|
|
196
|
+
# @gtk_list_model.remove(@gtk_list_model.get_iter(element.path))
|
197
|
+
# end
|
198
|
+
# end
|
199
|
+
#end
|
200
|
+
end
|
201
|
+
|
202
|
+
# The "window" for this object
|
203
|
+
def gtk_window
|
204
|
+
@gtk_container_box
|
205
|
+
end
|
206
|
+
|
207
|
+
# Set the focus to the entry field in the file search list
|
208
|
+
def focus_file_search
|
209
|
+
@gtk_entry.has_focus = true if @gtk_entry
|
210
|
+
end
|
211
|
+
|
212
|
+
# Add a block that will be called when the user choose to open a file
|
213
|
+
# The block take two argument: the path to the file to open, and a
|
214
|
+
# symbol to indicate the kind: :open, :split_open, :tab_open
|
215
|
+
def add_open_signal(&block)
|
216
|
+
@open_signal << block
|
217
|
+
end
|
218
|
+
|
219
|
+
# Add a block that will be called when the user choose to open the
|
220
|
+
# menu. The block takes one argument: the path to the file to open.
|
221
|
+
def add_menu_signal(&block)
|
222
|
+
@menu_signal << block
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
@@ -0,0 +1,167 @@
|
|
1
|
+
=begin
|
2
|
+
= VimMate: Vim graphical add-on
|
3
|
+
Copyright (c) 2006 Guillaume Benny
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
10
|
+
so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
=end
|
23
|
+
|
24
|
+
module VimMate
|
25
|
+
|
26
|
+
class TagsWindow
|
27
|
+
|
28
|
+
#treestore columns
|
29
|
+
# Column for the tag name
|
30
|
+
NAME = 0
|
31
|
+
# Column for the line it is in
|
32
|
+
LINE = 1
|
33
|
+
PATH = 2
|
34
|
+
|
35
|
+
#path_node_connection columns
|
36
|
+
NODE = 0
|
37
|
+
METHODS = 1
|
38
|
+
CLASSES = 2
|
39
|
+
|
40
|
+
def add_parent_rows(paths)
|
41
|
+
#add some parents
|
42
|
+
@path_node_connection = Hash.new(false)
|
43
|
+
paths.each do |path|
|
44
|
+
node = @tags_treestore.append(nil)
|
45
|
+
node[0] = path.split('/').last
|
46
|
+
node[1] = ''
|
47
|
+
node[2] = ''
|
48
|
+
methods = @tags_treestore.append(node)
|
49
|
+
methods[0] = 'Methods'
|
50
|
+
methods[1] = ''
|
51
|
+
methods[2] = ''
|
52
|
+
classes = @tags_treestore.append(node)
|
53
|
+
classes[0] = 'Classes'
|
54
|
+
classes[1] = ''
|
55
|
+
classes[2] = ''
|
56
|
+
@path_node_connection[path] = [node, methods, classes]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize(vim_window = FalseClass)
|
61
|
+
@vim_window = vim_window
|
62
|
+
@tags_treestore = Gtk::TreeStore.new(String,String,String)
|
63
|
+
|
64
|
+
# Tree View
|
65
|
+
@tags_tree_view = Gtk::TreeView.new(@tags_treestore)
|
66
|
+
@tags_tree_view.selection.mode = Gtk::SELECTION_SINGLE
|
67
|
+
@tags_tree_view.headers_visible = Config[:file_headers_visible]
|
68
|
+
@tags_tree_view.hover_selection = Config[:file_hover_selection]
|
69
|
+
|
70
|
+
tags_renderer = Gtk::CellRendererText.new
|
71
|
+
col = Gtk::TreeViewColumn.new("Identifier", tags_renderer, :text => NAME)
|
72
|
+
@tags_tree_view.append_column(col)
|
73
|
+
col = Gtk::TreeViewColumn.new("Line", tags_renderer, :text => LINE)
|
74
|
+
@tags_tree_view.append_column(col)
|
75
|
+
|
76
|
+
# Double-click, Enter, Space: Signal to open the file
|
77
|
+
@tags_tree_view.signal_connect("row-activated") do |view, path, column|
|
78
|
+
iter = @tags_treestore.get_iter(path)
|
79
|
+
@vim_window.open_and_jump_to_line iter[PATH], iter[LINE].to_i
|
80
|
+
end
|
81
|
+
|
82
|
+
Signal.on_file_opened do |path|
|
83
|
+
sleep 0.5
|
84
|
+
do_refresh_tags
|
85
|
+
end
|
86
|
+
|
87
|
+
#@tags_text_buffer = Gtk::TextBuffer.new()
|
88
|
+
#gtk_text_view = Gtk::TextView.new(@tags_text_buffer)
|
89
|
+
#gtk_text_view.editable = false
|
90
|
+
#gtk_text_view.cursor_visible = false
|
91
|
+
|
92
|
+
# Set the default size for the file list
|
93
|
+
|
94
|
+
Signal.on_file_modified do |path|
|
95
|
+
paths = @vim_window.get_all_buffer_paths
|
96
|
+
if paths.include?(path)
|
97
|
+
do_refresh_tags
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
#Signal.on_file_deleted do |path|
|
102
|
+
# #do_refresh_tags
|
103
|
+
#end
|
104
|
+
|
105
|
+
#Signal.on_file_created do |path|
|
106
|
+
# #do_refresh_tags
|
107
|
+
#end
|
108
|
+
end
|
109
|
+
|
110
|
+
# The "window" for this object
|
111
|
+
def gtk_window
|
112
|
+
@tags_tree_view
|
113
|
+
end
|
114
|
+
|
115
|
+
#TODO:
|
116
|
+
#refresh upon switch to this tab:
|
117
|
+
#switch-page: self, page, page_num
|
118
|
+
#Emitted when the user or a function changes the current page.
|
119
|
+
#
|
120
|
+
# * self: the object which received the signal.
|
121
|
+
# * page: the new current Gtk::NotebookPage
|
122
|
+
# * page_num: the index of the page
|
123
|
+
|
124
|
+
def do_refresh_tags(paths=nil)
|
125
|
+
if not paths
|
126
|
+
paths = @vim_window.get_all_buffer_paths
|
127
|
+
end
|
128
|
+
|
129
|
+
@tags_treestore.clear
|
130
|
+
add_parent_rows(paths)
|
131
|
+
|
132
|
+
paths.each do |path|
|
133
|
+
#TODO make me dependent/configurable on file type/suffix
|
134
|
+
tags = `ctags --sort=1 -ex #{path}`
|
135
|
+
last_class = nil
|
136
|
+
|
137
|
+
whats_a_tag = %r[^(\w+)\s+(\w+\s?\w+)\s+(\d+)\s+(\S+)]
|
138
|
+
tags.each_line do |tag|
|
139
|
+
if elems = whats_a_tag.match(tag)
|
140
|
+
id, type, line, file = elems[1..-1]
|
141
|
+
case type
|
142
|
+
when 'function'
|
143
|
+
new_row = @tags_treestore.append(@path_node_connection[path][METHODS])
|
144
|
+
new_row.set_value(NAME, id)
|
145
|
+
new_row.set_value(LINE, line)
|
146
|
+
new_row.set_value(PATH, file)
|
147
|
+
when 'class'
|
148
|
+
new_row = @tags_treestore.append(@path_node_connection[path][CLASSES])
|
149
|
+
new_row.set_value(NAME, id)
|
150
|
+
new_row.set_value(LINE, line)
|
151
|
+
new_row.set_value(PATH, file)
|
152
|
+
last_class = new_row
|
153
|
+
when /^(singleton )?method|member$/
|
154
|
+
new_row = @tags_treestore.append(last_class)
|
155
|
+
new_row.set_value(NAME, id)
|
156
|
+
new_row.set_value(LINE, line)
|
157
|
+
new_row.set_value(PATH, file)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
@tags_tree_view.expand_all
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|