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.
Files changed (252) hide show
  1. data/Gemfile +11 -0
  2. data/LICENSE +22 -0
  3. data/README.markdown +83 -0
  4. data/Rakefile +8 -0
  5. data/bin/xiki +46 -0
  6. data/etc/command/xiki_command.rb +203 -0
  7. data/etc/command/xiki_process.rb +52 -0
  8. data/etc/command/xiki_wrapper +2 -0
  9. data/etc/js/menu1.js +55 -0
  10. data/etc/js/xiki.js +259 -0
  11. data/etc/logo.png +0 -0
  12. data/etc/presentations/bootstrap.deck +5 -0
  13. data/etc/presentations/databases.deck +41 -0
  14. data/etc/presentations/diffs.deck +23 -0
  15. data/etc/presentations/documentation.deck +14 -0
  16. data/etc/presentations/effects.deck +5 -0
  17. data/etc/presentations/face.deck +297 -0
  18. data/etc/presentations/files.deck +79 -0
  19. data/etc/presentations/icons.deck +22 -0
  20. data/etc/presentations/images.deck +24 -0
  21. data/etc/presentations/key_shortcuts.deck +16 -0
  22. data/etc/presentations/macros.deck +18 -0
  23. data/etc/presentations/menu_classes.deck +44 -0
  24. data/etc/presentations/menu_directories.deck +30 -0
  25. data/etc/presentations/notes.deck +19 -0
  26. data/etc/presentations/other_languages.deck +55 -0
  27. data/etc/presentations/other_wiki_syntaxes.deck +4 -0
  28. data/etc/presentations/piano.deck +5 -0
  29. data/etc/presentations/potential/diffs.deck +38 -0
  30. data/etc/presentations/potential/evolution.deck +18 -0
  31. data/etc/presentations/potential/intro.deck +711 -0
  32. data/etc/presentations/potential/intro1.deck +711 -0
  33. data/etc/presentations/potential/intro2.deck +97 -0
  34. data/etc/presentations/potential/make_mysql_menu.deck +36 -0
  35. data/etc/presentations/potential/ruby_development.deck +17 -0
  36. data/etc/presentations/potential/ui_prototyping.deck +50 -0
  37. data/etc/presentations/potential/web_dev.deck +4 -0
  38. data/etc/presentations/potential/web_development.deck +10 -0
  39. data/etc/presentations/potential/wiki.deck +45 -0
  40. data/etc/presentations/presentations.deck +24 -0
  41. data/etc/presentations/rails_development.deck +29 -0
  42. data/etc/presentations/search_key_shortcuts.deck +37 -0
  43. data/etc/presentations/simplest_possible_ui.deck +37 -0
  44. data/etc/presentations/svg.deck +5 -0
  45. data/etc/presentations/testing.deck +28 -0
  46. data/etc/presentations/the_end.deck +13 -0
  47. data/etc/presentations/type_something_and_double_click.deck +57 -0
  48. data/etc/presentations/type_the_acronym.deck +144 -0
  49. data/etc/presentations/web_browser.deck +56 -0
  50. data/etc/presentations/xiki_command.deck +20 -0
  51. data/etc/presentations/xiki_url.deck +14 -0
  52. data/etc/shark.icns +0 -0
  53. data/etc/shark_script.icns +0 -0
  54. data/etc/snippets/html.notes +7 -0
  55. data/etc/snippets/notes.notes +20 -0
  56. data/etc/snippets/rb.notes +38 -0
  57. data/etc/templates/menu_template.menu +2 -0
  58. data/etc/templates/menu_template.rb +8 -0
  59. data/etc/templates/template.rb +5 -0
  60. data/etc/themes/Dark_Metal.notes +28 -0
  61. data/etc/themes/Orange_Path.notes +15 -0
  62. data/etc/themes/Shiny_Blue.notes +27 -0
  63. data/etc/themes/Shiny_Green.notes +27 -0
  64. data/etc/wrappers/wrapper.js +17 -0
  65. data/etc/wrappers/wrapper.py +20 -0
  66. data/etc/wrappers/wrapper.rb +25 -0
  67. data/lib/block.rb +72 -0
  68. data/lib/bookmarks.rb +352 -0
  69. data/lib/buffers.rb +170 -0
  70. data/lib/clipboard.rb +333 -0
  71. data/lib/code.rb +860 -0
  72. data/lib/code_tree.rb +476 -0
  73. data/lib/color.rb +274 -0
  74. data/lib/console.rb +557 -0
  75. data/lib/control_lock.rb +9 -0
  76. data/lib/control_tab.rb +176 -0
  77. data/lib/core_ext.rb +31 -0
  78. data/lib/cursor.rb +111 -0
  79. data/lib/deletes.rb +65 -0
  80. data/lib/diff_log.rb +297 -0
  81. data/lib/effects.rb +145 -0
  82. data/lib/environment.rb +5 -0
  83. data/lib/file_tree.rb +1875 -0
  84. data/lib/files.rb +334 -0
  85. data/lib/hide.rb +259 -0
  86. data/lib/history.rb +286 -0
  87. data/lib/image.rb +51 -0
  88. data/lib/incrementer.rb +15 -0
  89. data/lib/insert.rb +7 -0
  90. data/lib/irc.rb +22 -0
  91. data/lib/key_bindings.rb +658 -0
  92. data/lib/keys.rb +754 -0
  93. data/lib/launcher.rb +1351 -0
  94. data/lib/line.rb +429 -0
  95. data/lib/links.rb +6 -0
  96. data/lib/location.rb +175 -0
  97. data/lib/macros.rb +48 -0
  98. data/lib/man.rb +19 -0
  99. data/lib/menu.rb +708 -0
  100. data/lib/merb.rb +259 -0
  101. data/lib/message.rb +5 -0
  102. data/lib/meths.rb +56 -0
  103. data/lib/mode.rb +34 -0
  104. data/lib/move.rb +248 -0
  105. data/lib/notes.rb +1000 -0
  106. data/lib/numbers.rb +45 -0
  107. data/lib/ol.rb +203 -0
  108. data/lib/ol_helper.rb +44 -0
  109. data/lib/overlay.rb +167 -0
  110. data/lib/pause_means_space.rb +68 -0
  111. data/lib/php.rb +22 -0
  112. data/lib/projects.rb +21 -0
  113. data/lib/relinquish_exception.rb +2 -0
  114. data/lib/remote.rb +206 -0
  115. data/lib/requirer.rb +46 -0
  116. data/lib/rest_tree.rb +108 -0
  117. data/lib/ruby.rb +57 -0
  118. data/lib/ruby_console.rb +165 -0
  119. data/lib/search.rb +1572 -0
  120. data/lib/search_term.rb +40 -0
  121. data/lib/snippet.rb +68 -0
  122. data/lib/specs.rb +229 -0
  123. data/lib/styles.rb +274 -0
  124. data/lib/svn.rb +682 -0
  125. data/lib/text_util.rb +110 -0
  126. data/lib/tree.rb +1871 -0
  127. data/lib/tree_cursor.rb +87 -0
  128. data/lib/trouble_shooting.rb +27 -0
  129. data/lib/url_tree.rb +11 -0
  130. data/lib/view.rb +1474 -0
  131. data/lib/window.rb +133 -0
  132. data/lib/xiki.rb +404 -0
  133. data/menus/accounts.rb +5 -0
  134. data/menus/address_book.rb +21 -0
  135. data/menus/agenda.rb +28 -0
  136. data/menus/all.rb +5 -0
  137. data/menus/amazon.rb +16 -0
  138. data/menus/app.rb +16 -0
  139. data/menus/applescript.rb +46 -0
  140. data/menus/as.rb +15 -0
  141. data/menus/bookmarklet.rb +63 -0
  142. data/menus/bootstrap.rb +568 -0
  143. data/menus/browse.rb +13 -0
  144. data/menus/browser.rb +78 -0
  145. data/menus/cassandra_db.rb +36 -0
  146. data/menus/chmod.rb +27 -0
  147. data/menus/classes.rb +5 -0
  148. data/menus/coffee_script.rb +35 -0
  149. data/menus/computer.rb +24 -0
  150. data/menus/contacts.rb +5 -0
  151. data/menus/cookies.rb +25 -0
  152. data/menus/couch.rb +184 -0
  153. data/menus/crop.rb +45 -0
  154. data/menus/css.rb +55 -0
  155. data/menus/current.rb +5 -0
  156. data/menus/db.rb +12 -0
  157. data/menus/deck.rb +219 -0
  158. data/menus/dictionary.rb +9 -0
  159. data/menus/dir.rb +8 -0
  160. data/menus/disk.rb +5 -0
  161. data/menus/do.rb +13 -0
  162. data/menus/docs.rb +58 -0
  163. data/menus/dotsies.rb +107 -0
  164. data/menus/edited.rb +18 -0
  165. data/menus/emacs.rb +17 -0
  166. data/menus/enter.rb +13 -0
  167. data/menus/eval.rb +17 -0
  168. data/menus/executable.rb +16 -0
  169. data/menus/filter.rb +46 -0
  170. data/menus/firefox.rb +607 -0
  171. data/menus/foo.rb +30 -0
  172. data/menus/french.rb +7 -0
  173. data/menus/git.rb +185 -0
  174. data/menus/gito.rb +785 -0
  175. data/menus/google.rb +35 -0
  176. data/menus/google_images.rb +11 -0
  177. data/menus/google_patents.rb +10 -0
  178. data/menus/gutenberg.rb +13 -0
  179. data/menus/head.rb +10 -0
  180. data/menus/headings.rb +39 -0
  181. data/menus/html.rb +61 -0
  182. data/menus/icon.rb +40 -0
  183. data/menus/images.menu +2 -0
  184. data/menus/img.rb +15 -0
  185. data/menus/info.rb +9 -0
  186. data/menus/ip.rb +10 -0
  187. data/menus/iterm.rb +36 -0
  188. data/menus/itunes.rb +78 -0
  189. data/menus/javascript.rb +74 -0
  190. data/menus/layout.rb +18 -0
  191. data/menus/local_storage.rb +67 -0
  192. data/menus/ls.rb +19 -0
  193. data/menus/mac.rb +87 -0
  194. data/menus/maps.rb +18 -0
  195. data/menus/matches.rb +18 -0
  196. data/menus/memcache.rb +117 -0
  197. data/menus/mkdir.rb +23 -0
  198. data/menus/mongo.rb +83 -0
  199. data/menus/mysql.rb +294 -0
  200. data/menus/node.rb +88 -0
  201. data/menus/open.rb +19 -0
  202. data/menus/outline.rb +24 -0
  203. data/menus/piano.rb +746 -0
  204. data/menus/postgres.rb +34 -0
  205. data/menus/pre.rb +5 -0
  206. data/menus/python.rb +39 -0
  207. data/menus/rails.rb +160 -0
  208. data/menus/rake.rb +12 -0
  209. data/menus/redmine.rb +168 -0
  210. data/menus/riak_tree.rb +204 -0
  211. data/menus/rss.rb +15 -0
  212. data/menus/safari.rb +11 -0
  213. data/menus/sass.rb +15 -0
  214. data/menus/say.rb +6 -0
  215. data/menus/scale.rb +49 -0
  216. data/menus/serve.rb +78 -0
  217. data/menus/shuffle.rb +24 -0
  218. data/menus/spanish.rb +7 -0
  219. data/menus/standalone.rb +57 -0
  220. data/menus/tail.rb +41 -0
  221. data/menus/technologies.rb +19 -0
  222. data/menus/themes.rb +32 -0
  223. data/menus/thesaurus.rb +13 -0
  224. data/menus/to.rb +24 -0
  225. data/menus/twitter.rb +57 -0
  226. data/menus/wikipedia.rb +34 -0
  227. data/menus/words.rb +11 -0
  228. data/spec/code_tree_spec.rb +59 -0
  229. data/spec/diff_log_spec.rb +40 -0
  230. data/spec/file_tree_spec.rb +102 -0
  231. data/spec/keys_spec.rb +24 -0
  232. data/spec/line_spec.rb +68 -0
  233. data/spec/menu_spec.rb +50 -0
  234. data/spec/ol_spec.rb +98 -0
  235. data/spec/remote_spec.rb +43 -0
  236. data/spec/search_spec.rb +162 -0
  237. data/spec/text_util_spec.rb +119 -0
  238. data/spec/tree_cursor_spec.rb +91 -0
  239. data/spec/tree_spec.rb +955 -0
  240. data/tests/console_test.rb +11 -0
  241. data/tests/couch_db_test.rb +12 -0
  242. data/tests/diff_log_test.rb +43 -0
  243. data/tests/el_mixin.rb +16 -0
  244. data/tests/git_test.rb +95 -0
  245. data/tests/keys_test.rb +19 -0
  246. data/tests/line_test.rb +38 -0
  247. data/tests/merb_test.rb +11 -0
  248. data/tests/redmine_test.rb +50 -0
  249. data/tests/remote_test.rb +31 -0
  250. data/tests/rest_tree_test.rb +70 -0
  251. data/xiki.gemspec +37 -0
  252. metadata +332 -0
@@ -0,0 +1,682 @@
1
+ require 'net/http'
2
+
3
+ # Note:
4
+ # This file (svn.rb) currently doesn't work. This is because
5
+ # repository.rb used to be behave as a common interface to git.rb
6
+ # and svn.rb, but was recently merged into git.rb, and made svn.rb
7
+ # no longer used.
8
+ #
9
+ # To get svn.rb to work again, merge the original
10
+ # version of repository.rb (pasted and commented at the end of
11
+ # this file) into this file. Then map the keys to use Svn
12
+ # instead of Git
13
+ #
14
+ class Svn
15
+
16
+ def self.menu action=nil, *path
17
+ if action == "list"
18
+ orig = View.window
19
+ View.to_after_bar
20
+ out = $el.shell_command_to_string("svn list")
21
+ View.to_window orig
22
+ return out.gsub(/^/, '- ')
23
+ end
24
+
25
+ "
26
+ + list/
27
+ + .diff/
28
+ "
29
+ end
30
+
31
+ def self.commit comment=""
32
+ Tree.siblings
33
+ end
34
+
35
+ def self.jump_to_diff
36
+ find = Line.without_indent
37
+ View.handle_bar
38
+ View.to_buffer "*console: svn diff*"
39
+ View.to_top
40
+ $el.re_search_forward "^Index: #{find}"
41
+ Line.to_left
42
+ $el.recenter(0)
43
+ end
44
+
45
+ def self.diff *args
46
+ if args.empty?
47
+ Ol << "empty"
48
+ res = Console.run("svn diff -x -w", :dir=>"$tr", :sync=>true)
49
+ res.gsub!(/\r/, '')
50
+ res.gsub!(/^/, ' ||')
51
+ res.gsub!(/^ \|\|-/, ' -|')
52
+ res.gsub!(/^ \|\|\+/, ' +|')
53
+ res.gsub!(/^ \|\|Index: /, '- ')
54
+ puts res
55
+ return
56
+ end
57
+ Ol << "args: #{args}"
58
+ end
59
+
60
+ end
61
+
62
+
63
+ # class Repository
64
+ # extend ElMixin
65
+
66
+ # CODE_SAMPLES = %q<
67
+ # # Show options for the repository
68
+ # - Show options: Repository.menu
69
+ # >
70
+
71
+ # @@git_diff_options = ' -U2 '
72
+ # #@@git_diff_options = ' -U2 -w ' # -w caused a git segfault :/
73
+
74
+ # def self.svn?
75
+ # File.exists?("#{View.dir}.svn")
76
+ # end
77
+
78
+ # def self.tag to, from=nil
79
+ # unless Repository.url
80
+ # puts "Error: Repository.url isn't set!"
81
+ # return
82
+ # end
83
+ # from ||= "trunk"
84
+ # command = "svn -m \"Tag: Create #{from} tag\" cp #{Repository.url}/#{from} #{Repository.url}/#{to}"
85
+ # Console.run(command)
86
+ # end
87
+
88
+ # def self.url= url
89
+ # @@url = url
90
+ # end
91
+
92
+ # def self.url
93
+ # @@url
94
+ # end
95
+
96
+ # def self.menu project=nil
97
+ # # If no project, show all projects
98
+ # if project.nil?
99
+ # result = []
100
+
101
+ # result += (Projects.listing.map{|k, v| "#{k} - #{v}/"}.sort)
102
+
103
+ # # If current dir is in a repos, add it
104
+ # current_dir_repos = self.git_path
105
+ # result << FileTree.add_slash_maybe("current dir - #{current_dir_repos ? current_dir_repos : View.dir}")
106
+
107
+ # # If current dir isn't one, try after bar
108
+ # if ! current_dir_repos and View.bar?
109
+ # after_bar = View.dir_of_after_bar
110
+ # current_dir_repos = self.git_path(after_bar)
111
+ # result << FileTree.add_slash_maybe(
112
+ # "upper - #{current_dir_repos ? current_dir_repos : after_bar}")
113
+ # end
114
+
115
+ # result << "tmp dir - /tmp/t1/"
116
+
117
+ # return result
118
+ # end
119
+
120
+ # # If project, show options
121
+ # puts %Q[
122
+ # + .create/
123
+ # + .diff_unadded/
124
+ # + .diff_unadded :expand/
125
+ # + .diff/
126
+ # + .diff :expand/
127
+ # + .push
128
+ # + .pull
129
+ # + .log ""/
130
+ # + .log_by_file/
131
+ # + .status/
132
+ # + .status_tree/
133
+ # + .branches/
134
+ # + .stash/
135
+ # - .files/
136
+ # ].strip.gsub(/^ /, '')
137
+ # end
138
+
139
+ # # Shows revs for one file
140
+ # def self.log_by_file search, limit, project, file=nil, rev=nil, line=nil
141
+ # dir = self.extract_dir project
142
+ # if file.nil? # If no file, tell them they have to paste it
143
+ # return "- Replace this line with a path - I'm normally called via Keys.show_log_one_file"
144
+ # end
145
+
146
+ # if rev.nil? # If no rev, list all revs
147
+ # search = "-S'#{search}'" unless search.empty?
148
+ # txt = Console.run "git log -#{limit} --pretty=oneline #{search} #{file}", :sync=>true, :dir=>dir
149
+ # txt.gsub! ':', '-'
150
+ # txt.gsub! /(.+?) (.+)/, "\\2: \\1"
151
+ # txt.gsub! /^- /, ''
152
+ # return txt.gsub!(/^/, '+ ')
153
+ # #return "- TODO: show all revs"
154
+ # end
155
+
156
+ # if line.nil? # If no diff, show diff
157
+ # # File passed, show diff
158
+ # txt = Git.diff "git show #{@@git_diff_options} --pretty=oneline #{rev} #{file}", dir
159
+ # txt.sub!(/.+?@@/m, '@@')
160
+ # return txt.gsub /^/, '|'
161
+ # end
162
+
163
+ # # Line passed, so jump to it
164
+ # project.sub! /^project - /, ''
165
+ # self.jump_to_file_in_tree project
166
+ # nil
167
+ # end
168
+
169
+ # def self.log search, project, rev=nil, file=nil, line=nil
170
+ # dir = self.extract_dir project
171
+
172
+ # if rev.nil? # If no rev, list all revs
173
+ # search = "-S'#{search}'" unless search.empty?
174
+
175
+ # txt = Console.run "git log -100 --pretty=oneline #{search}", :sync=>true, :dir=>dir
176
+ # txt.gsub! ':', '-'
177
+ # txt.gsub! /(.+?) (.+)/, "\\2: \\1"
178
+ # txt.gsub! /^- /, ''
179
+ # return txt.gsub!(/^/, '+ ')
180
+ # end
181
+
182
+ # if file.nil? # If no file, show files for rev
183
+ # # Rev passed, so show all diffs
184
+ # txt = Git.diff "git show --pretty=oneline --name-status #{rev}", dir
185
+ # txt.sub! /^.+\n/, ''
186
+ # txt.gsub! /^([A-Z])\t/, "\\1: "
187
+ # txt.gsub! /^M: /, ''
188
+ # return txt.split("\n").sort.map{|l| "+ #{l}\n"}.join('')
189
+ # end
190
+
191
+ # if line.nil? # If no line but file passed, show diff
192
+ # txt = Git.diff "git show #{@@git_diff_options} --pretty=oneline #{rev} #{file}", dir
193
+ # txt.sub!(/.+?@@/m, '@@')
194
+ # txt.gsub! /^/, '|'
195
+ # puts txt
196
+ # return
197
+ # end
198
+
199
+ # # Line passed, so jump to file
200
+ # project.sub! /^project - /, ''
201
+ # self.jump_to_file_in_tree project
202
+ # nil
203
+ # end
204
+
205
+ # def self.diff_one_file
206
+ # self.git_diff_one_file
207
+ # end
208
+
209
+ # def self.git_diff_one_file
210
+ # repos = self.git_path # Get root of repos
211
+ # relative = View.file.sub(/^#{repos}/, '') # Split off root from relative path
212
+ # relative.sub! /^\//, ''
213
+
214
+ # if Keys.prefix_u :clear=>true
215
+ # return
216
+ # end
217
+
218
+ # # Insert codetree
219
+ # Launcher.open(
220
+ # "- Repository.menu/\n - project - #{repos}\n - .diff/\n - #{relative}",
221
+ # :no_search=>true
222
+ # )
223
+ # end
224
+
225
+ # def self.show_log
226
+ # dir = Keys.bookmark_as_path :prompt=>"Enter a bookmark to show the log for: "
227
+ # Launcher.open("- Repository.menu/\n - project - #{dir}\n - .log ''/")
228
+ # end
229
+
230
+ # def self.show_log_one_file
231
+ # repos = self.git_path # Get root of repos
232
+ # relative = View.file.sub(/^#{repos}/, '') # Split off root from relative path
233
+ # relative.sub! /^\//, '' # Insert codetree
234
+
235
+ # Launcher.open(
236
+ # "- Repository.menu/\n - project - #{repos}\n - .log_by_file \"\", 10/\n - #{relative}"
237
+ # )
238
+ # end
239
+
240
+ # def self.jump_to_file_in_tree dir
241
+ # orig = View.cursor
242
+ # Search.backward "^ +\|@@" unless Line.matches(/^ +\|@@/)
243
+
244
+ # inbetween = View.txt(orig, View.cursor)
245
+ # inbetween.gsub!(/^ +\|-.*\n/, '')
246
+ # inbetween = inbetween.count("\n")
247
+ # line = Line.value[/\+(\d+)/, 1]
248
+ # Search.backward "^ +[+-] "
249
+ # file = Line.without_label
250
+ # goto_char orig
251
+
252
+ # View.open("#{dir}/#{file}")
253
+ # View.to_line(line.to_i + (inbetween - 1))
254
+ # Color.colorize :l
255
+ # end
256
+
257
+ # def self.styles_define
258
+ # Styles.define :face_difflog_path_outline_rest,
259
+ # :fg => "000077",
260
+ # :bg => "7070bb",
261
+ # :font => "arial"
262
+
263
+ # # - foo (r): <here>
264
+ # Styles.define :diff_subhead,
265
+ # :bg => "333366", :fg => "88b", :size => "-3"
266
+
267
+ # end
268
+
269
+ # def self.styles
270
+ # cm_universal_diff_format
271
+ # difflog_highlight
272
+ # Styles.apply "^diff.+\n", :diff_subhead
273
+ # Styles.apply "^Index:? .+\n", :diff_subhead
274
+ # Styles.apply "^===+\n", :diff_subhead
275
+ # Styles.apply "^--- .+\n", :diff_subhead
276
+ # Styles.apply "^\\+\\+\\+ .+\n", :notes_h1
277
+ # Styles.apply "^\\\\.+", :cm_lighter_bold
278
+ # #Styles.apply "^\\*.+\n", :treels_f_blank
279
+ # Styles.apply "^@@.+\n", :diff_subhead
280
+
281
+ # end
282
+
283
+ # def self.git? dir
284
+ # git_status = Git.diff "git status", dir
285
+ # git_status !~ /^fatal: Not a git repository/
286
+ # end
287
+
288
+ # def self.git_path dir=nil
289
+ # dir ||= View.dir
290
+ # return nil unless self.git?(dir)
291
+ # dir = Console.run("git rev-parse --git-dir", :sync=>true,
292
+ # :dir=>dir
293
+ # ).sub(".git\n", '')
294
+ # dir = View.dir if dir == "" # Empty actually means it found it
295
+ # dir
296
+ # end
297
+
298
+ # def self.determine_dir dir
299
+ # self.git_path(dir)# || Bookmarks['$tr']
300
+ # end
301
+
302
+ # def self.open_list_repository
303
+ # # Figure out which dir
304
+ # dir = Keys.prefix_u? ? Bookmarks['$tr'] : self.determine_dir(View.dir)
305
+
306
+ # View.to_buffer "*repository status"
307
+ # View.clear
308
+ # View.dir = dir
309
+ # FileTree.apply_styles
310
+ # use_local_map elvar.notes_mode_map
311
+
312
+ # tree = self.status_tree_internal dir
313
+ # View.insert "- Repository.status_tree/\n#{tree.gsub(/^/, ' ')}"
314
+
315
+ # View.to_top
316
+ # Move.to_junior
317
+ # FileTree.search :recursive => true
318
+
319
+ # end
320
+
321
+ # # Called by code tree directly
322
+ # def self.status_tree project
323
+ # dir = self.extract_dir project
324
+ # dir = Bookmarks.expand(dir)
325
+ # puts CodeTree.tree_search_option + self.status_tree_internal(dir)
326
+ # end
327
+
328
+ # def self.status_tree_internal dir
329
+
330
+ # if self.svn?
331
+ # status = Console.run "svn st", :dir => dir, :sync => true
332
+ # # Remove question files
333
+ # status = status.split("\n")#.select{|l| l !~ /^\?/}
334
+ # status = status.each{|l| l.sub!(/^. +/, dir)}
335
+ # FileTree.paths_to_tree(status)
336
+ # else # git
337
+ # status = Console.run "git status", :dir => dir, :sync => true
338
+
339
+ # # Grab out modified:...
340
+ # found = status.scan(/^#\s+modified: +(.+)/)
341
+ # result = []
342
+ # found.each do |m|
343
+ # result << "#{dir}#{m[0]}"
344
+ # end
345
+ # FileTree.paths_to_tree(result)
346
+ # end
347
+ # end
348
+
349
+ # def self.clean! txt
350
+ # txt.gsub!(/^ ?index .+\n/, '')
351
+ # txt.gsub!(/^ ?--- .+\n/, '')
352
+ # txt.gsub!(/^ ?\+\+\+ .+\n/, '')
353
+ # end
354
+
355
+ # def self.extract_dir project
356
+ # project.sub(/.+? - /, '').sub(/\/$/, '')
357
+ # end
358
+
359
+ # def self.status project, file=nil
360
+ # dir = self.extract_dir project
361
+ # #dir ||= self.determine_dir
362
+
363
+ # if file.nil?
364
+ # return Git.status dir
365
+ # end
366
+
367
+ # View.open("#{dir}/#{file}") # If file, open it
368
+
369
+ # end
370
+
371
+ # def self.diff_unadded *args
372
+ # expand = args.shift if args.first.is_a? Symbol # Pull out :expand if 1st arg
373
+ # project, file, line = args
374
+ # dir = self.extract_dir project
375
+
376
+ # if self.git?(dir)
377
+ # self.git_diff_unadded(expand, dir, file, line)
378
+ # else
379
+ # self.svn_diff_unadded(dir, file)
380
+ # end
381
+ # end
382
+
383
+
384
+ # def self.git_diff_unadded expand, dir, file, line
385
+ # self.git_diff_or_diff_unadded true, expand, dir, file, line
386
+ # end
387
+
388
+ # def self.diff *args
389
+ # # Parse args
390
+ # expand = args.shift if args.first.is_a? Symbol # Pull out :expand if 2nd arg
391
+ # project, file, line = args
392
+ # dir = self.extract_dir project
393
+
394
+ # if self.git?(dir)
395
+ # self.git_diff expand, dir, file, line
396
+ # else
397
+ # self.svn_diff expand, dir, file, line
398
+ # end
399
+ # end
400
+
401
+ # def self.git_diff expand, dir, file, line
402
+
403
+ # self.git_diff_or_diff_unadded false, expand, dir, file, line
404
+
405
+ # end
406
+
407
+ # def self.git_diff_or_diff_unadded is_unadded, expand, dir, file, line
408
+ # if file.nil? # If launching .diff/.diff_unadded directly (not a file)
409
+
410
+ # txt = Console.run "git status", :dir=>dir, :sync=>true
411
+
412
+ # hash = Git.status_to_hash(Git.status_internal(txt))
413
+
414
+ # untracked = hash[:untracked].map{|i| i[1]}
415
+ # untracked.map!{|i| "+ untracked#{is_unadded ? '' : ' (ignore)'}: #{i}\n"}
416
+
417
+ # option = is_unadded ? "- action: .add\n" : "- action: .commit \"message\"\n"
418
+
419
+ # if expand # If showing diffs right away
420
+ # txt = Git.diff "git diff --patience --relative #{self.git_diff_options}#{is_unadded ? '' : ' HEAD'}", dir
421
+
422
+ # if txt =~ /^fatal: ambiguous argument 'HEAD': unknown revision/
423
+ # txt = "- Warning: Couldn't diff because no revisions exist yet in repository\n" +
424
+ # " - Try using: .diff/ (without :expand)\n"
425
+ # else
426
+ # unless txt.empty?
427
+ # self.clean! txt
428
+ # txt.gsub!(/^/, ' |')
429
+ # txt.gsub!(/^ \| ?diff --git .+ b\//, '- ')
430
+ # end
431
+ # end
432
+ # else # If just showing list of files
433
+ # if is_unadded # If unadded, simply use unadded
434
+ # txt = hash[:unadded].map{|i| "+ #{i[1]}\n"}.join('')
435
+ # else # If added, use added + unadded - dups
436
+ # txt = (hash[:unadded].map{|i| "+ #{i[1]}\n"} +
437
+ # hash[:added].map{|i| "+ #{i[1]}\n"}).sort.uniq.join('')
438
+ # end
439
+ # end
440
+
441
+ # # Add labels back
442
+ # if is_unadded # If unadded, add labels from added (if they exist there)
443
+ # hash[:added].each {|i| txt.sub! /^([+-]) #{i[1]}$/, "\\1 #{i[0]}: #{i[1]}"}
444
+ # else # If added, add your label also unadded (or special)
445
+ # unadded = hash[:unadded].map{|i| i[1]}
446
+ # hash[:added].each do |i|
447
+ # # Only add label if file is also unadded, or if label isn't 'modified'
448
+ # next unless unadded.member?(i[1]) or i[0] != 'modified'
449
+ # txt.sub! /^([+-]) #{i[1]}$/, "\\1 #{i[0]}: #{i[1]}"
450
+ # end
451
+ # end
452
+ # txt << untracked.join("")
453
+ # txt = "- Warning: nothing to show" if ! txt.any?
454
+ # return CodeTree.no_search_option + option + txt
455
+ # end
456
+
457
+ # if line.nil? # If no line passed, re-do diff for 1 file
458
+ # # If untracked, show whole file
459
+ # if Line.label =~ /^untracked/
460
+ # return "|@@ +1\n" + IO.read(Bookmarks.expand("#{dir}/#{file}")).gsub(/^/, '|+').gsub("\c@", '.')
461
+ # end
462
+
463
+ # txt = is_unadded ?
464
+ # Git.diff("git diff --patience --relative #{self.git_diff_options} #{file}", dir) :
465
+ # Git.diff("git diff --patience --relative #{self.git_diff_options} HEAD #{file}", dir)
466
+ # self.clean! txt
467
+ # txt.gsub!(/^ ?diff .+\n/, '')
468
+ # txt.gsub!(/^/, '|')
469
+ # return puts(txt)
470
+ # end
471
+
472
+ # # If line passed, jump to it
473
+ # self.jump_to_file_in_tree dir
474
+ # nil
475
+ # end
476
+
477
+ # def self.push project
478
+ # dir = self.extract_dir project
479
+ # Console.run "git push origin master", :dir=>dir
480
+ # nil
481
+ # end
482
+
483
+ # def self.pull project
484
+ # dir = self.extract_dir project
485
+ # Console.run "git pull origin master", :dir=>dir
486
+ # nil
487
+ # end
488
+
489
+ # def self.code_tree_diff options={}
490
+ # dir = Keys.bookmark_as_path :prompt=>"Enter a bookmark to push: "
491
+
492
+ # prefix = Keys.prefix
493
+ # expand = prefix == :uu ? "" : ", :expand"
494
+ # menu = "- Repository.menu/\n - project - #{dir}\n - .diff#{expand}/"
495
+
496
+ # if options[:enter]
497
+ # View.insert(menu)
498
+ # Launcher.launch
499
+ # else
500
+ # View.bar if prefix == 9
501
+ # Launcher.open(menu)
502
+ # end
503
+ # end
504
+
505
+ # def self.code_tree_diff_unadded options={}
506
+ # dir = Keys.bookmark_as_path
507
+ # menu = "- Repository.menu/\n - project - #{dir}\n - .diff_unadded :expand/"
508
+ # if options[:enter]
509
+ # View.insert(menu)
510
+ # Launcher.launch
511
+ # else
512
+ # Launcher.open(menu)
513
+ # end
514
+ # end
515
+
516
+ # def self.svn_diff_unadded dir, file
517
+ # children = CodeTree.children || []
518
+
519
+ # if file # If file passed, just open it
520
+ # View.open("#{dir}/#{file}")
521
+ # return
522
+ # end
523
+
524
+ # if children.nonempty? # If children, add them
525
+ # children = children.map{|c| c.sub(/^ +[+-] /, '')}.join(" ")
526
+ # txt = Console.run("svn add #{children}", :dir => dir)
527
+
528
+ # return
529
+ # end
530
+
531
+ # # If no children, show ones to be added
532
+ # txt = Console.run("svn status", :dir => dir, :sync => true)
533
+ # return txt.scan(/^\? +(.+)/)
534
+
535
+ # end
536
+
537
+ # def self.svn_diff expand, dir, file, line, children
538
+
539
+ # if file.nil? # If launching .commit directly (no file)
540
+
541
+ # if expand
542
+ # txt = Console.run("svn diff #{file}", :sync => true, :dir => dir)
543
+
544
+ # txt.gsub!(/^===+\n/, '')
545
+ # txt.gsub!(/^--- .+\n/, '')
546
+ # txt.gsub!(/^\+\+\+ .+\n/, '')
547
+ # txt.gsub!(/^/, ' |')
548
+ # txt.gsub!(/^ \|Index: /, '- ')
549
+ # return txt
550
+
551
+ # else
552
+ # txt = Console.run "svn status", :dir=>dir, :sync=>true
553
+
554
+ # modified = txt.scan(/^M +(.+)/).map{|i| i.first}
555
+ # new_files = txt.scan(/^A +(.+)/).map{|i| "new: " + i.first}
556
+
557
+ # return new_files + modified
558
+ # end
559
+ # end
560
+
561
+ # if line.nil? # If no line passed, re-do diff for 1 file
562
+ # txt = Console.run("svn diff #{file}", :sync => true, :dir => dir)
563
+
564
+ # txt.gsub!(/^Index: .+\n/, '')
565
+ # txt.gsub!(/^===+\n/, '')
566
+ # txt.gsub!(/^--- .+\n/, '')
567
+ # txt.gsub!(/^\+\+\+ .+\n/, '')
568
+ # txt.gsub!(/^/, '|')
569
+ # return txt
570
+ # end
571
+
572
+ # self.jump_to_file_in_tree dir # If line passed, jump to it
573
+
574
+ # nil # Be sure to have no return value
575
+
576
+ # end
577
+
578
+ # def self.add project
579
+ # dir = self.extract_dir project
580
+
581
+ # siblings = Tree.siblings
582
+ # # Error if no siblings
583
+ # unless siblings.any?
584
+ # return "- No files to add (they should be siblings of .add)!"
585
+ # end
586
+
587
+ # if self.git?(dir)
588
+ # Console.run("git add #{siblings.join(' ')}", :dir=>dir)
589
+ # else
590
+ # Console.run("svn add #{siblings.join(' ')}", :dir=>dir)
591
+ # end
592
+ # end
593
+
594
+ # def self.commit message, project
595
+ # dir = self.extract_dir project
596
+
597
+ # siblings = Tree.siblings :include_label=>true
598
+
599
+ # left1, right1, left2, right2 = Tree.sibling_bounds
600
+
601
+ # # Remove "untracked (ignore)"
602
+ # siblings = siblings.select{|i| i !~ /^. untracked \(ignore\)/}.map{|i| Line.without_label(:line=>i)}
603
+
604
+ # if message == 'message' # Error if no siblings
605
+ # return "- Error: You must change 'message' to be your commit message." if message == "message"
606
+ # end
607
+ # unless siblings.any?
608
+ # return "- Error: No files to commit\n" +
609
+ # " - They should be siblings of .commit, and already be added."
610
+ # end
611
+
612
+ # if self.git?(dir)
613
+ # Console.run "git commit -m \"#{message}\" #{siblings.join(' ')}", :dir=>dir#, :no_enter=>true
614
+ # else
615
+ # Console.run "svn ci -m \"#{message}\" #{siblings.join(' ')}", :dir=>dir
616
+ # end
617
+ # end
618
+
619
+ # def self.create project
620
+ # "
621
+ # - #{self.extract_dir(project)}/
622
+ # - create: ! git init
623
+ # - make test files: ! echo 'a\\na\\na' > a.txt; echo 'b\\nb\\nb' > b.txt
624
+ # - add files: ! git add .
625
+ # - commit: ! git commit -m \"First commit.\"
626
+ # "
627
+ # end
628
+
629
+ # # def self.initialize project
630
+ # # dir = self.extract_dir project
631
+ # # # Create dir if not there
632
+ # # Dir.mkdir(dir) if not File.directory?(dir)
633
+ # # Console.run("git init", :dir => dir)
634
+ # # nil
635
+ # # end
636
+
637
+ # def self.files project
638
+ # "- #{self.extract_dir(project)}/"
639
+ # end
640
+
641
+ # def self.branches project
642
+ # "
643
+ # - #{self.extract_dir(project)}/
644
+ # - list branches:
645
+ # ! git branch
646
+ # ! git branch -r
647
+ # - create branch:
648
+ # ! git branch foo
649
+ # - switch to:
650
+ # ! git checkout foo
651
+ # - delete:
652
+ # ! git branch -d foo
653
+ # - switch to main branch:
654
+ # ! git checkout master
655
+ # - delete remote branch:
656
+ # ! git push origin :my_branch
657
+ # "
658
+ # end
659
+
660
+ # def self.stash project
661
+ # "
662
+ # - #{self.extract_dir(project)}/
663
+ # - Temporarily put away uncommitted changes:
664
+ # ! git stash
665
+ # - Restore uncommitted changes:
666
+ # ! git stash apply
667
+ # ! git stash pop
668
+ # - list: ! git stash list
669
+ # - files: ! git stash show
670
+ # - diff: ! git stash show --patience
671
+ # "
672
+ # end
673
+
674
+ # def self.git_diff_options
675
+ # @@git_diff_options + (Keys.prefix_u ? ' --color-words ' : '')
676
+
677
+ # # Doesn't work:
678
+ # # + (Keys.prefix_uu ? ' --name-only ' : '')
679
+ # end
680
+
681
+ # end
682
+ # Repository.styles_define