Sha256: c7235358fe2e65db466e1e08001a188b9c3f54344badcefccf60d324e6b80fd6
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
module Ruco # everything that does not belong to a text-area # but is needed for Ruco::Editor class EditorArea < TextArea def delete_line lines.slice!(@line, 1) adjust_view end def indent selected_lines.each do |line| @lines[line].insert(0, ' ' * Ruco::TAB_SIZE) end adjust_to_indentation Ruco::TAB_SIZE adjust_view end def unindent lines_to_unindent = (selection ? selected_lines : [@line]) removed = lines_to_unindent.map do |line| remove = [@lines[line].leading_whitespace.size, Ruco::TAB_SIZE].min @lines[line].slice!(0, remove) remove end adjust_to_indentation -removed.first, -removed.last adjust_view end private def adjust_to_indentation(first, last=nil) last ||= first if selection cursor_adjustment = (selection.first == position ? first : last) selection.first.column = [selection.first.column + first, 0].max selection.last.column = [selection.last.column + last, 0].max @column += cursor_adjustment else @column += first end end def selected_lines selection.first.line.upto(selection.last.line) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.32 | lib/ruco/editor_area.rb |
ruco-0.0.31 | lib/ruco/editor_area.rb |
ruco-0.0.30 | lib/ruco/editor_area.rb |