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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Styles.mode_line(
|
|
2
|
+
:bg=>'44aa44',
|
|
3
|
+
:border=>['55aa55', -5, 'released-button'],
|
|
4
|
+
:face=>'Lucida Grande',
|
|
5
|
+
:size=>'3',
|
|
6
|
+
:bold=>false,
|
|
7
|
+
:fg=>'fff'
|
|
8
|
+
)
|
|
9
|
+
Styles.mode_line_inactive(
|
|
10
|
+
:bg=>'bbb',
|
|
11
|
+
:border=>['bbbbbb', -1],
|
|
12
|
+
:face=>'Lucida Grande',
|
|
13
|
+
:bold=>false,
|
|
14
|
+
:fg=>'000'
|
|
15
|
+
)
|
|
16
|
+
Styles.mode_line_dir(
|
|
17
|
+
:fg=>"222222",
|
|
18
|
+
:size=>"0",
|
|
19
|
+
:face=>"arial",
|
|
20
|
+
:bold=>false
|
|
21
|
+
)
|
|
22
|
+
Styles.mode_line_file(
|
|
23
|
+
:fg=>"fff",
|
|
24
|
+
:size=>"0",
|
|
25
|
+
:face=>"arial",
|
|
26
|
+
:bold=>false
|
|
27
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Sample js file this can invoke
|
|
2
|
+
/*
|
|
3
|
+
@/projects/xiki_wrappers/
|
|
4
|
+
- pie.js
|
|
5
|
+
| exports.menu = function () {
|
|
6
|
+
| return "hey/\nyou/\nthere/\n";
|
|
7
|
+
| };
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Gets shelled out to by xiki to delegate call to a .js file.
|
|
11
|
+
// Just gets the args passed in and requires and invokes.
|
|
12
|
+
var file = process.argv[2]
|
|
13
|
+
var path = process.argv[3]
|
|
14
|
+
|
|
15
|
+
var clazz = require(file);
|
|
16
|
+
var output = clazz.menu();
|
|
17
|
+
console.log(output);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Gets shelled out to by xiki to delegate call to a .py file.
|
|
2
|
+
# Just gets the args passed in and requires and invokes.
|
|
3
|
+
import sys, re
|
|
4
|
+
|
|
5
|
+
file = sys.argv[1]
|
|
6
|
+
path = sys.argv[2]
|
|
7
|
+
|
|
8
|
+
clazz = re.sub(".+/", "", file)
|
|
9
|
+
clazz = re.sub("\.py$", "", clazz)
|
|
10
|
+
clazz = clazz.capitalize()
|
|
11
|
+
execfile(file)
|
|
12
|
+
|
|
13
|
+
method = ".menu"
|
|
14
|
+
|
|
15
|
+
import re
|
|
16
|
+
|
|
17
|
+
if re.search("^\.", path):
|
|
18
|
+
method = path.replace(r'/', '')
|
|
19
|
+
|
|
20
|
+
print(eval(clazz+"()"+method+"()"))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Gets shelled out to by xiki to delegate call to a no-dependency .rb file.
|
|
2
|
+
# Just gets the args passed in and requires and invokes.
|
|
3
|
+
|
|
4
|
+
# TODO Don't hard-code path
|
|
5
|
+
require "/projects/xiki/lib/ol.rb"
|
|
6
|
+
|
|
7
|
+
file = ARGV.shift
|
|
8
|
+
path = ARGV.shift
|
|
9
|
+
|
|
10
|
+
load file
|
|
11
|
+
|
|
12
|
+
clazz = file[/\w+/].gsub(/_([a-z]+)/) {"#{$1.capitalize}"}.sub(/(.)/) {$1.upcase}.gsub("_", "")
|
|
13
|
+
clazz = eval clazz
|
|
14
|
+
|
|
15
|
+
method = "menu"
|
|
16
|
+
method = path[/^\.(.+?)\/?$/, 1] if path =~ /^\./
|
|
17
|
+
method = method.to_sym
|
|
18
|
+
|
|
19
|
+
if clazz.respond_to? method
|
|
20
|
+
puts clazz.send method
|
|
21
|
+
else
|
|
22
|
+
cmethods = clazz.methods - Class.methods
|
|
23
|
+
puts cmethods.sort.map{|o| "+ .#{o}/"}
|
|
24
|
+
end
|
|
25
|
+
|
data/lib/block.rb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
class Block
|
|
2
|
+
|
|
3
|
+
# def self.value
|
|
4
|
+
# res = []
|
|
5
|
+
# with(:save_excursion) do
|
|
6
|
+
# found = re_search_backward "^ *$", nil, 1
|
|
7
|
+
# if found
|
|
8
|
+
# end_of_line
|
|
9
|
+
# forward_char
|
|
10
|
+
# end
|
|
11
|
+
# res << point
|
|
12
|
+
# re_search_forward "^ *$", nil, 1
|
|
13
|
+
# beginning_of_line
|
|
14
|
+
# res << point
|
|
15
|
+
# end
|
|
16
|
+
# res
|
|
17
|
+
# end
|
|
18
|
+
|
|
19
|
+
def self.do_as_wrap
|
|
20
|
+
|
|
21
|
+
if Keys.prefix_u?
|
|
22
|
+
# Grab paragraph and remove linebreaks
|
|
23
|
+
|
|
24
|
+
orig = Location.new
|
|
25
|
+
txt = View.paragraph :delete => true, :start_here => true
|
|
26
|
+
txt.gsub! "\n", " "
|
|
27
|
+
txt.sub!(/ $/, "\n")
|
|
28
|
+
View.insert txt
|
|
29
|
+
orig.go
|
|
30
|
+
|
|
31
|
+
Line.to_left
|
|
32
|
+
View.insert "> "
|
|
33
|
+
$el.fill_paragraph nil
|
|
34
|
+
txt = View.paragraph(:delete => true)
|
|
35
|
+
View.insert txt.gsub(/^ /, '> ')
|
|
36
|
+
return
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
$el.fill_paragraph nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.do_as_something
|
|
43
|
+
|
|
44
|
+
prefix = Keys.prefix
|
|
45
|
+
txt, left, right = View.txt_per_prefix prefix
|
|
46
|
+
|
|
47
|
+
result = yield txt
|
|
48
|
+
|
|
49
|
+
# Insert result at end of block
|
|
50
|
+
orig = Location.new
|
|
51
|
+
View.cursor = right
|
|
52
|
+
Line.to_left
|
|
53
|
+
|
|
54
|
+
if prefix.nil?
|
|
55
|
+
View.insert(">>\n"+result.strip+"\n") unless result.blank?
|
|
56
|
+
else
|
|
57
|
+
View.insert(result.strip.gsub(/^/, ' ')+"\n") unless result.blank?
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
orig.go
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.>> txt
|
|
64
|
+
orig = Location.new
|
|
65
|
+
ignore, left, right = View.block_positions "^>"
|
|
66
|
+
View.cursor = right
|
|
67
|
+
|
|
68
|
+
View.insert(">>\n#{txt.strip}\n") unless txt.blank?
|
|
69
|
+
orig.go
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
data/lib/bookmarks.rb
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
require 'location'
|
|
2
|
+
require 'keys'
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
class Bookmarks
|
|
6
|
+
|
|
7
|
+
def self.menu
|
|
8
|
+
%`
|
|
9
|
+
- .list/
|
|
10
|
+
- .tree/
|
|
11
|
+
- .api/
|
|
12
|
+
| > Summary
|
|
13
|
+
| Some of the common ways to use the Bookmarks class programatically.
|
|
14
|
+
|
|
|
15
|
+
| > Get path for a bookmark
|
|
16
|
+
@p Bookmarks["$t"]
|
|
17
|
+
|
|
|
18
|
+
| > Expand bookmark in a path
|
|
19
|
+
@p Bookmarks["$tm/hi.txt"]
|
|
20
|
+
|
|
|
21
|
+
> Where Emacs stores bookmarks
|
|
22
|
+
@ ~/.emacs.bmk
|
|
23
|
+
|
|
|
24
|
+
- .elisp/
|
|
25
|
+
| > Save unsaved bookmarks to ~/.emacs.bmk
|
|
26
|
+
| (bookmark-save)
|
|
27
|
+
|
|
|
28
|
+
| > Delete a bookmark
|
|
29
|
+
| (bookmark-delete "foo")
|
|
30
|
+
- docs/
|
|
31
|
+
> Summary
|
|
32
|
+
| Xiki uses standard emacs bookmarks, while adding several keyboard shortcuts
|
|
33
|
+
| and the ability to bookmark buffers in addition to just files.
|
|
34
|
+
|
|
|
35
|
+
> Keys
|
|
36
|
+
| All of these prompt for a bookmark name:
|
|
37
|
+
|
|
|
38
|
+
| as+bookmark: bookmark the current file
|
|
39
|
+
| open+bookmark: jumps to bookmark file
|
|
40
|
+
| open+point: jumps to bookmark file and cursor position
|
|
41
|
+
|
|
|
42
|
+
> See Also
|
|
43
|
+
@files/docs/
|
|
44
|
+
`
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.save arg=nil
|
|
48
|
+
in_a_file_tree = FileTree.handles? rescue nil
|
|
49
|
+
|
|
50
|
+
# If we're in a file tree, use file in tree (unless C-u over-rides it)
|
|
51
|
+
if ! Keys.prefix_u? && in_a_file_tree && ! Line[/^ *\|/]
|
|
52
|
+
path = Tree.construct_path
|
|
53
|
+
keys = Keys.input(:timed=>true, :prompt=>"Name of bookmark for #{path.sub(/.+\/(.)/, "\\1")}: ") || "0"
|
|
54
|
+
$el.with(:save_window_excursion) do
|
|
55
|
+
$el.find_file path
|
|
56
|
+
self.set keys
|
|
57
|
+
end
|
|
58
|
+
View.flash "- bookmarked as: $#{keys}", :times=>3
|
|
59
|
+
return
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# If arg is a symbol, use it as the prefix
|
|
63
|
+
prefix = ""
|
|
64
|
+
if arg && arg.type == Symbol
|
|
65
|
+
prefix = arg.to_s
|
|
66
|
+
elsif arg && arg.type == String
|
|
67
|
+
self.set(arg.sub(/^\$/, ""))
|
|
68
|
+
return
|
|
69
|
+
end
|
|
70
|
+
# Use input from user or "default"
|
|
71
|
+
keys = Keys.input(:timed=>true, :prompt=>"Name of bookmark for #{View.file_name}: ") || "0"
|
|
72
|
+
self.set "#{prefix}#{keys}"
|
|
73
|
+
|
|
74
|
+
# Append to bookmark file
|
|
75
|
+
log_path = "/temp/bookmark_log.notes"
|
|
76
|
+
if File.exists?(log_path)
|
|
77
|
+
File.open(log_path, "a") { |f| f << "| $#{prefix}#{keys}\n#{View.file}\n\n" }
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.[]= bookmark, path
|
|
82
|
+
$el.with(:save_window_excursion) do
|
|
83
|
+
View.open path
|
|
84
|
+
Bookmarks.set bookmark
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Like bookmark-set, but accepts buffers
|
|
89
|
+
def self.set name
|
|
90
|
+
# Just create normal bookmark if file
|
|
91
|
+
return $el.bookmark_set(name) if View.file || $el.elvar.dired_directory
|
|
92
|
+
|
|
93
|
+
# Must be buffer
|
|
94
|
+
|
|
95
|
+
$el.bookmark_delete name # Delete real bookmark
|
|
96
|
+
|
|
97
|
+
# Load bookmarks.yml
|
|
98
|
+
bookmarks_yml = File.expand_path("~/bookmarks.yml")
|
|
99
|
+
if File.exists?(bookmarks_yml)
|
|
100
|
+
bookmarks = YAML::load IO.read(bookmarks_yml)
|
|
101
|
+
end
|
|
102
|
+
bookmarks = [] unless bookmarks
|
|
103
|
+
|
|
104
|
+
# Delete if there
|
|
105
|
+
already_here = bookmarks.find {|bm| bm[0] == name}
|
|
106
|
+
bookmarks.delete(already_here) if already_here
|
|
107
|
+
|
|
108
|
+
# Add to end
|
|
109
|
+
bookmarks << [name, View.name]
|
|
110
|
+
|
|
111
|
+
# Save file
|
|
112
|
+
File.open(bookmarks_yml, "w") { |f| f << bookmarks.to_yaml }
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Like bookmark-jump, but accepts buffers
|
|
117
|
+
def self.jump name
|
|
118
|
+
|
|
119
|
+
# If normal bookmark found, use it
|
|
120
|
+
return $el.bookmark_jump(name) if $el.bookmark_get_filename(name)
|
|
121
|
+
|
|
122
|
+
buffer = self.buffer_bookmark name
|
|
123
|
+
|
|
124
|
+
if buffer == :buffer_not_open
|
|
125
|
+
return $el.message "Buffer '#{buffer}' not currently open."
|
|
126
|
+
end
|
|
127
|
+
return nil if buffer.nil?
|
|
128
|
+
|
|
129
|
+
View.to_buffer buffer
|
|
130
|
+
return true
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def self.buffer_bookmark name
|
|
134
|
+
# Load bookmarks.yml
|
|
135
|
+
bookmarks_yml = File.expand_path("~/bookmarks.yml")
|
|
136
|
+
return nil unless File.exists?(bookmarks_yml)
|
|
137
|
+
bookmarks = YAML::load IO.read(bookmarks_yml)
|
|
138
|
+
bookmarks = [] unless bookmarks
|
|
139
|
+
|
|
140
|
+
# Get buffer name
|
|
141
|
+
found = bookmarks.find {|bm| bm[0] == name}
|
|
142
|
+
return nil unless found
|
|
143
|
+
|
|
144
|
+
unless View.buffer_open?(found[1])
|
|
145
|
+
return :buffer_not_open
|
|
146
|
+
end
|
|
147
|
+
# Do nothing if already open
|
|
148
|
+
|
|
149
|
+
found[1]
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# If string passed, go to file+point of bookmark.
|
|
155
|
+
# If nothing passed, go to file of user-prompted text
|
|
156
|
+
# If no args passed, get bookmark from user and jump there
|
|
157
|
+
def self.go bookmark=nil, options={}
|
|
158
|
+
#el4r_lisp_eval "(require 'bookmark)(bookmark-maybe-load-default-file)"
|
|
159
|
+
# If arg is a symbol, use it as the prefix
|
|
160
|
+
prefix_to_bm = ""
|
|
161
|
+
if bookmark && bookmark.type == Symbol
|
|
162
|
+
prefix_to_bm = bookmark.to_s
|
|
163
|
+
elsif bookmark && bookmark.type == String
|
|
164
|
+
keys = bookmark
|
|
165
|
+
# return self.jump(bookmark.sub(/^\$/, ""))
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Use input from user or "default"
|
|
169
|
+
keys ||= Keys.input(:timed => true, :prompt => "Enter bookmark to jump to: ") || "0"
|
|
170
|
+
|
|
171
|
+
# Open file or jump to if already open
|
|
172
|
+
path = $el.bookmark_get_filename( "#{prefix_to_bm}#{keys}" )
|
|
173
|
+
|
|
174
|
+
if path.nil? # If not found, try buffer in bookmarks.yml
|
|
175
|
+
|
|
176
|
+
return true if self.jump( "#{prefix_to_bm}#{keys}" )
|
|
177
|
+
View.beep
|
|
178
|
+
$el.message("Bookmark not found!")
|
|
179
|
+
return :not_found
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
prefix = Keys.prefix
|
|
183
|
+
if prefix==9 # If 9, open in bar
|
|
184
|
+
View.bar
|
|
185
|
+
self.jump "#{prefix_to_bm}#{keys}"
|
|
186
|
+
else
|
|
187
|
+
Location.go path, :stay_in_bar => true
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
if options[:point] or prefix == :u # Go to actual point
|
|
191
|
+
return self.jump("#{prefix_to_bm}#{keys}")
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def self.keys
|
|
196
|
+
# TODO: put newest keys here
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Expand $foo paths in strings. Expects strings to bee bookmark names,
|
|
200
|
+
# and replaces with corresponding paths.
|
|
201
|
+
def self.[] path
|
|
202
|
+
self.expand(path)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def self.expand path, options={}
|
|
206
|
+
if options[:just_bookmark] # If only a bookmark, just expand it
|
|
207
|
+
return $el.bookmark_get_filename(path)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# If $xxx found
|
|
211
|
+
if path =~ /^\$([._a-zA-Z0-9-]+)([\\\/]?)(.*)/
|
|
212
|
+
bm, slash, rest = $1, $2, $3
|
|
213
|
+
|
|
214
|
+
bm_orig = bm
|
|
215
|
+
# Expand bookmark
|
|
216
|
+
if ["x", "xiki"].member? bm
|
|
217
|
+
bm = Xiki.dir
|
|
218
|
+
else
|
|
219
|
+
bm = $el.bookmark_get_filename(bm)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
if bm.nil?
|
|
223
|
+
bm =
|
|
224
|
+
if bm_orig == "t"
|
|
225
|
+
"#{File.expand_path("~")}/todo.notes"
|
|
226
|
+
elsif bm_orig == "f"
|
|
227
|
+
"#{File.expand_path("~")}/files.notes"
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
return path if bm.nil?
|
|
231
|
+
|
|
232
|
+
# If a slash, cut off filename if there is one (only dir is wanted)
|
|
233
|
+
if options[:file_ok] # Put slash back if there was one
|
|
234
|
+
bm << "/" if bm !~ /\/$/ && slash.any?
|
|
235
|
+
elsif slash.any?
|
|
236
|
+
bm.sub! /[^\\\/]+$/, ""
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
path = "#{bm}#{rest}"
|
|
240
|
+
|
|
241
|
+
# Expand ~/ if it has it
|
|
242
|
+
|
|
243
|
+
path = View.expand_path(path) if path =~ /^~/
|
|
244
|
+
|
|
245
|
+
path
|
|
246
|
+
|
|
247
|
+
elsif path =~ /^~\// # If home dir, expand
|
|
248
|
+
# Expand ~/ if it has it
|
|
249
|
+
View.expand_path(path)
|
|
250
|
+
|
|
251
|
+
elsif options[:absolute] || path =~ /^\.+(\/|$)/ # If relative path, expand
|
|
252
|
+
View.expand_path(path)
|
|
253
|
+
else
|
|
254
|
+
path
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Insert $bookmark into to path if it contains a bookmarked path
|
|
259
|
+
def self.collapse path
|
|
260
|
+
if ! @bookmarks_cache
|
|
261
|
+
@bookmarks_cache = []
|
|
262
|
+
# TODO: pull this list out and make configurable
|
|
263
|
+
%w[a tr p n x 18].each do |name|
|
|
264
|
+
|
|
265
|
+
bmpath = $el.bookmark_get_filename(name)
|
|
266
|
+
next unless bmpath
|
|
267
|
+
bmpath.sub!(/[^\/]+$/, "")
|
|
268
|
+
|
|
269
|
+
@bookmarks_cache << [name, bmpath]
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
@bookmarks_cache.each do |name, bmpath|
|
|
274
|
+
next unless path =~ /^#{bmpath}/
|
|
275
|
+
return path.sub(bmpath, "$#{name}/")
|
|
276
|
+
end
|
|
277
|
+
return path
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# Remove file from the end (if not dir)
|
|
281
|
+
def self.dir_only path
|
|
282
|
+
path.sub(/\/[^\/]+\.[^\/]+$/, '')
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# Prompt user for bookmark name, and return bookmark
|
|
286
|
+
def self.input options={}
|
|
287
|
+
self.expand(
|
|
288
|
+
Keys.input(options.merge(:timed => true)),
|
|
289
|
+
:just_bookmark => true
|
|
290
|
+
)
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# Read a file
|
|
294
|
+
def self.read name
|
|
295
|
+
File.read(self.expand(name))
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def self.list path=nil
|
|
299
|
+
|
|
300
|
+
result = ""
|
|
301
|
+
if ! path # Print all bookmarks
|
|
302
|
+
all = $el.elvar.bookmark_alist.collect { |bm|
|
|
303
|
+
item = bm.to_a
|
|
304
|
+
[item[0], item[1].to_a[0][1]]
|
|
305
|
+
}
|
|
306
|
+
all.each do |l|
|
|
307
|
+
n, p = l
|
|
308
|
+
result << "- #{n}) @#{p.sub(/\/$/,'')}\n"
|
|
309
|
+
# puts "- #{n.ljust(7)} #{p.sub(/\/$/,'')}"
|
|
310
|
+
#puts "- #{n}: #{p}"
|
|
311
|
+
end
|
|
312
|
+
return result
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# Open single path
|
|
316
|
+
View.open path[/ ([~\/].+)/, 1]
|
|
317
|
+
nil
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def self.tree
|
|
321
|
+
# paths = elvar.bookmark_alist.collect {|bm|
|
|
322
|
+
# bm.to_a[1].to_a[0][1]
|
|
323
|
+
# }.select{|path| path =~ /^\/.+\w$/}
|
|
324
|
+
|
|
325
|
+
paths = $el.elvar.bookmark_alist.collect {|bm|
|
|
326
|
+
ary = bm.to_a
|
|
327
|
+
key = ary[0]
|
|
328
|
+
path = ary[1].to_a[0][1]
|
|
329
|
+
[key, path]
|
|
330
|
+
}
|
|
331
|
+
paths = paths.select{|a| a[1] =~ /^\/.+\w$/} # Remove bm's to dirs
|
|
332
|
+
paths.collect! {|bm|
|
|
333
|
+
path = bm[1]
|
|
334
|
+
path.sub! /(.+\/)/, "\\1#{bm[0]}: "
|
|
335
|
+
path
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
Tree.paths_to_tree(paths)
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
def self.open_quick
|
|
342
|
+
bookmark = Keys.input :timed=>1, :prompt=>"Enter a quick bookmark to jump to:"
|
|
343
|
+
Bookmarks.go("q#{bookmark}")
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
if $el
|
|
349
|
+
$el.el4r_lisp_eval("(require 'bookmark)")
|
|
350
|
+
$el.bookmark_maybe_load_default_file
|
|
351
|
+
end
|
|
352
|
+
|