Sha256: 0fa0c481bcdd2f5919e7ef31de6b57704b7c18032c1b3d5ba8fd797b81cdb6d2
Contents?: true
Size: 673 Bytes
Versions: 1
Compression:
Stored size: 673 Bytes
Contents
module Ruco class TextField def initialize(options) @options = options @content = '' @column = 0 end def insert(text) @content += text move(0, text.size) end def delete(count) if count > 0 @content.slice!(@column, count) else delete_start = [@column - count.abs, 0].max @content[delete_start...@column] = '' @column = delete_start end end def view @content end def value @content end def move(line, column) @column = [[@column + column, 0].max, @content.size].min end def cursor [0, @column] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.5 | lib/ruco/text_field.rb |