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/window.rb
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
class Window
|
|
2
|
+
|
|
3
|
+
def self.menu
|
|
4
|
+
"
|
|
5
|
+
- .dimensions/
|
|
6
|
+
- presets/
|
|
7
|
+
- @dimensions config/
|
|
8
|
+
- .adjust/
|
|
9
|
+
- position/
|
|
10
|
+
- up/
|
|
11
|
+
- down/
|
|
12
|
+
- left/
|
|
13
|
+
- right/
|
|
14
|
+
- size/
|
|
15
|
+
- wider/
|
|
16
|
+
- narrower/
|
|
17
|
+
- taller/
|
|
18
|
+
- shorter/
|
|
19
|
+
- current/
|
|
20
|
+
- .visibility/
|
|
21
|
+
- full/
|
|
22
|
+
- high/
|
|
23
|
+
- medium/
|
|
24
|
+
- low/
|
|
25
|
+
- .colorized/
|
|
26
|
+
- .scroll bars/
|
|
27
|
+
- .scroll bars/
|
|
28
|
+
"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Show dimension options, and invoke corresponding proc
|
|
32
|
+
def self.dimensions action=nil, preset=nil
|
|
33
|
+
|
|
34
|
+
if action == "current"
|
|
35
|
+
# width, height, left, top
|
|
36
|
+
return "#{View.frame_width}, #{View.frame_height}, #{$el.frame_parameter(nil, :left)}, #{$el.frame_parameter(nil, :top)}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
txt = File.read(File.expand_path("#{Xiki.dir}menus/dimensions_config.menu"))
|
|
40
|
+
|
|
41
|
+
txt.sub! /\n\n.+/m, "\n"
|
|
42
|
+
|
|
43
|
+
txt = txt.split("\n")
|
|
44
|
+
|
|
45
|
+
# Any after blank line will be ignored
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# If just presets/, list all presets
|
|
49
|
+
|
|
50
|
+
if ! preset
|
|
51
|
+
return txt.map { |o|
|
|
52
|
+
o = o.match(/(\w.+?)\/(.+)/)
|
|
53
|
+
next if ! o
|
|
54
|
+
"#{o[1]}--#{o[2]}"
|
|
55
|
+
"- #{o[1]}/\n"
|
|
56
|
+
}.join("")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# If preset passed, apply it
|
|
60
|
+
|
|
61
|
+
View.kill if View.name == "@window/dimensions/presets/"
|
|
62
|
+
txt = txt.find { |o| o =~ /^[ +-]*#{preset}\// }
|
|
63
|
+
|
|
64
|
+
txt = txt[/\/(.+)/, 1]
|
|
65
|
+
self.dimensions_set txt
|
|
66
|
+
|
|
67
|
+
nil
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.dimensions_set txt
|
|
72
|
+
|
|
73
|
+
# If just numbers and commas
|
|
74
|
+
if txt =~ /^[0-9, ]+$/
|
|
75
|
+
txt = txt.split(/, */).map{|o| o.to_i}
|
|
76
|
+
View.dimensions_set *txt
|
|
77
|
+
return
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Otherwise, it's code so just eval
|
|
81
|
+
|
|
82
|
+
eval txt
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def self.adjust type, direction
|
|
86
|
+
|
|
87
|
+
if type == "size"
|
|
88
|
+
case direction
|
|
89
|
+
when "wider"; View.frame_width += 1
|
|
90
|
+
when "narrower"; View.frame_width -= 1
|
|
91
|
+
when "taller"; View.frame_height += 1
|
|
92
|
+
when "shorter"; View.frame_height -= 1
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
elsif type == "wider"
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
nil
|
|
100
|
+
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def self.visibility choice=nil
|
|
105
|
+
choices = {
|
|
106
|
+
'full'=>"(100 85)",
|
|
107
|
+
'high'=>"(85 70)",
|
|
108
|
+
'medium'=>"(70 55)",
|
|
109
|
+
'low'=>"(40 30)",
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
numbers = choices[choice]
|
|
113
|
+
raise ".flash - '#{choice}' isn't a valid choice for View.visibility!" if numbers.nil?
|
|
114
|
+
|
|
115
|
+
$el.el4r_lisp_eval "(set-frame-parameter nil 'alpha '#{numbers})" # full visibility
|
|
116
|
+
View.kill if View.name == "@window/visibility/"
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def self.colorized
|
|
120
|
+
View.kill if View.file.nil?
|
|
121
|
+
Styles.toggle
|
|
122
|
+
nil
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def self.scroll_bars
|
|
126
|
+
result = $el.scroll_bar_mode
|
|
127
|
+
View.frame_width += View.scroll_bars ? -3 : 3
|
|
128
|
+
# View.scroll_bars = false
|
|
129
|
+
View.kill if View.name == "@window/visibility/"
|
|
130
|
+
nil
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end
|
data/lib/xiki.rb
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
XIKI_ROOT = File.expand_path "#{File.dirname(__FILE__)}/.."
|
|
2
|
+
Dir.chdir(XIKI_ROOT)
|
|
3
|
+
|
|
4
|
+
# Used by a lot of classes
|
|
5
|
+
class Xiki
|
|
6
|
+
@@dir = "#{Dir.pwd}/" # Store current dir when xiki first launches
|
|
7
|
+
|
|
8
|
+
# TODO Just use XIKI_ROOT from above?
|
|
9
|
+
|
|
10
|
+
def self.dir
|
|
11
|
+
@@dir
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
$el.el4r_lisp_eval '(ignore-errors (kill-buffer "Issues Loading Xiki"))' if $el
|
|
17
|
+
|
|
18
|
+
# Require some of the core files
|
|
19
|
+
require 'trouble_shooting'
|
|
20
|
+
require 'rubygems'
|
|
21
|
+
require 'ol'
|
|
22
|
+
require 'requirer'
|
|
23
|
+
require 'text_util'
|
|
24
|
+
Requirer.require_classes ['notes']
|
|
25
|
+
require 'launcher'
|
|
26
|
+
require 'mode'
|
|
27
|
+
require 'menu'
|
|
28
|
+
|
|
29
|
+
# Launcher.add_class_launchers classes
|
|
30
|
+
class Xiki
|
|
31
|
+
def self.menu
|
|
32
|
+
%`
|
|
33
|
+
- .tests/
|
|
34
|
+
- .github/
|
|
35
|
+
- commits/
|
|
36
|
+
- files/
|
|
37
|
+
- .setup/
|
|
38
|
+
- install command/
|
|
39
|
+
| Double-click on these lines to add the executable 'xiki' command to
|
|
40
|
+
| your path:
|
|
41
|
+
|
|
|
42
|
+
@$ cp _____/xiki_wrapper /usr/local/bin/xiki
|
|
43
|
+
@$ chmod 755 /usr/local/bin/xiki
|
|
44
|
+
|
|
|
45
|
+
| Then you can type 'xiki' on a command line outside of emacs as a
|
|
46
|
+
| shortcut to opening xiki and opening menus, like so:
|
|
47
|
+
|
|
|
48
|
+
| $ xiki computer
|
|
49
|
+
|
|
|
50
|
+
- .install icon/
|
|
51
|
+
| Double-click on this line to make .xiki files have the xiki 'shark'
|
|
52
|
+
| icon:
|
|
53
|
+
|
|
|
54
|
+
- install/
|
|
55
|
+
|
|
|
56
|
+
| When you right-click on a .xiki file and select "Open With" and
|
|
57
|
+
| choose emacs, the files will be assigned the xiki shark icon.
|
|
58
|
+
|
|
|
59
|
+
- install global shortcut/
|
|
60
|
+
- 1) With cursor on the following, type open+in+os, then click "Install"
|
|
61
|
+
@ #{Xiki.dir}etc/services/Xiki Menu.workflow
|
|
62
|
+
|
|
63
|
+
- 2) In Mac OS, open
|
|
64
|
+
| System Preferences > Keyboard > Keyboard Shortcuts > Services
|
|
65
|
+
|
|
66
|
+
- 3) Scroll down to the bottom and give "Xiki Menu" the shortcut
|
|
67
|
+
| Command+Control+X
|
|
68
|
+
|
|
69
|
+
- 4) Try it out by typing Command+Control+X from any application
|
|
70
|
+
| It should prompt you to type a xiki menu
|
|
71
|
+
- .process/
|
|
72
|
+
- status/
|
|
73
|
+
- start/
|
|
74
|
+
- stop/
|
|
75
|
+
- restart/
|
|
76
|
+
- api/
|
|
77
|
+
> Summary
|
|
78
|
+
Here are some functions that will always be available to menu classes,
|
|
79
|
+
even external ones.
|
|
80
|
+
|
|
|
81
|
+
| Put pipes at beginning of lines (except bullets etc)
|
|
82
|
+
| p Xiki.quote "hey\\nyou"
|
|
83
|
+
|
|
|
84
|
+
| Return path to tree's root including current line, will be a list with 1
|
|
85
|
+
| path unless nested.
|
|
86
|
+
| p Xiki.trunk
|
|
87
|
+
|
|
|
88
|
+
Here are some functions that will always be available toxxxxxxxxxxxxxxxxxx
|
|
89
|
+
`
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.install_icon arg
|
|
94
|
+
|
|
95
|
+
emacs_dir = "/Applications/Emacs.app"
|
|
96
|
+
|
|
97
|
+
return "- Couldn't find #{emacs_dir}!" if ! File.exists?("#{emacs_dir}")
|
|
98
|
+
|
|
99
|
+
plist_path = "#{emacs_dir}/Contents/Info.plist"
|
|
100
|
+
|
|
101
|
+
plist = File.read "#{emacs_dir}/Contents/Info.plist"
|
|
102
|
+
|
|
103
|
+
# TODO
|
|
104
|
+
# "Back up plist file - where - xiki root?!
|
|
105
|
+
# "Tell them where it was backed up!
|
|
106
|
+
# "Show diffs of change that was made!
|
|
107
|
+
|
|
108
|
+
return "- This file wasn't in the format we expected: #{plist_path}" if plist !~ %r"^\t<key>CFBundleDocumentTypes</key>\n\t<array>\n"
|
|
109
|
+
|
|
110
|
+
# TODO
|
|
111
|
+
# .plist
|
|
112
|
+
# if change was already made, say so
|
|
113
|
+
|
|
114
|
+
# TODO
|
|
115
|
+
# icon
|
|
116
|
+
# copy over
|
|
117
|
+
# cp "#{Xiki.dir}etc/shark.icns"
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
"- finish implementing!"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def self.insert_menu
|
|
124
|
+
line = Line.value
|
|
125
|
+
indent = Line.indent line
|
|
126
|
+
blank = Line.blank?
|
|
127
|
+
|
|
128
|
+
prefix = Keys.prefix
|
|
129
|
+
|
|
130
|
+
# If line not blank, usually indent after
|
|
131
|
+
|
|
132
|
+
Line.<<("\n#{indent} @") if ! blank
|
|
133
|
+
|
|
134
|
+
# If at end of line, and line not blank, go to next line
|
|
135
|
+
|
|
136
|
+
# Todo: if dash+, do auto-complete even if exact match - how to implement?
|
|
137
|
+
|
|
138
|
+
input = Keys.input(:timed=>true, :prompt=>"Start typing a menu that might exist (or type 'all'): ")
|
|
139
|
+
|
|
140
|
+
View << input
|
|
141
|
+
|
|
142
|
+
Launcher.launch
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def self.open_menu
|
|
146
|
+
|
|
147
|
+
return Launcher.open("- last/") if Keys.prefix_u
|
|
148
|
+
|
|
149
|
+
input = Keys.input(:timed=>true, :prompt=>"Start typing a menu that might exist (or type 'all'): ")
|
|
150
|
+
View.to_buffer "menu"
|
|
151
|
+
Notes.mode
|
|
152
|
+
View.kill_all
|
|
153
|
+
View << "#{input}\n"
|
|
154
|
+
View.to_highest
|
|
155
|
+
Launcher.launch
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def self.menus
|
|
159
|
+
CodeTree.menu
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def self.github page
|
|
163
|
+
Firefox.url case page
|
|
164
|
+
when 'files'; "http://github.com/trogdoro/xiki"
|
|
165
|
+
when 'commits'; "https://github.com/trogdoro/xiki/commits/master"
|
|
166
|
+
end
|
|
167
|
+
".flash - Opened in browser!"
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def self.dont_search
|
|
171
|
+
$xiki_no_search = true
|
|
172
|
+
nil
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def self.quote_spec txt
|
|
176
|
+
txt.
|
|
177
|
+
gsub(/^/, '| ').
|
|
178
|
+
gsub(/ +$/, '').
|
|
179
|
+
gsub(/^\|( )([+-])/) {|o| "|#{$2 == '-' ? '+' : '-'}#{$1}"} # Make "expected" be green
|
|
180
|
+
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def self.tests clazz=nil, describe=nil, test=nil, quote=nil
|
|
184
|
+
|
|
185
|
+
prefix = Keys.prefix :clear=>1
|
|
186
|
+
|
|
187
|
+
return if self.nav_to_line # If on line to navigate to, just navigate
|
|
188
|
+
|
|
189
|
+
# If no class, list all classes
|
|
190
|
+
|
|
191
|
+
if clazz.nil?
|
|
192
|
+
return ["all/"] + Dir["#{Xiki.dir}/spec/*_spec.rb"].entries.map{|o| "#{o[/.+\/(.+)_spec\.rb/, 1]}/"}
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# If /class, list describes
|
|
196
|
+
|
|
197
|
+
path = Bookmarks["$x/spec/#{clazz}_spec.rb"]
|
|
198
|
+
|
|
199
|
+
sync_options = prefix == :u ? {} : {:sync=>1}
|
|
200
|
+
|
|
201
|
+
if describe.nil?
|
|
202
|
+
return View.open path if prefix == "open"
|
|
203
|
+
|
|
204
|
+
if clazz == "all" # Run all specs
|
|
205
|
+
return self.quote_spec( #prefix == :u ?
|
|
206
|
+
Console.run("rspec spec", sync_options.merge(:dir=>Xiki.dir))
|
|
207
|
+
)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
txt = File.read path
|
|
211
|
+
return "- all/\n" + txt.scan(/^ *describe .*"(.+)"/).map{|o|
|
|
212
|
+
"- #{o}/"
|
|
213
|
+
}.join("\n")
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# If /class/describe, list tests
|
|
217
|
+
|
|
218
|
+
if test.nil?
|
|
219
|
+
|
|
220
|
+
return self.nav_to path, describe if prefix == "open"
|
|
221
|
+
|
|
222
|
+
if describe == "all" # Run whole test
|
|
223
|
+
return self.quote_spec(
|
|
224
|
+
Console.run("rspec spec/#{clazz}_spec.rb", sync_options.merge(:dir=>Xiki.dir))
|
|
225
|
+
)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
txt = File.read path
|
|
229
|
+
|
|
230
|
+
is_match = false
|
|
231
|
+
return "- all/\n" + txt.scan(/^ *(describe|it) .*"(.+)"/).map{|o|
|
|
232
|
+
next is_match = o[1] == describe if o[0] == "describe" # If describe, set whether it's a match
|
|
233
|
+
next if ! is_match
|
|
234
|
+
"- #{o[1]}/"
|
|
235
|
+
}.select{|o| o.is_a? String}.join("\n")
|
|
236
|
+
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# If /class/describe/test, run test
|
|
240
|
+
|
|
241
|
+
if ! quote
|
|
242
|
+
if test == "all" # Run all for describe
|
|
243
|
+
return self.quote_spec(
|
|
244
|
+
Console.run("rspec spec/#{clazz}_spec.rb -e \"#{describe}\"", sync_options.merge(:dir=>Xiki.dir))
|
|
245
|
+
# Console.run("rspec spec", sync_options.merge(:dir=>Xiki.dir))
|
|
246
|
+
)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# If U prefix, just jump to file
|
|
250
|
+
if prefix == "open"
|
|
251
|
+
return self.nav_to path, describe, test if prefix == "open"
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
# Run it
|
|
256
|
+
command = "rspec spec/#{clazz}_spec.rb -e \"#{describe} #{test}\""
|
|
257
|
+
result = Console.run command, :dir=>"$x", :sync=>true
|
|
258
|
+
|
|
259
|
+
if result =~ /^All examples were filtered out$/
|
|
260
|
+
TextUtil.title_case! clazz
|
|
261
|
+
describe.sub! /^#/, ''
|
|
262
|
+
|
|
263
|
+
return %`
|
|
264
|
+
> Test doesn't appear to exist. Create it?
|
|
265
|
+
| Copy this text into the file:
|
|
266
|
+
|
|
267
|
+
@#{path}
|
|
268
|
+
| describe #{clazz}, "##{describe}" do
|
|
269
|
+
| it "#{test}" do
|
|
270
|
+
| #{clazz}.#{describe}.should == "hi"
|
|
271
|
+
| end
|
|
272
|
+
| end
|
|
273
|
+
`
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
return self.quote_spec result
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# Quoted line, so jump to line number
|
|
280
|
+
|
|
281
|
+
nil
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def self.nav_to_line
|
|
285
|
+
match = Line.value.match(/([\/\w.]+)?:(\d+)/)
|
|
286
|
+
return if ! match
|
|
287
|
+
|
|
288
|
+
file, line = match[1..2]
|
|
289
|
+
file.sub! /^\.\//, Bookmarks["$x"]
|
|
290
|
+
View.open file
|
|
291
|
+
View.to_line line.to_i
|
|
292
|
+
|
|
293
|
+
return true # Did navigate
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def self.nav_to path, *searches
|
|
297
|
+
View.open path
|
|
298
|
+
View.to_highest
|
|
299
|
+
searches.each { |s| Search.forward "[\"']#{$el.regexp_quote s}[\"']" }
|
|
300
|
+
Move.to_axis
|
|
301
|
+
Color.colorize :l
|
|
302
|
+
nil
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def self.trunk options={}
|
|
306
|
+
self.path options
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
def self.path options={}
|
|
310
|
+
Tree.path options
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
def self.quote txt
|
|
314
|
+
Tree.quote txt
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
# Other .init mode defined below
|
|
318
|
+
def self.on_open
|
|
319
|
+
orig = View.name
|
|
320
|
+
name = orig[/(.+?)\./, 1]
|
|
321
|
+
|
|
322
|
+
file = View.file
|
|
323
|
+
|
|
324
|
+
# Figure out whether menu or class
|
|
325
|
+
txt = File.read file
|
|
326
|
+
kind = txt =~ /^class / ? "class" : "menu"
|
|
327
|
+
require_menu file, :force_as=>kind
|
|
328
|
+
|
|
329
|
+
View.kill
|
|
330
|
+
|
|
331
|
+
Buffers.delete name if View.buffer_open? name
|
|
332
|
+
|
|
333
|
+
View.to_buffer name
|
|
334
|
+
Notes.mode
|
|
335
|
+
|
|
336
|
+
View.dir = "/tmp/"
|
|
337
|
+
|
|
338
|
+
View.<< "- #{name}/\n", :dont_move=>1
|
|
339
|
+
Launcher.launch
|
|
340
|
+
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def self.init
|
|
344
|
+
# Get rest of files to require
|
|
345
|
+
|
|
346
|
+
classes = Dir["lib/*.rb"]
|
|
347
|
+
Ol << "classes: #{classes.inspect}"
|
|
348
|
+
classes = classes.select{|i|
|
|
349
|
+
i !~ /xiki.rb$/ && # Remove self
|
|
350
|
+
i !~ /key_bindings.rb$/ && # Remove key_bindings
|
|
351
|
+
i !~ /__/ # Remove __....rb files
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
# classes = Dir["**/*.rb"]
|
|
355
|
+
# classes = classes.select{|i|
|
|
356
|
+
# i !~ /xiki.rb$/ && # Remove self
|
|
357
|
+
# i !~ /key_bindings.rb$/ && # Remove key_bindings
|
|
358
|
+
# i !~ /\// && # Remove all files in dirs
|
|
359
|
+
# i !~ /tests\// && # Remove tests
|
|
360
|
+
# i !~ /__/ # Remove __....rb files
|
|
361
|
+
# }
|
|
362
|
+
|
|
363
|
+
classes.map!{|i| i.sub(/\.rb$/, '')}.sort!
|
|
364
|
+
|
|
365
|
+
Ol << "classes: #{classes.inspect}"
|
|
366
|
+
|
|
367
|
+
# Require classes
|
|
368
|
+
Requirer.require_classes classes
|
|
369
|
+
|
|
370
|
+
# key_bindings has many dependencies, require it last
|
|
371
|
+
Requirer.require_classes ['lib/key_bindings.rb']
|
|
372
|
+
|
|
373
|
+
Launcher.add_class_launchers classes.map{|o| o[/\/(.+)/, 1]}
|
|
374
|
+
Launcher.reload_menu_dirs
|
|
375
|
+
|
|
376
|
+
Launcher.add "xiki"
|
|
377
|
+
|
|
378
|
+
# Pull out into .define_mode
|
|
379
|
+
|
|
380
|
+
Mode.define(:xiki, ".xiki") do
|
|
381
|
+
Xiki.on_open
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
def self.process action
|
|
386
|
+
|
|
387
|
+
case action
|
|
388
|
+
when "status"
|
|
389
|
+
"- #{`xiki status`}"
|
|
390
|
+
when "stop"
|
|
391
|
+
response = `xiki stop`
|
|
392
|
+
response = "apparently it wasn't running" if response.blank?
|
|
393
|
+
response.gsub /^/, '- '
|
|
394
|
+
when "restart"
|
|
395
|
+
response = `xiki restart`
|
|
396
|
+
response = "apparently it wasn't running" if response.blank?
|
|
397
|
+
response.gsub /^/, '- '
|
|
398
|
+
when "start"
|
|
399
|
+
result = `xiki`
|
|
400
|
+
"- started!"
|
|
401
|
+
end
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
end
|