Module: Redcar::Textmate
- Defined in:
- plugins/textmate/lib/textmate.rb,
plugins/textmate/lib/textmate/editor.rb,
plugins/textmate/lib/textmate/bundle.rb,
plugins/textmate/lib/textmate/snippet.rb,
plugins/textmate/lib/textmate/commands.rb,
plugins/textmate/lib/textmate/preference.rb,
plugins/textmate/lib/textmate/environment.rb,
plugins/textmate/lib/textmate/tree_mirror.rb,
plugins/textmate/lib/textmate/editor/drag_controller.rb,
plugins/textmate/lib/textmate/editor/bundle_controller.rb,
plugins/textmate/lib/textmate/editor/snippet_controller.rb
Defined Under Namespace
Classes: BackgroundSetting, BoldSetting, Bundle, BundleEditor, BundleEditorController, BundleNode, ClearBundleMenu, CommentSetting, CompletionCommandSetting, CompletionsSetting, CreateNewBundle, CreateNewSnippet, CreateNewSnippetGroup, DecreaseIndentPatternSetting, DeleteNode, DisableDefaultCompletionSetting, DragController, EmptyTree, Environment, FontStyleSetting, ForegroundSetting, HighlightPairsSetting, IncreaseIndentPatternSetting, IndentNextLinePatternSetting, InstalledBundles, ItalicSetting, OpenBundleEditor, OpenSnippetEditor, PinBundleToMenu, Preference, ReloadSnippetTree, RemovePinnedBundle, RenameSnippetGroup, Setting, ShellVariablesSetting, ShowInSymbolListSetting, ShowSnippetTree, SmartTypingPairsSetting, Snippet, SnippetEditorController, SnippetGroup, SnippetNode, SortNodes, SpellCheckingSetting, SymbolTransformationSetting, TreeController, TreeMirror, UnIndentedLinePatternSetting, UnderlineSetting
Constant Summary
- TREE_TITLE =
"Bundles"
Class Method Summary
(collapse)
Class Method Details
+ (Object) all_bundle_paths
20
21
22
23
24
25
26
27
|
# File 'plugins/textmate/lib/textmate.rb', line 20
def self.all_bundle_paths
@all_bundle_paths = Dir[File.join(user_bundle_dir, "*")]
@all_bundle_paths += Dir[File.join(RedcarBundles.dir, "Bundles", "*")]
Redcar.plugin_manager.loaded_plugins.each do |plugin|
@all_bundle_paths += Dir[File.join(File.dirname(plugin.definition_file), "Bundles", "*")]
end
@all_bundle_paths
end
|
+ (Object) all_bundles
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# File 'plugins/textmate/lib/textmate.rb', line 164
def self.all_bundles
@all_bundles ||= begin
cache.cache do
dups = []
uuids = []
bundles = all_bundle_paths.map {|path|
b = Bundle.new(path)
dups << b.uuid if uuids.include?(b.uuid)
uuids << b.uuid
b
}
bundles.reject! {|b|
dups.include?(b.uuid) and File.dirname(b.path) != user_bundle_dir}
bundles
end
end
end
|
+ (Object) all_settings
188
189
190
191
192
|
# File 'plugins/textmate/lib/textmate.rb', line 188
def self.all_settings
@all_settings ||= begin
all_bundles.map {|b| b.preferences }.flatten.map {|p| p.settings}.flatten
end
end
|
+ (Object) all_snippets
182
183
184
185
186
|
# File 'plugins/textmate/lib/textmate.rb', line 182
def self.all_snippets
@all_snippets ||= begin
all_bundles.map {|b| b.snippets }.flatten
end
end
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'plugins/textmate/lib/textmate.rb', line 145
def self.(builder)
if Textmate.storage['load_bundles_menu']
Menu::Builder.build do |a|
Textmate.all_bundles.sort_by {|b| (b.name||"").downcase}.each do |bundle|
name = (bundle.name||"").downcase
unless Textmate.storage['select_bundles_for_menu'] and not Textmate.storage['loaded_bundles'].to_a.include?(name)
bundle.(a).each do |c|
builder.append(c)
end
end
end
end
end
end
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
|
# File 'plugins/textmate/lib/textmate.rb', line 55
def self.(tree,node)
Menu::Builder.build do
if not node.nil?
if node.children.size > 0
item("Sort") do
SortNodes.new(tree,node).run
end
end
case node
when BundleNode
item("Edit Bundle") do
OpenBundleEditor.new(node.bundle).run
end
item("Add new Snippet...") do
CreateNewSnippet.new(node.bundle).run
end
item("Add new Snippet Menu...") do
CreateNewSnippetGroup.new(tree, node).run
end
if Textmate.storage['load_bundles_menu']
if Textmate.storage['loaded_bundles'].include?(node.text.downcase)
item ("Remove from Bundles Menu") do
RemovePinnedBundle.new(node.text).run
end
else
item("Pin to Bundles Menu") do
PinBundleToMenu.new(node.text).run
end
end
end
when SnippetNode
item("Edit Snippet") do
OpenSnippetEditor.new(node.snippet).run
end
item("Delete Snippet") do
DeleteNode.new(node).run
end
when SnippetGroup
item("Rename...") do
RenameSnippetGroup.new(tree,node).run
end
item("Add new Snippet...") do
CreateNewSnippet.new(node.bundle,node.uuid).run
end
item("Add new Snippet Menu...") do
CreateNewSnippetGroup.new(tree, node).run
end
item("Delete Menu") do
DeleteNode.new(node).run
end
end
end
item("Create new Bundle") do
CreateNewBundle.new.run
end
end
end
|
160
161
162
|
# File 'plugins/textmate/lib/textmate.rb', line 160
def self.cache
@cache ||= PersistentCache.new("textmate_bundles")
end
|
39
40
41
42
43
44
45
46
47
|
# File 'plugins/textmate/lib/textmate.rb', line 39
def self.keymaps
osx = Redcar::Keymap.build("main", [:osx]) do
link "Cmd+Shift+B", ShowSnippetTree
end
lin = Redcar::Keymap.build("main", [:windows,:linux]) do
link "Ctrl+Shift+B", ShowSnippetTree
end
[osx,lin]
end
|
29
30
31
32
33
34
35
36
37
|
# File 'plugins/textmate/lib/textmate.rb', line 29
def self.
Menu::Builder.build do
"Bundles" do
if Textmate.storage['loaded_bundles'].size() > 0 and Textmate.storage['load_bundles_menu']
item "Clear Bundle Menu", :command => ClearBundleMenu, :priority => 20
end
end
end
end
|
+ (Object) refresh_tree
113
114
115
116
117
118
|
# File 'plugins/textmate/lib/textmate.rb', line 113
def self.refresh_tree
win = Redcar.app.focussed_window
if tree = win.treebook.trees.detect {|tree| tree.tree_mirror.title == TREE_TITLE }
tree.refresh
end
end
|
+ (Object) settings(type = nil)
194
195
196
197
|
# File 'plugins/textmate/lib/textmate.rb', line 194
def self.settings(type=nil)
@all_settings_by_type ||= {}
@all_settings_by_type[type] ||= all_settings.select {|s| s.is_a?(type) }
end
|
134
135
136
137
138
139
140
141
142
143
|
# File 'plugins/textmate/lib/textmate.rb', line 134
def self.storage
@storage ||= begin
storage = Plugin::Storage.new('textmate')
storage.set_default('load_bundles_menu',false)
storage.set_default('select_bundles_for_menu',true)
storage.set_default('select_bundles_for_tree',false)
storage.set_default('loaded_bundles',[])
storage
end
end
|
49
50
51
52
53
|
# File 'plugins/textmate/lib/textmate.rb', line 49
def self.toolbars
Redcar::ToolBar::Builder.build do
item "Snippet Browser", :command => Textmate::ShowSnippetTree, :icon => File.join(Redcar.icons_directory, "document-tree.png"), :barname => :help
end
end
|
+ (Object) translate_key_equivalent(keyeq, name = nil)
Translates a Textmate key equivalent into a Redcar keybinding.
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
|
# File 'plugins/textmate/lib/textmate.rb', line 200
def self.translate_key_equivalent(keyeq, name=nil)
if keyeq
key_str = keyeq[-1..-1]
case key_str
when "\n"
letter = "Return"
else
letter = key_str.gsub("\e", "Escape")
end
modifier_str = keyeq[0..-2]
modifiers = modifier_str.split("").map do |modchar|
case modchar
when "^" [2, "Ctrl"]
when "~" [3, "Alt"]
when "@" [1, "Super"]
when "$"
[4, "Shift"]
else
return nil
end
end
if letter =~ /^[[:alpha:]]$/ and letter == letter.upcase
modifiers << [4, "Shift"]
end
modifiers = modifiers.sort_by {|a| a[0]}.map{|a| a[1]}.uniq
res = if modifiers.empty?
letter
else
modifiers.join("+") + "+" + (letter.length == 1 ? letter.upcase : letter)
end
res
end
end
|
+ (Object) user_bundle_dir
16
17
18
|
# File 'plugins/textmate/lib/textmate.rb', line 16
def self.user_bundle_dir
File.join(Redcar.user_dir, "Bundles")
end
|
+ (Object) uuid_hash
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'plugins/textmate/lib/textmate.rb', line 120
def self.uuid_hash
@uuid_hash ||= begin
h = {}
all_bundles.each do |b|
if h[b.uuid].nil?
h[b.uuid] = b
b.snippets.each {|s| h[s.uuid] = s }
b.preferences.each {|p| h[p.uuid] = p }
end
end
h
end
end
|