Method: Tree.collapse

Defined in:
lib/xiki/tree.rb

.collapse(options = {}) ⇒ Object



1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
# File 'lib/xiki/tree.rb', line 1313

def self.collapse options={}
  # If at root or end of line, go to next
  Line.next if Line !~ /^ / || Line.at_right?
  CodeTree.kill_siblings

  Move.to_end -1

  Line.sub! /([ +-]*).+/, "\\1" if options[:replace_parent]

  left = View.cursor
  $el.skip_chars_forward(" \n+-")
  View.delete left, View.cursor

  Move.to_end
  left, right = View.paragraph :bounds=>true, :start_here=>true

  $el.indent_rigidly View.cursor, right, -2
end