Sha256: 1424a36be7f1ac919880401322e229a472475c165d0b1ba3fc87971a31598405
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module Ruco class Editor attr_reader :file attr_reader :text_area private :text_area delegate :view, :selection, :text_in_selection, :color_mask, :selecting, :move, :cursor, :resize, :to => :text_area def initialize(file, options) @file = file content = (File.exist?(@file) ? File.read(@file) : '') if content.include?("\t") if options[:convert_tabs] content.tabs_to_spaces! else raise "#{@file} contains tabs.\nRuco atm does not support tabs, but will happily convert them to spaces if started with --convert-tabs or -c" end end @text_area = TextArea.new(content, options) @modified = false end def find(text) return unless start = text_area.content.index(text, text_area.index_for_position+1) finish = start + text.size move(:to_index, finish) selecting{ move(:to_index, start) } end def reset;end def insert(text) text_area.insert(text) @modified = true end def delete(*args) text_area.delete(*args) @modified = true end def delete_line(*args) text_area.delete_line(*args) @modified = true end def modified? @modified end def save File.open(@file,'w'){|f| f.write(text_area.content) } @modified = false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.27 | lib/ruco/editor.rb |