Sha256: 4751da95d93e65958da015538d2fe079e8b4f297c5500bcc60fcea9d606e6320
Contents?: true
Size: 899 Bytes
Versions: 6
Compression:
Stored size: 899 Bytes
Contents
module Ruco class Editor attr_reader :file delegate :view, :move, :cursor, :delete_line, :to => :text_area def initialize(file, options) @file = file @options = options content = (File.exist?(@file) ? File.read(@file) : '') @text_area = TextArea.new(content, @options) @modified = false end def find(text) index = text_area.content.index(text, text_area.cursor_index+1) || text_area.cursor_index move :to, *text_area.cursor_for_index(index) end def reset;end def insert(text) @modified = true text_area.insert(text) end def delete(*args) text_area.delete(*args) @modified = true end def modified? @modified end def save File.open(@file,'w'){|f| f.write(text_area.content) } @modified = false end private attr_reader :text_area end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.19 | lib/ruco/editor.rb |
ruco-0.0.18 | lib/ruco/editor.rb |
ruco-0.0.17 | lib/ruco/editor.rb |
ruco-0.0.16 | lib/ruco/editor.rb |
ruco-0.0.15 | lib/ruco/editor.rb |
ruco-0.0.14 | lib/ruco/editor.rb |