Sha256: 28b87dfaa2a769f775b1bea1163a4a6c3e23b9dd68ddc190454ef6b8140f7a53
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
module Ruco class Editor attr_reader :file attr_reader :text_area private :text_area delegate :view, :color_mask, :cursor, :selecting, :selection, :text_in_selection, :move, :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 indent(*args) text_area.indent(*args) @modified = true end def unindent(*args) text_area.unindent(*args) @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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.29 | lib/ruco/editor.rb |
ruco-0.0.28 | lib/ruco/editor.rb |