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/search_term.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Remember something you're searching for, and jump to the next occurrences.
|
|
2
|
+
CODE_SAMPLES = %q<
|
|
3
|
+
- Deprecated:
|
|
4
|
+
>
|
|
5
|
+
|
|
6
|
+
class SearchTerm
|
|
7
|
+
|
|
8
|
+
@@last_dash_search = ""
|
|
9
|
+
def self.keys
|
|
10
|
+
$el.define_key :isearch_mode_map, $el.kbd("C--") do # During isearch, remember current search term
|
|
11
|
+
$el.isearch_done
|
|
12
|
+
$el.isearch_clean_overlays
|
|
13
|
+
match = $el.buffer_substring $el.match_beginning(0), $el.match_end(0)
|
|
14
|
+
@@last_dash_search = match
|
|
15
|
+
end
|
|
16
|
+
Keys.set("C--") do
|
|
17
|
+
started = $el.point
|
|
18
|
+
chars = @@last_dash_search.size
|
|
19
|
+
# Go to it
|
|
20
|
+
$el.search_forward @@last_dash_search
|
|
21
|
+
# Go forward again if you were already at it
|
|
22
|
+
$el.search_forward @@last_dash_search if started == $el.point - chars
|
|
23
|
+
# Back up to beginning
|
|
24
|
+
$el.backward_char chars
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
# Does an isearch on the characters typed, until the user pauses more than .4 seconds
|
|
28
|
+
def self.timed_search
|
|
29
|
+
|
|
30
|
+
# isearch_forward
|
|
31
|
+
c = $el.read_char "search: "
|
|
32
|
+
# keys = self.to_letter(keys)
|
|
33
|
+
$el.call_interactively $el.key_binding(c)
|
|
34
|
+
while(c = $el.read_char("Input: ", nil, 0.40))
|
|
35
|
+
$el.call_interactively $el.key_binding(c)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
# Test stuff to search for, and stuff
|
data/lib/snippet.rb
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
class Snippet
|
|
2
|
+
def self.menu *args
|
|
3
|
+
|
|
4
|
+
if args[0] == "docs"
|
|
5
|
+
return Tree.children self.docs, args[1..-1]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
extension = View.extension
|
|
9
|
+
file = "#{Xiki.dir}etc/snippets/#{extension}.notes"
|
|
10
|
+
|
|
11
|
+
prefix = Keys.prefix
|
|
12
|
+
|
|
13
|
+
return View.open file if prefix == 'open' || prefix == :u # If up+, just go to file
|
|
14
|
+
|
|
15
|
+
# If leaf has quote, kill the rest or create new snippet
|
|
16
|
+
|
|
17
|
+
if args[-1] =~ /\|/
|
|
18
|
+
txt = ENV['txt'].dup
|
|
19
|
+
|
|
20
|
+
txt << "\n" if txt !~ /\n/
|
|
21
|
+
|
|
22
|
+
#Tree.to_parent :u
|
|
23
|
+
Tree.to_root
|
|
24
|
+
CodeTree.kill_rest
|
|
25
|
+
indent = Line.indent
|
|
26
|
+
Line.delete
|
|
27
|
+
View.<< txt.gsub(/^/, indent), :dont_move=>1
|
|
28
|
+
|
|
29
|
+
return
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Get snippets.foo file from snippets/ dirs, and drill into it
|
|
33
|
+
|
|
34
|
+
# TODO: also look in ~/xiki/snippets? - find different dir name, in case ~/xiki is the Xiki.dir
|
|
35
|
+
|
|
36
|
+
if ! File.exists? file
|
|
37
|
+
# TODO: if none found, show
|
|
38
|
+
return "
|
|
39
|
+
| No snippets were found for the file extension '#{extension}'.
|
|
40
|
+
| You can create some by making a tree in this file:
|
|
41
|
+
@ #{file}
|
|
42
|
+
"
|
|
43
|
+
# TODO: maybe let them type directly into the @snippet menu and do C-. to save
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
txt = File.read file
|
|
47
|
+
Tree.children txt, args
|
|
48
|
+
|
|
49
|
+
# TODO: if line has quote and path doesn't exist in file (.drill fails), create new snippet
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.insert
|
|
54
|
+
View << "@" if Line =~ /^ /
|
|
55
|
+
|
|
56
|
+
Launcher.insert("snippet/")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def self.docs
|
|
60
|
+
"
|
|
61
|
+
> To edit
|
|
62
|
+
|
|
63
|
+
> To Use
|
|
64
|
+
___
|
|
65
|
+
"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
data/lib/specs.rb
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
gem "rspec"
|
|
2
|
+
require "rspec"
|
|
3
|
+
|
|
4
|
+
class Specs
|
|
5
|
+
|
|
6
|
+
def self.menu
|
|
7
|
+
'
|
|
8
|
+
- .load/
|
|
9
|
+
| Loads rspec (including the .should method) into the xiki environment:
|
|
10
|
+
- more/
|
|
11
|
+
- continue/
|
|
12
|
+
> See
|
|
13
|
+
<< xiki/tests/
|
|
14
|
+
'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.load choice
|
|
18
|
+
if choice == "more"
|
|
19
|
+
return "
|
|
20
|
+
| > Point
|
|
21
|
+
| The point is so you can use rspec methods like .should when using
|
|
22
|
+
| do+run, as an easy transition to creating a spec:
|
|
23
|
+
|
|
|
24
|
+
| Launch continue/ above and then launch this line. This servers as
|
|
25
|
+
| a sort of mini test you can create inline.
|
|
26
|
+
|
|
|
27
|
+
+ try it out) @ puts 1.should == 2
|
|
28
|
+
|
|
|
29
|
+
"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Must be "continue/"
|
|
33
|
+
gem "rspec"
|
|
34
|
+
require "rspec"
|
|
35
|
+
return "- loaded!"
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class << self
|
|
40
|
+
def method_missing(func, *args, &block)
|
|
41
|
+
|
|
42
|
+
prefix = Keys.prefix
|
|
43
|
+
|
|
44
|
+
bm = nil
|
|
45
|
+
if args[0].is_a?(Symbol) # If symbol, use that as bookmark
|
|
46
|
+
bm = args.shift
|
|
47
|
+
else # Climb tree one level
|
|
48
|
+
parent = FileTree.parent
|
|
49
|
+
bm = parent.sub(/./, '') if parent =~ /^:\w+$/
|
|
50
|
+
end
|
|
51
|
+
bm = (bm || 'mt').to_sym
|
|
52
|
+
# thing, opts = nil, thing if thing.is_a?(Hash)
|
|
53
|
+
|
|
54
|
+
test, quote = args
|
|
55
|
+
|
|
56
|
+
quote = test if args.size == 1 && test =~ /\n/ # If only 1 arg and it's multiline, it must be a quote
|
|
57
|
+
if quote # If there's a quote, we're jumping, not running
|
|
58
|
+
quote = Line.value
|
|
59
|
+
quote =~ /([\.\/].+):(\d+)/
|
|
60
|
+
|
|
61
|
+
path, line = $1, $2
|
|
62
|
+
path.sub! /^\.\//, Bookmarks["$#{bm}"] # Fix relative paths
|
|
63
|
+
|
|
64
|
+
View.open path
|
|
65
|
+
View.to_line line.to_i
|
|
66
|
+
return
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
clazz = func.to_s
|
|
70
|
+
dir = 'models' # Assume model
|
|
71
|
+
|
|
72
|
+
dir = 'controllers' if clazz =~ /s$/ # If it ends with s, assume controller
|
|
73
|
+
dir = 'helpers' if clazz =~ /_helpers$/
|
|
74
|
+
|
|
75
|
+
# Special cases
|
|
76
|
+
dir = 'controllers' if clazz == "application"
|
|
77
|
+
|
|
78
|
+
# Try in unit/ dir first
|
|
79
|
+
path = "spec/unit/#{dir}/#{clazz}_spec.rb"
|
|
80
|
+
# Try just spec/ if not found
|
|
81
|
+
path = "spec/#{dir}/#{clazz}_spec.rb" if ! File.exists?("#{Bookmarks["$#{bm}"]}#{path}")
|
|
82
|
+
|
|
83
|
+
# If xiki, fix paths
|
|
84
|
+
# if bm == :x
|
|
85
|
+
# Ol << "path: #{path.inspect}"
|
|
86
|
+
# path.sub! /.+\//, 'spec/'
|
|
87
|
+
# end
|
|
88
|
+
|
|
89
|
+
if prefix == :u # If U prefix, jump to test
|
|
90
|
+
|
|
91
|
+
View.open "#{Bookmarks["$#{bm}"]}#{path}"
|
|
92
|
+
Keys.clear_prefix
|
|
93
|
+
View.to_highest
|
|
94
|
+
if test =~ /^#/
|
|
95
|
+
Search.forward "^ *describe .+['\"]#{$el.regexp_quote(test)}['\"]"
|
|
96
|
+
else
|
|
97
|
+
Search.forward "^ *it ['\"]#{$el.regexp_quote(test)}['\"]"
|
|
98
|
+
end
|
|
99
|
+
Line.to_beginning
|
|
100
|
+
return
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
txt = self.run_spec path, test, bm
|
|
104
|
+
txt.sub! /^F\n\n1\)\n/, '' # Remove 1st few lines
|
|
105
|
+
txt.sub! /^\.+\n\nFinished in.+\n\n/, '' # Remove 1st when passing
|
|
106
|
+
txt.sub! /^\(irb\):.+/m, '' # Remove everything after (irb)
|
|
107
|
+
|
|
108
|
+
txt.gsub! /^#{Bookmarks["$#{bm}"]}/m, './' # Shorten the paths
|
|
109
|
+
|
|
110
|
+
txt.sub! /nil\n$/, ''
|
|
111
|
+
# CodeTree.no_search_option +
|
|
112
|
+
|
|
113
|
+
txt.gsub!(/.+\/gems\/rr-.+\n/, '')
|
|
114
|
+
txt.gsub!(/.+\/gems\/rspec-.+\n/, '')
|
|
115
|
+
|
|
116
|
+
txt.gsub(/^/, '| ')
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def self.line_of_test path, test, bm
|
|
122
|
+
found = nil; number = 1
|
|
123
|
+
IO.foreach(Bookmarks["$#{bm}/#{path}"]) do |line|
|
|
124
|
+
if line =~ /^ *describe.+#{test}\b/
|
|
125
|
+
break found = number
|
|
126
|
+
end
|
|
127
|
+
number += 1
|
|
128
|
+
end
|
|
129
|
+
found
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def self.run_spec path, test, bm
|
|
133
|
+
params = [path]
|
|
134
|
+
|
|
135
|
+
if test =~ /^#/ # If starts with #, find line number
|
|
136
|
+
found = self.line_of_test path, test, bm
|
|
137
|
+
params << "-l" << (found ? "#{found}" : "0")
|
|
138
|
+
elsif test.is_a?(String)
|
|
139
|
+
params << "-e" << test
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# command = bm == :x ?
|
|
143
|
+
# command = "Spec::Runner::CommandLine.run(Spec::Runner::OptionParser.parse(#{params.inspect}, $out_bufr, $out_bufr))" :
|
|
144
|
+
|
|
145
|
+
# Rails
|
|
146
|
+
command = "require 'spec'; reload!; Spec::Runner::CommandLine.run(Spec::Runner::OptionParser.parse(#{params.inspect}, $out_bufr, $out_bufr))"
|
|
147
|
+
|
|
148
|
+
# Assume merb if a merb file exists
|
|
149
|
+
# Merb
|
|
150
|
+
if File.exists?(Bookmarks["$#{bm}/bin/merb"])
|
|
151
|
+
command = "Merb::Mailer.delivery_method=:test_send; Spec::Runner::CommandLine.run(Spec::Runner::OptionParser.parse(#{params.inspect}, $out_bufr, $out_bufr)); Merb::Mailer.delivery_method=nil"
|
|
152
|
+
end
|
|
153
|
+
result = RubyConsole[bm].run(command)
|
|
154
|
+
result
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Pastes in for the line in the clipboard:
|
|
158
|
+
# Spec.foo "bar"
|
|
159
|
+
def self.enter_as_rspec
|
|
160
|
+
|
|
161
|
+
line = Line.value
|
|
162
|
+
orig = Location.new
|
|
163
|
+
|
|
164
|
+
clazz = View.file_name[/(\w+)_spec\.rb/, 1]
|
|
165
|
+
path = "xiki/tests/#{clazz}/"
|
|
166
|
+
|
|
167
|
+
# If on describe, just append and done
|
|
168
|
+
if line =~ /^ *describe/
|
|
169
|
+
describe = line[/"(.+)"/, 1]
|
|
170
|
+
path << "#{describe}/"
|
|
171
|
+
else # If on it, grab, then go to describe
|
|
172
|
+
test = line[/"(.+)"/, 1]
|
|
173
|
+
Search.backward "^ *describe "
|
|
174
|
+
describe = Line[/"(.+)"/, 1]
|
|
175
|
+
path << "#{describe}/#{test}/"
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
View.layout_todo :no_blink=>1
|
|
180
|
+
View.to_highest
|
|
181
|
+
|
|
182
|
+
View.insert("\n", :dont_move=>1) unless line.empty? # Make room if line not blank
|
|
183
|
+
View.insert("\n", :dont_move=>1) if Line.value(2) =~ /^>/ # Add extra space if heading is after!
|
|
184
|
+
|
|
185
|
+
View.insert path
|
|
186
|
+
|
|
187
|
+
Move.to_axis
|
|
188
|
+
orig.go
|
|
189
|
+
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def self.enter_as_test_from_visit
|
|
194
|
+
line = Clipboard[0]
|
|
195
|
+
|
|
196
|
+
params_str = line[/\{(.+)\}/, 1]
|
|
197
|
+
params = eval "{#{params_str}}"
|
|
198
|
+
params_symbols = params.map{|k, v| ":#{k}=>#{v.inspect}"} * ",\n "
|
|
199
|
+
|
|
200
|
+
View.insert %Q`
|
|
201
|
+
it "__" do
|
|
202
|
+
c = dispatch_to(#{TextUtil.camel_case params['controller']}, #{params['action']},
|
|
203
|
+
#{params_symbols}) do |c|
|
|
204
|
+
end
|
|
205
|
+
c.body.should =~ /result...__/
|
|
206
|
+
end
|
|
207
|
+
`.unindent
|
|
208
|
+
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def self.run_spec_in_place
|
|
213
|
+
Keys.clear_prefix
|
|
214
|
+
cursor = View.cursor
|
|
215
|
+
|
|
216
|
+
path = View.file.sub /.+\/spec\//, 'spec/'
|
|
217
|
+
command = "rspec #{path}:#{View.line}"
|
|
218
|
+
result = Console.run command, :dir=>"$x", :sync=>true
|
|
219
|
+
result = result.gsub(/^/, ' # ').gsub(/ +$/, '')
|
|
220
|
+
|
|
221
|
+
Search.forward '^ +end$'
|
|
222
|
+
Move.forward
|
|
223
|
+
View.insert result
|
|
224
|
+
|
|
225
|
+
View.cursor = cursor
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
Menu.rspec :menu=>"specs"
|
data/lib/styles.rb
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
class Styles
|
|
2
|
+
|
|
3
|
+
def self.menu
|
|
4
|
+
|
|
5
|
+
'
|
|
6
|
+
- .font size/
|
|
7
|
+
- .background color/
|
|
8
|
+
- white/
|
|
9
|
+
- black/
|
|
10
|
+
- .list faces/
|
|
11
|
+
- api/
|
|
12
|
+
> Summary
|
|
13
|
+
| How to use the Styles class. You can change the color and font of text.
|
|
14
|
+
| You define styles, then make them apply to the text that matches
|
|
15
|
+
| regular expression.
|
|
16
|
+
|
|
|
17
|
+
> Define
|
|
18
|
+
| Styles.define :red, :bg => "d77"
|
|
19
|
+
|
|
|
20
|
+
> Apply
|
|
21
|
+
| Styles.apply "apply", :red
|
|
22
|
+
|
|
|
23
|
+
> Define more complex font
|
|
24
|
+
| Styles.define :blueish,
|
|
25
|
+
| :fg => "99e",
|
|
26
|
+
| :face => "verdana",
|
|
27
|
+
| :size => 90,
|
|
28
|
+
| :bold => true
|
|
29
|
+
|
|
|
30
|
+
> See
|
|
31
|
+
| For styling specific text (not just a pattern):
|
|
32
|
+
<<< @overlay/
|
|
33
|
+
- see/
|
|
34
|
+
> List styles in current page in web browser
|
|
35
|
+
<<< @css/list/
|
|
36
|
+
'
|
|
37
|
+
# > Apply multiple fonts and groups
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.background_color color
|
|
42
|
+
|
|
43
|
+
$el.customize_set_variable(:background_mode_type, color == "black" ? :dark : :light)
|
|
44
|
+
|
|
45
|
+
Notes.define_styles
|
|
46
|
+
FileTree.define_styles
|
|
47
|
+
Styles.use_xiki_color_scheme
|
|
48
|
+
Styles.define_misc_face_colors
|
|
49
|
+
Color.define_styles
|
|
50
|
+
|
|
51
|
+
nil
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.font_size size=nil
|
|
55
|
+
|
|
56
|
+
# If nothing passed, show default sizes
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if ! size
|
|
60
|
+
return "
|
|
61
|
+
- original) #{Styles.height}
|
|
62
|
+
- 110
|
|
63
|
+
- 120
|
|
64
|
+
- 135
|
|
65
|
+
- 160
|
|
66
|
+
- 200
|
|
67
|
+
- 250
|
|
68
|
+
"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
Styles.define :default, :size=>size.to_i
|
|
72
|
+
|
|
73
|
+
# To resize mode lines
|
|
74
|
+
Themes.use "Shiny Blue"
|
|
75
|
+
Notes.define_styles
|
|
76
|
+
FileTree.define_styles
|
|
77
|
+
|
|
78
|
+
nil
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.zoom options={}
|
|
82
|
+
|
|
83
|
+
increment = options[:out] ? -10 : 10
|
|
84
|
+
increment *= 10 if Keys.prefix_u
|
|
85
|
+
|
|
86
|
+
height = self.height
|
|
87
|
+
height += increment
|
|
88
|
+
self.font_size height
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def self.toggle
|
|
93
|
+
$el.elvar.font_lock_mode ?
|
|
94
|
+
$el.font_lock_mode(0) : # plain text
|
|
95
|
+
$el.font_lock_mode(true) # stylized text
|
|
96
|
+
|
|
97
|
+
nil
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def self.list_faces
|
|
101
|
+
$el.with(:save_window_excursion) do
|
|
102
|
+
$el.list_faces_display
|
|
103
|
+
end
|
|
104
|
+
View.to_buffer "*Faces*"
|
|
105
|
+
|
|
106
|
+
nil
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def self.inverse_bg enable=true
|
|
110
|
+
$el.customize_set_variable(:background_mode_type, enable ? :dark : :light)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def self.inverse
|
|
114
|
+
$el.boundp(:background_mode_type) &&
|
|
115
|
+
$el.elvar.background_mode_type.to_s == 'dark'
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def self.exand_colors options, keys
|
|
119
|
+
keys.each do |key|
|
|
120
|
+
next if ! options[key]
|
|
121
|
+
options[key].sub! /^#/, ''
|
|
122
|
+
options[key].sub! /^(.)(.)(.)$/, "\\1\\1\\2\\2\\3\\3"
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def self.method_missing *args
|
|
127
|
+
self.define *args
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def self.define name, options
|
|
131
|
+
|
|
132
|
+
return if ! $el
|
|
133
|
+
|
|
134
|
+
self.exand_colors options, [:bg, :fg]
|
|
135
|
+
|
|
136
|
+
code = "(set-face-attribute (make-face '#{name.to_s.gsub("_", "-")}) nil\n"
|
|
137
|
+
code << " :background \"##{options[:bg]}\"\n" if options[:bg]
|
|
138
|
+
code << " :foreground \"##{options[:fg]}\"\n" if options[:fg]
|
|
139
|
+
code << " :family \"#{options[:face]}\"\n" if options[:face]
|
|
140
|
+
|
|
141
|
+
if options[:size]
|
|
142
|
+
size = options[:size]
|
|
143
|
+
size = self.size(size.to_i) if size.is_a? String # If a string, convert to relative size
|
|
144
|
+
code << " :height #{size}\n"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
code += options[:strike] ? " :strike-through t\n" : " :strike-through nil\n" if options.has_key?(:strike)
|
|
148
|
+
|
|
149
|
+
code += options[:underline] ? " :underline t\n" : " :underline nil\n" if options.has_key?(:underline)
|
|
150
|
+
code += options[:overline] ? " :overline t\n" : " :overline nil\n" if options.has_key?(:overline)
|
|
151
|
+
|
|
152
|
+
code += options[:bold] ? " :weight 'bold\n" : " :weight 'normal\n" if options.has_key?(:bold)
|
|
153
|
+
if options[:border]
|
|
154
|
+
border = options[:border]
|
|
155
|
+
code <<
|
|
156
|
+
if border.class == Symbol
|
|
157
|
+
":box nil\n"
|
|
158
|
+
elsif border.class == String
|
|
159
|
+
":box '(:line-width 1 :color \"##{border}\")\n"
|
|
160
|
+
elsif border.class == Array
|
|
161
|
+
":box '(:line-width #{border[1]} :color \"##{border[0]}\" :style #{border[2] || 'nil'})\n"
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
code << " )"
|
|
165
|
+
|
|
166
|
+
$el.el4r_lisp_eval code
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def self.define_misc_face_colors
|
|
170
|
+
|
|
171
|
+
if Styles.inverse
|
|
172
|
+
|
|
173
|
+
Styles.define :font_lock_comment_face, :fg=>'777' # gray
|
|
174
|
+
Styles.define :font_lock_function_name_face, :fg=>'f50' # orange
|
|
175
|
+
Styles.define :font_lock_type_face, :fg=>'0a1' # green
|
|
176
|
+
Styles.define :font_lock_variable_name_face, :fg=>'fd0' # yellow
|
|
177
|
+
Styles.define :font_lock_string_face, :fg=>'e10' # red
|
|
178
|
+
Styles.define :font_lock_keyword_face, :fg=>'999'
|
|
179
|
+
|
|
180
|
+
else
|
|
181
|
+
|
|
182
|
+
Styles.define :font_lock_comment_face, :fg=>'aaa' # gray
|
|
183
|
+
Styles.define :font_lock_function_name_face, :fg=>'f50' # orange
|
|
184
|
+
Styles.define :font_lock_type_face, :fg=>'090', :bold=>nil # green
|
|
185
|
+
Styles.define :font_lock_variable_name_face, :fg=>'00c', :bold=>1 # yellow
|
|
186
|
+
Styles.define :font_lock_string_face, :fg=>'e10', :bold=>nil # red
|
|
187
|
+
Styles.define :font_lock_keyword_face, :fg=>'888', :bold=>1 # blue
|
|
188
|
+
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def self.apply(pattern, *styles)
|
|
194
|
+
# Make back-slashes double
|
|
195
|
+
pattern.gsub!("\\", '\\\\\\\\')
|
|
196
|
+
code = "(font-lock-add-keywords nil '(( \"#{pattern}\"\n"
|
|
197
|
+
styles.each_with_index do |f, i|
|
|
198
|
+
code << " (#{i} '#{f.to_s.gsub("_", "-")})\n" if f
|
|
199
|
+
end
|
|
200
|
+
code << " )))"
|
|
201
|
+
$el.el4r_lisp_eval code
|
|
202
|
+
$el.font_lock_mode 1
|
|
203
|
+
nil
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def self.init
|
|
207
|
+
return if ! $el
|
|
208
|
+
|
|
209
|
+
# Make 'arial black' work in Linux
|
|
210
|
+
$el.el4r_lisp_eval %`
|
|
211
|
+
(custom-set-variables
|
|
212
|
+
'(face-font-family-alternatives '(
|
|
213
|
+
("arial black" "arial" "DejaVu Sans")
|
|
214
|
+
("arial" "DejaVu Sans")
|
|
215
|
+
("verdana" "DejaVu Sans")
|
|
216
|
+
;("verdana" "arial")
|
|
217
|
+
))
|
|
218
|
+
'(global-font-lock-mode t nil (font-lock))
|
|
219
|
+
;'(font-lock-defaults '(nil t)) ; messes up Open List Faces
|
|
220
|
+
'(show-trailing-whitespace t)
|
|
221
|
+
'(font-lock-keywords-case-fold-search t)
|
|
222
|
+
)
|
|
223
|
+
`
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Don't format quotes (it can override other styles)
|
|
227
|
+
def self.clear
|
|
228
|
+
$el.el4r_lisp_eval "(setq font-lock-defaults '(nil t))"
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def self.height
|
|
232
|
+
$el.el4r_lisp_eval "(face-attribute 'default :height)"
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def self.attribute style, attribute
|
|
236
|
+
$el.el4r_lisp_eval "(face-attribute '#{style} :#{attribute})"
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def self.size relative=0
|
|
240
|
+
# Cache so subsequent calls don't have to look up from elisp
|
|
241
|
+
size = $el.el4r_lisp_eval "(face-attribute 'default :height)"
|
|
242
|
+
size ||= 90
|
|
243
|
+
size + relative * 5
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def self.use_xiki_color_scheme
|
|
247
|
+
if Styles.inverse # Use black
|
|
248
|
+
# Mode line (bar between windows)
|
|
249
|
+
|
|
250
|
+
$el.set_face_background :trailing_whitespace, "#333333"
|
|
251
|
+
Styles.define :default, :bg=>'111111', :fg=>'ffffff'
|
|
252
|
+
Styles.define :cursor, :bg=>'ffffff', :fg=>'000000'
|
|
253
|
+
|
|
254
|
+
Styles.define :fringe, :bg=>'111111', :fg=>'666666'
|
|
255
|
+
|
|
256
|
+
# Dark gray scheme
|
|
257
|
+
Styles.define :mode_line, :bg=>'333', :border=>['666', -1], :face=>'Lucida Grande', :size=>'3', :bold=>false, :fg=>'fff'
|
|
258
|
+
Styles.define :mode_line_inactive, :bg=>'666', :border=>['888', -1], :face=>'Lucida Grande', :size=>'3', :bold=>false, :fg=>'fff'
|
|
259
|
+
|
|
260
|
+
else
|
|
261
|
+
$el.set_face_background :trailing_whitespace, "#aaaaaa"
|
|
262
|
+
Styles.define :default, :bg=>'ffffff', :fg=>'000000'# , :height=>110
|
|
263
|
+
Styles.define :cursor, :bg=>'333333', :fg=>'ffffff'
|
|
264
|
+
Styles.define :fringe, :bg=>'ffffff', :fg=>'cccccc' # eg border / status
|
|
265
|
+
|
|
266
|
+
Styles.define :mode_line, :fg=>'222222', :bg=>'555', :border=>['333', -1], :face=>'Lucida Grande', :size=>'3', :bold=>false
|
|
267
|
+
Styles.define :mode_line_inactive, :fg=>'999999', :bg=>'888', :border=>['666', -1], :face=>'Lucida Grande', :size=>'3', :bold=>false
|
|
268
|
+
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
end
|
|
274
|
+
Styles.init
|