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/line.rb
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
class Line
|
|
2
|
+
|
|
3
|
+
def self.menu
|
|
4
|
+
"
|
|
5
|
+
- api/
|
|
6
|
+
> Moving
|
|
7
|
+
@ Line.previous # up
|
|
8
|
+
@ Line.next # down
|
|
9
|
+
|
|
|
10
|
+
> Getting text
|
|
11
|
+
@ p Line.value # line text
|
|
12
|
+
@ p Line.indent # indent
|
|
13
|
+
@ p Line.without_indent # without indent
|
|
14
|
+
@ p Line.label # label
|
|
15
|
+
@ p Line.without_label # without label
|
|
16
|
+
|
|
|
17
|
+
> Getting Positions
|
|
18
|
+
@ p Line.left # line start
|
|
19
|
+
@ p Line.right # line ending
|
|
20
|
+
|
|
|
21
|
+
> Tests
|
|
22
|
+
@ p Line.blank? # blank
|
|
23
|
+
@ Line[/s...thing/] # matches something
|
|
24
|
+
"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Text on current line (minus linebreak)
|
|
28
|
+
def self.[] regex, index=0
|
|
29
|
+
self.value[regex, index]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.value n=1, options={}
|
|
33
|
+
eol = "(point-at-eol #{n})"
|
|
34
|
+
|
|
35
|
+
# Optionally include linebreak
|
|
36
|
+
eol = "(+ 1 #{eol})" if options[:include_linebreak]
|
|
37
|
+
|
|
38
|
+
result = $el.el4r_lisp_eval("(buffer-substring (point-at-bol #{n}) #{eol})")
|
|
39
|
+
|
|
40
|
+
if options[:delete]
|
|
41
|
+
$el.el4r_lisp_eval("(delete-region (point-at-bol #{n}) #{eol})")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
result
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Whether line matches pattern
|
|
48
|
+
def self.matches o, line=nil
|
|
49
|
+
line ||= self.value
|
|
50
|
+
line[o]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Return value of next line
|
|
54
|
+
def self.next_value n=2
|
|
55
|
+
#buffer_substring(point_at_bol(n), point_at_eol(n))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Whether next line matches pattern
|
|
59
|
+
def self.next_matches pattern
|
|
60
|
+
self.next_value =~ pattern
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.indent line=nil
|
|
64
|
+
line ||= self.value
|
|
65
|
+
line[/^\s*/].gsub("\t", ' ')
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.right
|
|
69
|
+
$el.point_at_eol
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.at_right?
|
|
73
|
+
$el.point_at_eol == $el.point
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def self.blank?
|
|
77
|
+
self.matches /^$/
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def self.left down=1
|
|
81
|
+
$el.point_at_bol down
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def self.at_left?
|
|
85
|
+
$el.point_at_bol == $el.point
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def self.without_indent txt=nil
|
|
89
|
+
txt ||= self.value
|
|
90
|
+
txt.sub(/^\s+/, "")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.txt
|
|
94
|
+
self.without_indent
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def self.bounds
|
|
98
|
+
[$el.point_at_bol, $el.point_at_eol]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def self.delete leave_linebreak=nil
|
|
102
|
+
value = self.value
|
|
103
|
+
bol, eol = $el.point_at_bol, $el.point_at_eol
|
|
104
|
+
eol += 1 unless leave_linebreak
|
|
105
|
+
$el.delete_region(bol, eol)
|
|
106
|
+
value
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Gets symbol at point
|
|
110
|
+
def self.symbol options={}
|
|
111
|
+
symbol = $el.thing_at_point(:symbol)
|
|
112
|
+
# Delete if option passed
|
|
113
|
+
if options[:delete]
|
|
114
|
+
$el.delete_region(* $el.bounds_of_thing_at_point(:symbol))
|
|
115
|
+
end
|
|
116
|
+
symbol
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Moves down, going to first column
|
|
120
|
+
def self.to_next times=nil
|
|
121
|
+
self.next times
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Moves up, going to first column
|
|
125
|
+
def self.to_previous times=nil
|
|
126
|
+
self.previous times
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Moves down, going to first column
|
|
130
|
+
def self.next times=nil
|
|
131
|
+
$el.forward_line times
|
|
132
|
+
nil
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Moves up, going to first column
|
|
136
|
+
def self.previous times=nil
|
|
137
|
+
times = times ?
|
|
138
|
+
-times :
|
|
139
|
+
-1
|
|
140
|
+
$el.forward_line times
|
|
141
|
+
nil
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def self.beginning
|
|
145
|
+
$el.forward_line 0
|
|
146
|
+
nil
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def self.to_left
|
|
150
|
+
self.beginning
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def self.end
|
|
154
|
+
$el.end_of_line
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def self.to_right
|
|
158
|
+
$el.end_of_line
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def self.to_end
|
|
162
|
+
self.to_right
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def self.to_start
|
|
166
|
+
self.to_left
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def self.to_words
|
|
170
|
+
$el.beginning_of_line
|
|
171
|
+
$el.skip_chars_forward "[^ \t]"
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def self.to_beginning options={}
|
|
175
|
+
down = options[:down]
|
|
176
|
+
prefix = options[:prefix] || Keys.prefix
|
|
177
|
+
down ||= prefix
|
|
178
|
+
|
|
179
|
+
# If prefix go down n lines first
|
|
180
|
+
Line.next down if down.is_a? Fixnum
|
|
181
|
+
|
|
182
|
+
Line.to_left
|
|
183
|
+
|
|
184
|
+
prefix == :u || options[:quote]?
|
|
185
|
+
$el.skip_chars_forward("[^ \t]") :
|
|
186
|
+
$el.skip_chars_forward("[^ \t|]") # If quoted, skip quote unless :u
|
|
187
|
+
|
|
188
|
+
nil
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def self.label line=nil
|
|
193
|
+
line ||= self.value
|
|
194
|
+
# Space or blank can follow colon
|
|
195
|
+
label = line[/^\s*[+-] (.+?): /, 1]
|
|
196
|
+
label ||= line[/^\s*[+-] (.+?):$/, 1]
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def self.without_label options={}
|
|
200
|
+
line = options.has_key?(:line) ? options[:line] : self.value
|
|
201
|
+
|
|
202
|
+
return nil if line.nil?
|
|
203
|
+
|
|
204
|
+
# Delete comment (parenthesis)
|
|
205
|
+
line = line.sub /^(\s*)(?:[+-]|<+) [^\n\(]+\) (.*)/, "\\1\\2"
|
|
206
|
+
|
|
207
|
+
# If paren at end of line, delete label
|
|
208
|
+
line.sub! /^(\s*)(?:[+-]|<+) [^\n\(]+?\)$/, "\\1"
|
|
209
|
+
# If just bullet
|
|
210
|
+
line.sub! /^(\s*)(?:[+-]|<+) (.+)/, "\\1\\2"
|
|
211
|
+
# Remove whitespace by default
|
|
212
|
+
line.sub!(/^ */, '') unless options[:leave_indent]
|
|
213
|
+
|
|
214
|
+
line
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def self.=~ regex
|
|
218
|
+
self.value =~ regex
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
class << self
|
|
222
|
+
alias :start :beginning
|
|
223
|
+
alias :content :without_label
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def self.is_bullet? line=nil
|
|
227
|
+
line ||= self.value
|
|
228
|
+
self.matches /^\s*[+-] /, line
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def self.number pos=nil
|
|
232
|
+
$el.xiki_line_number pos || $el.point
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def self.to_blank
|
|
236
|
+
$el.re_search_forward "^[ \t]*$"
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def self.duplicate_line
|
|
240
|
+
|
|
241
|
+
prefix = Keys.prefix
|
|
242
|
+
|
|
243
|
+
# If in file tree, actually duplicate file
|
|
244
|
+
if prefix == :u && FileTree.handles?
|
|
245
|
+
Location.as_spot
|
|
246
|
+
FileTree.copy_to :prefix=>1
|
|
247
|
+
return
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
column = View.column
|
|
251
|
+
|
|
252
|
+
line = "#{Line.value}\n"
|
|
253
|
+
Line.to_left
|
|
254
|
+
Code.comment(:line) if prefix == :u
|
|
255
|
+
times = if prefix.nil?
|
|
256
|
+
1
|
|
257
|
+
elsif prefix == :u
|
|
258
|
+
1 # Put commented line after
|
|
259
|
+
# 0 # Put commented line before
|
|
260
|
+
elsif prefix == 0
|
|
261
|
+
0
|
|
262
|
+
elsif prefix > 0
|
|
263
|
+
prefix + 1
|
|
264
|
+
elsif prefix < 0
|
|
265
|
+
prefix
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
Line.next times
|
|
269
|
+
View.insert line
|
|
270
|
+
Line.previous
|
|
271
|
+
|
|
272
|
+
View.column = column
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def self.move direction
|
|
276
|
+
column = View.column
|
|
277
|
+
many = Keys.prefix_times
|
|
278
|
+
|
|
279
|
+
many = (0 - many) if direction == :previous
|
|
280
|
+
|
|
281
|
+
line = Line.value 1, :include_linebreak=>true, :delete=>true # Get line
|
|
282
|
+
Line.to_next many
|
|
283
|
+
View.insert line
|
|
284
|
+
|
|
285
|
+
Line.previous
|
|
286
|
+
View.column = column
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def self.sub! from, to
|
|
290
|
+
orig = Location.new
|
|
291
|
+
value = Line.value
|
|
292
|
+
return unless value.sub! from, to
|
|
293
|
+
self.delete :leave
|
|
294
|
+
View.insert value
|
|
295
|
+
orig.go :assume_file=>1
|
|
296
|
+
value
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
def self.gsub! from, to
|
|
300
|
+
orig = Location.new
|
|
301
|
+
value = Line.value
|
|
302
|
+
return unless value.gsub! from, to
|
|
303
|
+
self.delete :leave
|
|
304
|
+
View.insert value
|
|
305
|
+
orig.go :assume_file=>1
|
|
306
|
+
value
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
def self.<< txt, options={}
|
|
310
|
+
orig = View.cursor
|
|
311
|
+
Keys.clear_prefix
|
|
312
|
+
Move.to_end
|
|
313
|
+
View.insert txt
|
|
314
|
+
View.cursor = orig if options[:dont_move]
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
def self.< txt
|
|
318
|
+
self.delete :leave
|
|
319
|
+
View.insert txt
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
#
|
|
323
|
+
# Add slash to end of line, and optionally a string as well
|
|
324
|
+
#
|
|
325
|
+
# Line.add_slash
|
|
326
|
+
# Line.add_slash "hi"
|
|
327
|
+
#
|
|
328
|
+
def self.add_slash options={}
|
|
329
|
+
|
|
330
|
+
line = Line.value
|
|
331
|
+
|
|
332
|
+
line =~ /\/$/ || line.blank? ?
|
|
333
|
+
Move.to_end :
|
|
334
|
+
Line << "/"
|
|
335
|
+
|
|
336
|
+
txt = options.is_a?(String) ? options : options[:txt]
|
|
337
|
+
|
|
338
|
+
orig = View.cursor
|
|
339
|
+
Line << txt if txt
|
|
340
|
+
View.cursor = orig if options[:left]
|
|
341
|
+
nil
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def self.before_cursor
|
|
345
|
+
View.txt self.left, View.cursor
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def self.do_lines_sort
|
|
349
|
+
old = $el.elvar.sort_fold_case# rescue true
|
|
350
|
+
$el.elvar.sort_fold_case = true
|
|
351
|
+
$el.sort_lines(nil, $el.region_beginning, $el.region_end)
|
|
352
|
+
$el.elvar.sort_fold_case = old
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
def self.do_lines_toggle
|
|
356
|
+
prefix = Keys.prefix :clear=>1
|
|
357
|
+
|
|
358
|
+
prefix ||= 1 # Default to one line
|
|
359
|
+
|
|
360
|
+
if prefix.is_a? Fixnum # If number, grab that many lines
|
|
361
|
+
line_a = [Line.left, Line.left(1+prefix)]
|
|
362
|
+
line_b = [Line.left(1+prefix), Line.left(1+prefix*2)]
|
|
363
|
+
Effects.glow :fade_out=>1, :what=>line_b
|
|
364
|
+
txt = View.delete *line_b
|
|
365
|
+
|
|
366
|
+
View.to line_a[0]
|
|
367
|
+
View.<< txt, :dont_move=>1
|
|
368
|
+
line_a_size = line_a[1] - line_a[0]
|
|
369
|
+
line_b.map! {|o| o - line_a_size}
|
|
370
|
+
Effects.glow :fade_in=>1, :what=>line_b
|
|
371
|
+
|
|
372
|
+
return
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def self.init
|
|
378
|
+
|
|
379
|
+
return if ! $el # Do nothing if not running under el4r
|
|
380
|
+
|
|
381
|
+
# Define lisp function to get list of displayed lines
|
|
382
|
+
# In case something has been done to change them
|
|
383
|
+
$el.el4r_lisp_eval %q`
|
|
384
|
+
(defun xiki-line-number (pos)
|
|
385
|
+
(save-excursion
|
|
386
|
+
(goto-char pos)
|
|
387
|
+
(forward-line 0)
|
|
388
|
+
(1+ (count-lines 1 (point))))
|
|
389
|
+
)
|
|
390
|
+
`
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
def self.enter_docs
|
|
394
|
+
|
|
395
|
+
line = Line.value
|
|
396
|
+
|
|
397
|
+
if line.blank? # If blank line, prompt for menu
|
|
398
|
+
return Launcher.like_menu "docs/", :inline=>1
|
|
399
|
+
|
|
400
|
+
elsif line =~ /^(\w+\.\w+| +([+-] )?\.)/i # If a method, grab docs from source and insert
|
|
401
|
+
orig = Location.new
|
|
402
|
+
|
|
403
|
+
txt = nil
|
|
404
|
+
$el.with(:save_window_excursion) do
|
|
405
|
+
Launcher.as_open
|
|
406
|
+
|
|
407
|
+
# Grab comments
|
|
408
|
+
right = View.cursor
|
|
409
|
+
Move.to_previous_paragraph
|
|
410
|
+
txt = View.txt View.cursor, right
|
|
411
|
+
orig.go
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
if txt =~ /^ *[^ #]/ # Do nothing if it wasn't one big comment
|
|
415
|
+
return View.flash "- No docs found for this method!"
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
txt = txt.gsub /^ *#( )?/, "@\\1"
|
|
419
|
+
Tree.<< txt, :no_slash=>1, :no_search=>1
|
|
420
|
+
return
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
Line.add_slash :txt=>"docs/", :unless_blank=>1
|
|
424
|
+
Launcher.launch
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
Line.init
|
data/lib/links.rb
ADDED
data/lib/location.rb
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Saves and restores locations. A location can include multiple of
|
|
2
|
+
# these: a file, a line number, a column number
|
|
3
|
+
class Location
|
|
4
|
+
|
|
5
|
+
def self.menu
|
|
6
|
+
%`
|
|
7
|
+
- examples/
|
|
8
|
+
| orig = Location.new # Save where we are
|
|
9
|
+
| Line.next 4; View.open '/tmp' # Go Somewhere else
|
|
10
|
+
| orig.go # Go back to where we were
|
|
11
|
+
`
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attr_accessor :line
|
|
15
|
+
attr_accessor :file
|
|
16
|
+
attr_accessor :column
|
|
17
|
+
attr_accessor :buffer
|
|
18
|
+
|
|
19
|
+
@@spots = {}
|
|
20
|
+
|
|
21
|
+
def file_or_buffer
|
|
22
|
+
@file || @buffer
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Save file and location
|
|
26
|
+
def initialize *args
|
|
27
|
+
# Just use file if it's passed
|
|
28
|
+
if args[0] && args[0].class == String
|
|
29
|
+
@file = File.expand_path(args.shift)
|
|
30
|
+
return
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
if args[0] && args[0].class == Hash
|
|
34
|
+
options = args.shift
|
|
35
|
+
if options[:save_scroll_position]
|
|
36
|
+
@scroll_position = ($el.line_number_at_pos $el.point) - ($el.line_number_at_pos $el.window_start)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
@file = $el.buffer_file_name
|
|
41
|
+
@buffer = View.name
|
|
42
|
+
@line = Line.number
|
|
43
|
+
@column = $el.point - $el.point_at_bol
|
|
44
|
+
|
|
45
|
+
# Get buffer if no file
|
|
46
|
+
@buffer = $el.buffer_name unless @file
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Use View.open instead of this, where possible
|
|
51
|
+
# Opens path, in other window if already open.
|
|
52
|
+
# If nothing passed, prompt user. If string assume it's a path.
|
|
53
|
+
# If symbol, assume it's a bookmark.
|
|
54
|
+
def self.go path=nil, options={}
|
|
55
|
+
# If no param passed, get key from user and go to corresponding location
|
|
56
|
+
if path.nil?
|
|
57
|
+
loc = Keys.input(:optional => true)
|
|
58
|
+
loc ||= "0"
|
|
59
|
+
loc = "_#{loc}"
|
|
60
|
+
View.open("$#{loc}")
|
|
61
|
+
# Optionally go to point
|
|
62
|
+
$el.bookmark_jump(loc) unless $el.elvar.current_prefix_arg
|
|
63
|
+
return
|
|
64
|
+
|
|
65
|
+
# If symbol, look up location in map and go to it
|
|
66
|
+
elsif path.class == Symbol
|
|
67
|
+
# @@hash[path.to_s].go
|
|
68
|
+
View.open("$#{path.to_s}")
|
|
69
|
+
$el.bookmark_jump(path.to_s)
|
|
70
|
+
return
|
|
71
|
+
|
|
72
|
+
# If string, look up location in map and go to it
|
|
73
|
+
elsif path.class == String and path[/^\$./]
|
|
74
|
+
View.open(path, :goto_point => true)
|
|
75
|
+
|
|
76
|
+
# Jump to specific boomkark point - redundant??
|
|
77
|
+
# Is this even a bookmark?
|
|
78
|
+
$el.bookmark_jump(path.sub(/^\$/, ""))
|
|
79
|
+
return
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Otherwise, go to path passed in
|
|
83
|
+
self.new(path).go(options)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Goes to location, with whatever information we have. Note that if
|
|
87
|
+
# file is already shown, we just move to its window.
|
|
88
|
+
def go options={}
|
|
89
|
+
if ! options[:assume_file]
|
|
90
|
+
if @file
|
|
91
|
+
View.open(@file, options)
|
|
92
|
+
else
|
|
93
|
+
View.to_buffer(@buffer)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
$el.goto_line @line if @line
|
|
98
|
+
|
|
99
|
+
# Exit if no column is set
|
|
100
|
+
return unless @column
|
|
101
|
+
|
|
102
|
+
# If enough space, just move to column
|
|
103
|
+
if $el.point + @column <= $el.point_at_eol
|
|
104
|
+
$el.forward_char @column
|
|
105
|
+
# Otherwise, move to end
|
|
106
|
+
else
|
|
107
|
+
$el.end_of_line
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
$el.recenter @scroll_position if @scroll_position
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Saves a generic location based on user input
|
|
114
|
+
def self.save name=nil
|
|
115
|
+
# Use string if user types it quickly (or arg, if passed)
|
|
116
|
+
name ||= Keys.input(:prompt => "Save this spot as (pause when done): ", :optional => true)
|
|
117
|
+
name ||= "0"
|
|
118
|
+
#path = path.to_s unless path.class == String
|
|
119
|
+
name = "_#{name}"
|
|
120
|
+
# Remove beginning $ (it might have been passed in with the arg)
|
|
121
|
+
name.sub!(/^\$/, "")
|
|
122
|
+
|
|
123
|
+
# Save location in corresponding register
|
|
124
|
+
# @@hash[name] = Location.new
|
|
125
|
+
$el.bookmark_set(name)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def self.jump path=nil
|
|
129
|
+
path ||= "0"
|
|
130
|
+
path = "_#{path}"
|
|
131
|
+
#path = path.to_s unless path.class == String
|
|
132
|
+
View.open("$#{path}")
|
|
133
|
+
# Optionally go to point
|
|
134
|
+
$el.bookmark_jump(path) #unless $el.elvar.current_prefix_arg
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Enter selected text at spot
|
|
138
|
+
def self.enter_at_spot
|
|
139
|
+
txt = View.selection
|
|
140
|
+
txt = FileTree.snippet if Keys.prefix_u?
|
|
141
|
+
Location.jump("0")
|
|
142
|
+
View.set_mark
|
|
143
|
+
$el.insert txt
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def self.as_spot key='0'
|
|
147
|
+
|
|
148
|
+
# Remember window (in case buffer in 2 windows)
|
|
149
|
+
@@spot_index = View.index if key == '0'
|
|
150
|
+
|
|
151
|
+
if View.file # If buffer has a file, just save in location
|
|
152
|
+
Location.save(key)
|
|
153
|
+
return @@spots[key] = nil
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Must be a buffer
|
|
157
|
+
@@spots[key] = [$el.buffer_name(View.buffer), $el.point]
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def self.to_spot key='0'
|
|
161
|
+
if @@spots[key]
|
|
162
|
+
View.to_buffer @@spots[key][0]
|
|
163
|
+
View.to @@spots[key][1]
|
|
164
|
+
else # If file, just jump
|
|
165
|
+
# If original window/buffer still there, go back
|
|
166
|
+
if key == '0'
|
|
167
|
+
if $el.buffer_file_name($el.window_buffer(View.nth(@@spot_index))) == Bookmarks["$_0"]
|
|
168
|
+
View.to_nth @@spot_index
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
Location.jump(key)
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
end
|