Class: Block
Class Method Summary collapse
- .>>(txt) ⇒ Object
- .do_as_something ⇒ Object
-
.do_as_wrap ⇒ Object
def self.value res = [] with(:save_excursion) do found = re_search_backward “^ *$”, nil, 1 if found end_of_line forward_char end res << point re_search_forward “^ *$”, nil, 1 beginning_of_line res << point end res end.
Class Method Details
.>>(txt) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/xiki/block.rb', line 63 def self.>> txt orig = Location.new ignore, left, right = View.block_positions "^>" View.cursor = right View.insert(">>\n#{txt.strip}\n") unless txt.blank? orig.go end |
.do_as_something ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/xiki/block.rb', line 42 def self.do_as_something prefix = Keys.prefix txt, left, right = View.txt_per_prefix prefix result = yield txt # Insert result at end of block orig = Location.new View.cursor = right Line.to_left if prefix.nil? View.insert(">>\n"+result.strip+"\n") unless result.blank? else View.insert(result.strip.gsub(/^/, ' ')+"\n") unless result.blank? end orig.go end |
.do_as_wrap ⇒ Object
def self.value
res = []
with(:save_excursion) do
found = re_search_backward "^ *$", nil, 1
if found
end_of_line
forward_char
end
res << point
re_search_forward "^ *$", nil, 1
beginning_of_line
res << point
end
res
end
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/xiki/block.rb', line 19 def self.do_as_wrap if Keys.prefix_u? # Grab paragraph and remove linebreaks orig = Location.new txt = View.paragraph :delete => true, :start_here => true txt.gsub! "\n", " " txt.sub!(/ $/, "\n") View.insert txt orig.go Line.to_left View.insert "> " $el.fill_paragraph nil txt = View.paragraph(:delete => true) View.insert txt.gsub(/^ /, '> ') return end $el.fill_paragraph nil end |