Class: Snippet
Class Method Summary collapse
Class Method Details
.docs ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/xiki/snippet.rb', line 59 def self.docs " > To edit > To Use ___ " end |
.insert ⇒ Object
53 54 55 56 57 |
# File 'lib/xiki/snippet.rb', line 53 def self.insert View << "@" if Line =~ /^ / Launcher.insert("snippet/") end |
.menu(*args) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/xiki/snippet.rb', line 2 def self. *args if args[0] == "docs" return Tree.children self.docs, args[1..-1] end extension = View.extension file = "#{Xiki.dir}etc/snippets/#{extension}.notes" prefix = Keys.prefix return View.open file if prefix == 'open' || prefix == :u # If up+, just go to file # If leaf has quote, kill the rest or create new snippet if args[-1] =~ /\|/ txt = ENV['txt'].dup txt << "\n" if txt !~ /\n/ #Tree.to_parent :u Tree.to_root CodeTree.kill_rest indent = Line.indent Line.delete View.<< txt.gsub(/^/, indent), :dont_move=>1 return end # Get snippets.foo file from snippets/ dirs, and drill into it # TODO: also look in ~/xiki/snippets? - find different dir name, in case ~/xiki is the Xiki.dir if ! File.exists? file # TODO: if none found, show return " | No snippets were found for the file extension '#{extension}'. | You can create some by making a tree in this file: @ #{file} " # TODO: maybe let them type directly into the @snippet menu and do C-. to save end txt = File.read file Tree.children txt, args # TODO: if line has quote and path doesn't exist in file (.drill fails), create new snippet end |