xiki 0.5.0a
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/Gemfile +11 -0
- data/LICENSE +22 -0
- data/README.markdown +83 -0
- data/Rakefile +8 -0
- data/bin/xiki +46 -0
- data/etc/command/xiki_command.rb +203 -0
- data/etc/command/xiki_process.rb +52 -0
- data/etc/command/xiki_wrapper +2 -0
- data/etc/js/menu1.js +55 -0
- data/etc/js/xiki.js +259 -0
- data/etc/logo.png +0 -0
- data/etc/presentations/bootstrap.deck +5 -0
- data/etc/presentations/databases.deck +41 -0
- data/etc/presentations/diffs.deck +23 -0
- data/etc/presentations/documentation.deck +14 -0
- data/etc/presentations/effects.deck +5 -0
- data/etc/presentations/face.deck +297 -0
- data/etc/presentations/files.deck +79 -0
- data/etc/presentations/icons.deck +22 -0
- data/etc/presentations/images.deck +24 -0
- data/etc/presentations/key_shortcuts.deck +16 -0
- data/etc/presentations/macros.deck +18 -0
- data/etc/presentations/menu_classes.deck +44 -0
- data/etc/presentations/menu_directories.deck +30 -0
- data/etc/presentations/notes.deck +19 -0
- data/etc/presentations/other_languages.deck +55 -0
- data/etc/presentations/other_wiki_syntaxes.deck +4 -0
- data/etc/presentations/piano.deck +5 -0
- data/etc/presentations/potential/diffs.deck +38 -0
- data/etc/presentations/potential/evolution.deck +18 -0
- data/etc/presentations/potential/intro.deck +711 -0
- data/etc/presentations/potential/intro1.deck +711 -0
- data/etc/presentations/potential/intro2.deck +97 -0
- data/etc/presentations/potential/make_mysql_menu.deck +36 -0
- data/etc/presentations/potential/ruby_development.deck +17 -0
- data/etc/presentations/potential/ui_prototyping.deck +50 -0
- data/etc/presentations/potential/web_dev.deck +4 -0
- data/etc/presentations/potential/web_development.deck +10 -0
- data/etc/presentations/potential/wiki.deck +45 -0
- data/etc/presentations/presentations.deck +24 -0
- data/etc/presentations/rails_development.deck +29 -0
- data/etc/presentations/search_key_shortcuts.deck +37 -0
- data/etc/presentations/simplest_possible_ui.deck +37 -0
- data/etc/presentations/svg.deck +5 -0
- data/etc/presentations/testing.deck +28 -0
- data/etc/presentations/the_end.deck +13 -0
- data/etc/presentations/type_something_and_double_click.deck +57 -0
- data/etc/presentations/type_the_acronym.deck +144 -0
- data/etc/presentations/web_browser.deck +56 -0
- data/etc/presentations/xiki_command.deck +20 -0
- data/etc/presentations/xiki_url.deck +14 -0
- data/etc/shark.icns +0 -0
- data/etc/shark_script.icns +0 -0
- data/etc/snippets/html.notes +7 -0
- data/etc/snippets/notes.notes +20 -0
- data/etc/snippets/rb.notes +38 -0
- data/etc/templates/menu_template.menu +2 -0
- data/etc/templates/menu_template.rb +8 -0
- data/etc/templates/template.rb +5 -0
- data/etc/themes/Dark_Metal.notes +28 -0
- data/etc/themes/Orange_Path.notes +15 -0
- data/etc/themes/Shiny_Blue.notes +27 -0
- data/etc/themes/Shiny_Green.notes +27 -0
- data/etc/wrappers/wrapper.js +17 -0
- data/etc/wrappers/wrapper.py +20 -0
- data/etc/wrappers/wrapper.rb +25 -0
- data/lib/block.rb +72 -0
- data/lib/bookmarks.rb +352 -0
- data/lib/buffers.rb +170 -0
- data/lib/clipboard.rb +333 -0
- data/lib/code.rb +860 -0
- data/lib/code_tree.rb +476 -0
- data/lib/color.rb +274 -0
- data/lib/console.rb +557 -0
- data/lib/control_lock.rb +9 -0
- data/lib/control_tab.rb +176 -0
- data/lib/core_ext.rb +31 -0
- data/lib/cursor.rb +111 -0
- data/lib/deletes.rb +65 -0
- data/lib/diff_log.rb +297 -0
- data/lib/effects.rb +145 -0
- data/lib/environment.rb +5 -0
- data/lib/file_tree.rb +1875 -0
- data/lib/files.rb +334 -0
- data/lib/hide.rb +259 -0
- data/lib/history.rb +286 -0
- data/lib/image.rb +51 -0
- data/lib/incrementer.rb +15 -0
- data/lib/insert.rb +7 -0
- data/lib/irc.rb +22 -0
- data/lib/key_bindings.rb +658 -0
- data/lib/keys.rb +754 -0
- data/lib/launcher.rb +1351 -0
- data/lib/line.rb +429 -0
- data/lib/links.rb +6 -0
- data/lib/location.rb +175 -0
- data/lib/macros.rb +48 -0
- data/lib/man.rb +19 -0
- data/lib/menu.rb +708 -0
- data/lib/merb.rb +259 -0
- data/lib/message.rb +5 -0
- data/lib/meths.rb +56 -0
- data/lib/mode.rb +34 -0
- data/lib/move.rb +248 -0
- data/lib/notes.rb +1000 -0
- data/lib/numbers.rb +45 -0
- data/lib/ol.rb +203 -0
- data/lib/ol_helper.rb +44 -0
- data/lib/overlay.rb +167 -0
- data/lib/pause_means_space.rb +68 -0
- data/lib/php.rb +22 -0
- data/lib/projects.rb +21 -0
- data/lib/relinquish_exception.rb +2 -0
- data/lib/remote.rb +206 -0
- data/lib/requirer.rb +46 -0
- data/lib/rest_tree.rb +108 -0
- data/lib/ruby.rb +57 -0
- data/lib/ruby_console.rb +165 -0
- data/lib/search.rb +1572 -0
- data/lib/search_term.rb +40 -0
- data/lib/snippet.rb +68 -0
- data/lib/specs.rb +229 -0
- data/lib/styles.rb +274 -0
- data/lib/svn.rb +682 -0
- data/lib/text_util.rb +110 -0
- data/lib/tree.rb +1871 -0
- data/lib/tree_cursor.rb +87 -0
- data/lib/trouble_shooting.rb +27 -0
- data/lib/url_tree.rb +11 -0
- data/lib/view.rb +1474 -0
- data/lib/window.rb +133 -0
- data/lib/xiki.rb +404 -0
- data/menus/accounts.rb +5 -0
- data/menus/address_book.rb +21 -0
- data/menus/agenda.rb +28 -0
- data/menus/all.rb +5 -0
- data/menus/amazon.rb +16 -0
- data/menus/app.rb +16 -0
- data/menus/applescript.rb +46 -0
- data/menus/as.rb +15 -0
- data/menus/bookmarklet.rb +63 -0
- data/menus/bootstrap.rb +568 -0
- data/menus/browse.rb +13 -0
- data/menus/browser.rb +78 -0
- data/menus/cassandra_db.rb +36 -0
- data/menus/chmod.rb +27 -0
- data/menus/classes.rb +5 -0
- data/menus/coffee_script.rb +35 -0
- data/menus/computer.rb +24 -0
- data/menus/contacts.rb +5 -0
- data/menus/cookies.rb +25 -0
- data/menus/couch.rb +184 -0
- data/menus/crop.rb +45 -0
- data/menus/css.rb +55 -0
- data/menus/current.rb +5 -0
- data/menus/db.rb +12 -0
- data/menus/deck.rb +219 -0
- data/menus/dictionary.rb +9 -0
- data/menus/dir.rb +8 -0
- data/menus/disk.rb +5 -0
- data/menus/do.rb +13 -0
- data/menus/docs.rb +58 -0
- data/menus/dotsies.rb +107 -0
- data/menus/edited.rb +18 -0
- data/menus/emacs.rb +17 -0
- data/menus/enter.rb +13 -0
- data/menus/eval.rb +17 -0
- data/menus/executable.rb +16 -0
- data/menus/filter.rb +46 -0
- data/menus/firefox.rb +607 -0
- data/menus/foo.rb +30 -0
- data/menus/french.rb +7 -0
- data/menus/git.rb +185 -0
- data/menus/gito.rb +785 -0
- data/menus/google.rb +35 -0
- data/menus/google_images.rb +11 -0
- data/menus/google_patents.rb +10 -0
- data/menus/gutenberg.rb +13 -0
- data/menus/head.rb +10 -0
- data/menus/headings.rb +39 -0
- data/menus/html.rb +61 -0
- data/menus/icon.rb +40 -0
- data/menus/images.menu +2 -0
- data/menus/img.rb +15 -0
- data/menus/info.rb +9 -0
- data/menus/ip.rb +10 -0
- data/menus/iterm.rb +36 -0
- data/menus/itunes.rb +78 -0
- data/menus/javascript.rb +74 -0
- data/menus/layout.rb +18 -0
- data/menus/local_storage.rb +67 -0
- data/menus/ls.rb +19 -0
- data/menus/mac.rb +87 -0
- data/menus/maps.rb +18 -0
- data/menus/matches.rb +18 -0
- data/menus/memcache.rb +117 -0
- data/menus/mkdir.rb +23 -0
- data/menus/mongo.rb +83 -0
- data/menus/mysql.rb +294 -0
- data/menus/node.rb +88 -0
- data/menus/open.rb +19 -0
- data/menus/outline.rb +24 -0
- data/menus/piano.rb +746 -0
- data/menus/postgres.rb +34 -0
- data/menus/pre.rb +5 -0
- data/menus/python.rb +39 -0
- data/menus/rails.rb +160 -0
- data/menus/rake.rb +12 -0
- data/menus/redmine.rb +168 -0
- data/menus/riak_tree.rb +204 -0
- data/menus/rss.rb +15 -0
- data/menus/safari.rb +11 -0
- data/menus/sass.rb +15 -0
- data/menus/say.rb +6 -0
- data/menus/scale.rb +49 -0
- data/menus/serve.rb +78 -0
- data/menus/shuffle.rb +24 -0
- data/menus/spanish.rb +7 -0
- data/menus/standalone.rb +57 -0
- data/menus/tail.rb +41 -0
- data/menus/technologies.rb +19 -0
- data/menus/themes.rb +32 -0
- data/menus/thesaurus.rb +13 -0
- data/menus/to.rb +24 -0
- data/menus/twitter.rb +57 -0
- data/menus/wikipedia.rb +34 -0
- data/menus/words.rb +11 -0
- data/spec/code_tree_spec.rb +59 -0
- data/spec/diff_log_spec.rb +40 -0
- data/spec/file_tree_spec.rb +102 -0
- data/spec/keys_spec.rb +24 -0
- data/spec/line_spec.rb +68 -0
- data/spec/menu_spec.rb +50 -0
- data/spec/ol_spec.rb +98 -0
- data/spec/remote_spec.rb +43 -0
- data/spec/search_spec.rb +162 -0
- data/spec/text_util_spec.rb +119 -0
- data/spec/tree_cursor_spec.rb +91 -0
- data/spec/tree_spec.rb +955 -0
- data/tests/console_test.rb +11 -0
- data/tests/couch_db_test.rb +12 -0
- data/tests/diff_log_test.rb +43 -0
- data/tests/el_mixin.rb +16 -0
- data/tests/git_test.rb +95 -0
- data/tests/keys_test.rb +19 -0
- data/tests/line_test.rb +38 -0
- data/tests/merb_test.rb +11 -0
- data/tests/redmine_test.rb +50 -0
- data/tests/remote_test.rb +31 -0
- data/tests/rest_tree_test.rb +70 -0
- data/xiki.gemspec +37 -0
- metadata +332 -0
data/lib/files.rb
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
class Files
|
|
3
|
+
|
|
4
|
+
def self.menu
|
|
5
|
+
"
|
|
6
|
+
- @edited/
|
|
7
|
+
- @current/
|
|
8
|
+
- tree) @Buffers.tree 25/
|
|
9
|
+
- .history/
|
|
10
|
+
- docs/
|
|
11
|
+
> Summary
|
|
12
|
+
| The 'files' menu deals with navigating the filesystem.
|
|
13
|
+
|
|
|
14
|
+
- keys/
|
|
15
|
+
> Navigating
|
|
16
|
+
| open+tree - navigate the files in a bookmarked dir
|
|
17
|
+
| (type '/' for the root)
|
|
18
|
+
| search+bookmark - searches file contents in a bookmarked dir
|
|
19
|
+
|
|
|
20
|
+
> Recent Files
|
|
21
|
+
| open+current - Show files currently open
|
|
22
|
+
| open+edited - Show files recently edited
|
|
23
|
+
| open+history - Show files recently open
|
|
24
|
+
|
|
|
25
|
+
> Saving
|
|
26
|
+
| as+file - saves the file
|
|
27
|
+
| (using the normal emacs shortcut won't update the difflog)
|
|
28
|
+
|
|
|
29
|
+
> File Trees
|
|
30
|
+
| do+name+file
|
|
31
|
+
| Renames a file (the file in a tree that the cursor is on).
|
|
32
|
+
|
|
|
33
|
+
| do+kill+file
|
|
34
|
+
| Deletes a file (the file in a tree that the cursor is on).
|
|
35
|
+
|
|
|
36
|
+
| do+copy+to
|
|
37
|
+
| Copies a file in the filesystem. Used in a tree. To use:
|
|
38
|
+
|
|
|
39
|
+
| - 1) Put the cursor on a file in a tree
|
|
40
|
+
| - 2) do as+spot to remember that's the file you want to copy
|
|
41
|
+
| - 3) Put cursor on a file you want to copy it to
|
|
42
|
+
| - If you don't want to over-write an existing file
|
|
43
|
+
| - add the filename to the tree that you want to exist
|
|
44
|
+
| - 4) Type do+copy+to
|
|
45
|
+
|
|
|
46
|
+
> See
|
|
47
|
+
@diff_log/docs/
|
|
48
|
+
"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
@@dir_hash = {
|
|
52
|
+
'j' => '.js',
|
|
53
|
+
'r' => '.rb',
|
|
54
|
+
's' => '/spec/',
|
|
55
|
+
'a' => '/app/',
|
|
56
|
+
'm' => '/app/models/',
|
|
57
|
+
'v' => '/app/views/',
|
|
58
|
+
'c' => '/app/controllers/',
|
|
59
|
+
'n' => '.notes',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# Lets user open a file
|
|
63
|
+
def self.open
|
|
64
|
+
return View.open $el.read_file_name("Open: ") if Keys.prefix_u
|
|
65
|
+
View.open $el.read_file_name("Open: ", "/")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.open_sudo
|
|
69
|
+
$el.find_file "/sudo:root@localhost:#{View.file || View.dir}"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.save
|
|
73
|
+
# If prefix, save as
|
|
74
|
+
if $el.elvar.current_prefix_arg
|
|
75
|
+
$el.write_file $el.read_file_name("Save as: ")
|
|
76
|
+
# Otherwise, difflog save
|
|
77
|
+
else
|
|
78
|
+
$el.difflog_save
|
|
79
|
+
end
|
|
80
|
+
# Refresh
|
|
81
|
+
self.refresh_me_and_next_dired
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def self.copy
|
|
85
|
+
from = Files.file_name
|
|
86
|
+
|
|
87
|
+
View.next
|
|
88
|
+
to = View.dir
|
|
89
|
+
View.previous
|
|
90
|
+
if Keys.prefix_u?
|
|
91
|
+
$el.rename_file(from, to)
|
|
92
|
+
elsif Keys.prefix_uu
|
|
93
|
+
command = "cp -R \"#{from}\" \"#{to}\""
|
|
94
|
+
Console.run command, :sync => true
|
|
95
|
+
else
|
|
96
|
+
$el.copy_file(from, to)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Refresh
|
|
100
|
+
self.refresh_me_and_next_dired
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def self.zip
|
|
104
|
+
#from = Files.file_name(:path => true)
|
|
105
|
+
from = Files.file_name
|
|
106
|
+
$el.other_window 1; to = $el.elvar.default_directory; $el.other_window -1
|
|
107
|
+
if Keys.prefix_u?
|
|
108
|
+
command = "unzip -d \"#{to}\" \"#{from}\""
|
|
109
|
+
else
|
|
110
|
+
command = "zip -r \"#{to}#{from}.zip\" \"#{from}\""
|
|
111
|
+
end
|
|
112
|
+
$el.message command
|
|
113
|
+
$el.shell_command command
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def self.file_name options={}
|
|
117
|
+
if options[:path]
|
|
118
|
+
return $el.buffer_file_name || $el.dired_get_filename #'no_dir
|
|
119
|
+
end
|
|
120
|
+
if $el.buffer_file_name
|
|
121
|
+
return $el.file_name_nondirectory($el.buffer_file_name)
|
|
122
|
+
end
|
|
123
|
+
$el.dired_get_filename(:no_dir)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def self.refresh_me_and_next_dired
|
|
127
|
+
$el.revert_buffer(true, true, true) if($el.elvar.dired_directory)
|
|
128
|
+
$el.other_window 1
|
|
129
|
+
$el.revert_buffer(true, true, true) if($el.elvar.dired_directory)
|
|
130
|
+
$el.other_window -1
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def self.open_tail
|
|
134
|
+
bm = Keys.input(:timed=>true, :prompt=>"Enter bookmark of file to tail (or period for current file): ")
|
|
135
|
+
file = (bm == ".") ?
|
|
136
|
+
View.file :
|
|
137
|
+
Bookmarks["$#{bm}"]
|
|
138
|
+
Console.run "tail -f #{file}", :buffer => "*tail of #{file}"
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def self.edited_array
|
|
142
|
+
$el.elvar.editedhistory_history.to_a
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def self.current times=nil
|
|
146
|
+
Buffers.tree times
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def self.history # *path
|
|
150
|
+
paths = history_array#[0..400]
|
|
151
|
+
paths.map!{|i| i.sub(/(.+\/)(.+)/, "- @\\1\n - \\2")}
|
|
152
|
+
paths.join("\n")
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def self.history_array
|
|
156
|
+
$el.elvar.recentf_list.to_a
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def self.history_tree times=nil
|
|
160
|
+
times ||= History.prefix_times
|
|
161
|
+
puts CodeTree.tree_search_option + Tree.paths_to_tree(history_array[0..(times-1)])
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def self.open_just
|
|
165
|
+
key = Keys.input(:prompt => "Open just currently open files of type (enter a letter): ", :chars=>1)
|
|
166
|
+
dir = @@dir_hash[key]
|
|
167
|
+
return message("No dir matching '#{key}' found. See Files\#@@dir_hash") unless dir
|
|
168
|
+
if Keys.prefix_u?
|
|
169
|
+
Keys.clear_prefix
|
|
170
|
+
Launcher.open("- Files.edited(100, :dir => '#{dir}')/")
|
|
171
|
+
else
|
|
172
|
+
Launcher.open("- Buffers.tree(0, :dir => '#{dir}')/")
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def self.open_last
|
|
177
|
+
key = Keys.input(:prompt => "Open just currently open files of type (enter a letter): ", :chars=>1)
|
|
178
|
+
dir = @@dir_hash[key]
|
|
179
|
+
View.open Files.edited_array.grep((Regexp.new(Regexp.escape(dir)))).first
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def self.open_edited
|
|
183
|
+
case Keys.prefix
|
|
184
|
+
when :u, 8: Launcher.open("- edited/tree/")
|
|
185
|
+
else Launcher.open("- edited/")
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def self.open_history
|
|
190
|
+
case Keys.prefix
|
|
191
|
+
when nil: Keys.prefix = nil; Launcher.open("- Files.history/")
|
|
192
|
+
when 0: Launcher.open("- Files.history_tree/")
|
|
193
|
+
when :u: Launcher.open("- Files.history_tree 7/")
|
|
194
|
+
else Launcher.open("- Files.history_tree #{Keys.prefix}/")
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def self.open? name
|
|
199
|
+
$el.buffer_list.find{|b| $el.buffer_file_name(b) == name}
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def self.open_in_os path=nil
|
|
203
|
+
|
|
204
|
+
# If we're in a file tree, use path
|
|
205
|
+
|
|
206
|
+
if path.nil? && FileTree.handles?
|
|
207
|
+
path = Xiki.trunk[-1]
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
path ||= View.file
|
|
211
|
+
path ||= View.dir
|
|
212
|
+
|
|
213
|
+
$el.shell_command("open \"#{path}\"")
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def self.do_load_file
|
|
217
|
+
$el.revert_buffer(true, true, true) rescue nil
|
|
218
|
+
|
|
219
|
+
View.message "Reverted file"
|
|
220
|
+
return if ! Keys.prefix_u
|
|
221
|
+
|
|
222
|
+
View.message $el.auto_revert_mode ? "Enabled Auto-revert" : "Disabled Auto-revert"
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def self.do_clean_quotes
|
|
226
|
+
with(:save_excursion) do
|
|
227
|
+
$el.clean_crazy_quotes
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
# Use File.basename
|
|
232
|
+
# def self.name path # Extract name from path
|
|
233
|
+
# path.sub(/.+\/(.+)/, "\\1") # Cut of path
|
|
234
|
+
# end
|
|
235
|
+
|
|
236
|
+
# Use File.dirname
|
|
237
|
+
# def self.dir path # Extract dir from path
|
|
238
|
+
# return "" unless path =~ /\//
|
|
239
|
+
# path.sub(/(.+)\/.*/, "\\1") # Cut of path
|
|
240
|
+
# end
|
|
241
|
+
|
|
242
|
+
def self.enter_file
|
|
243
|
+
path = File.expand_path(Keys.bookmark_as_path(:include_file=>1))
|
|
244
|
+
path << "/" if File.directory? path
|
|
245
|
+
View.insert(path)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# This is currently mac-specific
|
|
249
|
+
def self.open_last_screenshot
|
|
250
|
+
|
|
251
|
+
dirs = `ls -t #{Bookmarks["$dt"]}`
|
|
252
|
+
screenshot = Bookmarks["$dt"]+dirs[/.+/]
|
|
253
|
+
|
|
254
|
+
self.open_as screenshot, "Adobe Illustrator"
|
|
255
|
+
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# This is currently mac-specific
|
|
259
|
+
def self.open_as file, application
|
|
260
|
+
command = "open -a \"#{application}\" \"#{file}\""
|
|
261
|
+
|
|
262
|
+
$el.shell_command(command)
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def self.open_in_window file=nil
|
|
266
|
+
|
|
267
|
+
file ||= FileTree.tree_path_or_this_file
|
|
268
|
+
|
|
269
|
+
# Else, reveal current file
|
|
270
|
+
command = "open --reveal \"#{file}\""
|
|
271
|
+
$el.shell_command(command)
|
|
272
|
+
|
|
273
|
+
nil
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def self.dir_of path
|
|
277
|
+
if File.directory? path
|
|
278
|
+
path =~ /\/$/ ? path : "#{path}/"
|
|
279
|
+
else
|
|
280
|
+
path[/.+\//]
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def self.append path, txt
|
|
285
|
+
|
|
286
|
+
return if View.name =~ /_log.notes$/
|
|
287
|
+
path = File.expand_path path
|
|
288
|
+
txt = "#{txt.strip}\n"
|
|
289
|
+
File.open(path, "a") { |f| f << txt }
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# Returns contents of a dir. Just a wrapper around Dir.entries that removes "." and ".."
|
|
293
|
+
def self.in_dir path
|
|
294
|
+
Dir.entries(path).select{|o| o !~ /^\.+$/}
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
def self.open_nth nth
|
|
298
|
+
View.layout_files :no_blink=>1
|
|
299
|
+
View.to_highest
|
|
300
|
+
nth.times { Move.to_quote }
|
|
301
|
+
Effects.blink
|
|
302
|
+
Launcher.launch
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def self.delete_current_file
|
|
306
|
+
|
|
307
|
+
dest_path = View.file
|
|
308
|
+
return View.beep("- There's no file for this buffer!") if ! dest_path
|
|
309
|
+
|
|
310
|
+
View.beep :times=>3
|
|
311
|
+
View.flash "- Delete CURRENT file for sure?", :times=>4
|
|
312
|
+
answer = Keys.input :chars=>1, :prompt=>"- Delete current file for sure?" #"
|
|
313
|
+
|
|
314
|
+
return View.flash("- cancelled!") if answer !~ /y/i
|
|
315
|
+
|
|
316
|
+
command = "rm \"#{dest_path}\""
|
|
317
|
+
|
|
318
|
+
result = Console.run command, :sync=>true
|
|
319
|
+
if (result||"").any?
|
|
320
|
+
View.beep
|
|
321
|
+
View.message "#{result}"
|
|
322
|
+
return
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
return View.kill
|
|
326
|
+
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
if $el
|
|
332
|
+
$el.el4r_lisp_eval("(require 'recentf)")
|
|
333
|
+
$el.el4r_lisp_eval("(recentf-mode 1)")
|
|
334
|
+
end
|
data/lib/hide.rb
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
class Hide
|
|
2
|
+
|
|
3
|
+
@@visible = {}
|
|
4
|
+
|
|
5
|
+
def self.menu
|
|
6
|
+
"
|
|
7
|
+
| TODO: add docs about hiding.
|
|
8
|
+
"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# self.reset
|
|
13
|
+
def self.hide_unless search, options={}
|
|
14
|
+
self.hide_unless_block(options) do |l, bol, eol|
|
|
15
|
+
l =~ search
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.visible
|
|
20
|
+
@@visible
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.already_hidden
|
|
24
|
+
@@already_hidden
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.hide_unless_block options={}, &block
|
|
28
|
+
|
|
29
|
+
# elvar.line_move_ignore_invisible = true
|
|
30
|
+
# @@already_hidden = {}
|
|
31
|
+
# @@visible = []
|
|
32
|
+
|
|
33
|
+
@@visible = []
|
|
34
|
+
|
|
35
|
+
# Unless we can optimize by assuming hidden regions are ok
|
|
36
|
+
unless options[:optimize]
|
|
37
|
+
self.reset
|
|
38
|
+
# Lisp funtion defined below
|
|
39
|
+
l = $el.hide_find_overlays.to_a
|
|
40
|
+
l.each { |i| @@already_hidden[i] = true }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
t = $el.buffer_string
|
|
44
|
+
lines = t.split "\n"
|
|
45
|
+
bol = 1
|
|
46
|
+
left = 1
|
|
47
|
+
in_non_match = false
|
|
48
|
+
|
|
49
|
+
if options[:include_first] # Optionally skip top line
|
|
50
|
+
l = lines.shift
|
|
51
|
+
eol = bol + l.size + 1
|
|
52
|
+
left = eol
|
|
53
|
+
bol = eol
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
lines.each do |l| # For each line
|
|
57
|
+
eol = bol + l.size + 1
|
|
58
|
+
# if (l =~ search) && (! @@already_hidden[bol])
|
|
59
|
+
if (yield(l, bol, eol)) && (! @@already_hidden[bol])
|
|
60
|
+
@@visible << bol
|
|
61
|
+
# If we're at the end of non-match area, hide
|
|
62
|
+
if in_non_match
|
|
63
|
+
@@areas_to_hide << [left, bol]
|
|
64
|
+
in_non_match = false
|
|
65
|
+
end
|
|
66
|
+
left = eol
|
|
67
|
+
else
|
|
68
|
+
in_non_match = true
|
|
69
|
+
@@already_hidden[bol] = true
|
|
70
|
+
end
|
|
71
|
+
bol = eol
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
@@areas_to_hide << [left, bol] if in_non_match
|
|
75
|
+
|
|
76
|
+
# Construct and run lisp to hide it
|
|
77
|
+
elisp = "(progn\n"
|
|
78
|
+
@@areas_to_hide.each do |i|
|
|
79
|
+
elisp += " (overlay-put (make-overlay #{i[0]} #{i[1]}) 'invisible 'hide)\n"
|
|
80
|
+
end
|
|
81
|
+
$el.el4r_lisp_eval elisp + ")"
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def self.char_from_user
|
|
86
|
+
c = $el.read_char_exclusive
|
|
87
|
+
# Treat C-0 - C-9 the same as 0-9
|
|
88
|
+
c -= 67108864 if(c >= 67108912 && c <= 67108921)
|
|
89
|
+
"#{c.chr}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def self.search search=nil, options={}
|
|
93
|
+
if search
|
|
94
|
+
if search.class == String
|
|
95
|
+
search = /#{Regexp.escape(search)}/i
|
|
96
|
+
end
|
|
97
|
+
self.hide_unless search, options
|
|
98
|
+
else
|
|
99
|
+
search = ""
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
$el.message "Hide.search for: #{search}"
|
|
103
|
+
ch = self.char_from_user
|
|
104
|
+
|
|
105
|
+
first_search = true
|
|
106
|
+
|
|
107
|
+
while true
|
|
108
|
+
break unless ch =~ /[-a-zA-Z ._=@\/\\#,;*<>-]/
|
|
109
|
+
search += ch
|
|
110
|
+
$el.message "hide-search for: #{search}"
|
|
111
|
+
|
|
112
|
+
# If a tab, clear search and keep going
|
|
113
|
+
if ch == ","
|
|
114
|
+
search = ""
|
|
115
|
+
ch = self.char_from_user
|
|
116
|
+
next
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
self.hide_unless /#{Regexp.escape(search)}/i, options
|
|
120
|
+
$el.recenter -3
|
|
121
|
+
|
|
122
|
+
# Don't re-check visible regions from now on
|
|
123
|
+
if first_search
|
|
124
|
+
options.merge!(:optimize => true)
|
|
125
|
+
first_search = false
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# If only one left, go to it
|
|
129
|
+
if @@visible.size == 1 && options[:expand_when_one]
|
|
130
|
+
ch = "1"
|
|
131
|
+
break
|
|
132
|
+
end
|
|
133
|
+
ch = self.char_from_user
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
ch = 1 if ch == "\t" # If a tab, treat it like C-1
|
|
137
|
+
|
|
138
|
+
# If num
|
|
139
|
+
if 1 <= ch.to_i && ch.to_i <= 9
|
|
140
|
+
if @@visible.size > 0
|
|
141
|
+
if @@visible[ch.to_i - 1]
|
|
142
|
+
$el.goto_char @@visible[ch.to_i - 1]
|
|
143
|
+
else
|
|
144
|
+
$el.goto_char @@visible[-1]
|
|
145
|
+
end
|
|
146
|
+
else
|
|
147
|
+
$el.goto_line ch.to_i
|
|
148
|
+
end
|
|
149
|
+
# next_line -1
|
|
150
|
+
self.show
|
|
151
|
+
$el.recenter 0
|
|
152
|
+
# Run enter if option was passed
|
|
153
|
+
if options[:press_enter]
|
|
154
|
+
$el.command_execute "\C-m"
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Show all if they typed C-a
|
|
158
|
+
elsif ch == "\001"
|
|
159
|
+
self.show
|
|
160
|
+
# Else, if control character, execute it and exit
|
|
161
|
+
elsif "\C-a" <= ch && ch <= "\C-z"
|
|
162
|
+
$el.command_execute ch unless ch == "\C-m"
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def self.keys
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Shows things hidden by .hide
|
|
170
|
+
def self.show
|
|
171
|
+
|
|
172
|
+
# Move down to visible line (this doesn't seem to happen on its own)
|
|
173
|
+
while( @@already_hidden[$el.point] )
|
|
174
|
+
$el.forward_line
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# @@already_hidden = {}
|
|
178
|
+
# Delete hidden overlays
|
|
179
|
+
$el.el4r_lisp_eval %`
|
|
180
|
+
(dolist (over (overlays-in (point-min) (point-max) ))
|
|
181
|
+
(when
|
|
182
|
+
(overlay-get over 'invisible)
|
|
183
|
+
(delete-overlay over)
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
`
|
|
187
|
+
self.reset
|
|
188
|
+
@@visible = []
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def self.visible
|
|
192
|
+
@@visible
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def self.reset
|
|
196
|
+
@@areas_to_hide = []
|
|
197
|
+
# Make this be stored per page, not globally
|
|
198
|
+
@@already_hidden = {}
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# What is this doing here??
|
|
202
|
+
self.reset
|
|
203
|
+
$el.add_to_invisibility_spec :hide if $el
|
|
204
|
+
|
|
205
|
+
def self.hide_by_indent indent=nil
|
|
206
|
+
indent ||= Keys.prefix
|
|
207
|
+
indent = -1 if indent == :u
|
|
208
|
+
|
|
209
|
+
# If no prefix, use indent of current line
|
|
210
|
+
if indent.nil?
|
|
211
|
+
indent = Line.matches(/^ */).size
|
|
212
|
+
# If currently indented to that level, go one deeper
|
|
213
|
+
if $el.elvar.selective_display && indent == ($el.elvar.selective_display - 1)
|
|
214
|
+
indent += 2
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
$el.set_selective_display(indent + 1)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def self.init
|
|
222
|
+
|
|
223
|
+
return if ! $el
|
|
224
|
+
|
|
225
|
+
# Define lisp function to get list of displayed lines
|
|
226
|
+
# In case something has been done to change them
|
|
227
|
+
$el.el4r_lisp_eval %`
|
|
228
|
+
(defun hide-find-overlays ()
|
|
229
|
+
(save-excursion
|
|
230
|
+
(beginning-of-buffer)
|
|
231
|
+
(let (found (res ()))
|
|
232
|
+
(while (not (eq (point) (point-max)))
|
|
233
|
+
(setq found nil)
|
|
234
|
+
; Save if not hidden
|
|
235
|
+
(dolist (o (overlays-at (point)))
|
|
236
|
+
(if (overlay-get o 'invisible)
|
|
237
|
+
(setq found t)
|
|
238
|
+
)
|
|
239
|
+
)
|
|
240
|
+
(if found
|
|
241
|
+
(push (point) res))
|
|
242
|
+
(forward-line)
|
|
243
|
+
)
|
|
244
|
+
(reverse res)
|
|
245
|
+
)
|
|
246
|
+
)
|
|
247
|
+
)
|
|
248
|
+
`
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Reveals all hidden
|
|
252
|
+
def self.reveal
|
|
253
|
+
$el.widen
|
|
254
|
+
self.show
|
|
255
|
+
self.hide_by_indent :u # If hidden by indent
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
end
|
|
259
|
+
Hide.init
|