Sha256: 5db9153a860a173d2b9ca2923d482cbe3b34afaa2d398ea07b606bf2ae2f1353
Contents?: true
Size: 851 Bytes
Versions: 40
Compression:
Stored size: 851 Bytes
Contents
module Ruco class Form delegate :move, :delete, :value, :selecting, :selection, :text_in_selection, :to => :text_field def initialize(label, options, &submit) @options = options @label = label.strip + ' ' @submit = submit reset end def view @label + @text_field.view end def style_map map = @text_field.style_map map.left_pad!(@label.size) map end def insert(text) @text_field.insert(text.gsub("\n",'')) unless text == "\n" @submit.call(@text_field.value) if text.include?("\n") or @options[:auto_enter] end def cursor Position.new 0, @label.size + @text_field.cursor.column end def reset @text_field = TextField.new(:columns => @options[:columns] - @label.size) end private attr_reader :text_field end end
Version data entries
40 entries across 40 versions & 1 rubygems