X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Ftextfield.rb;h=76803bf97c9a00bc394a6f9e59c4f26b6b318b9e;hb=aef0216d7f988ab87a3430c9a65210f0d55dfc64;hp=479c609e146913c4e1391ef13740ef50a779f8da;hpb=16c86c02c5ee067194ecad0a86b4e8f08134c3e6;p=sup diff --git a/lib/sup/textfield.rb b/lib/sup/textfield.rb index 479c609..76803bf 100644 --- a/lib/sup/textfield.rb +++ b/lib/sup/textfield.rb @@ -33,11 +33,11 @@ class TextField @w, @y, @x, @width = window, y, x, width @question = question @completion_block = block - @field = Ncurses::Form.new_field 1, @width - question.length, @y, @x + question.length, 0, 0 + @field = Ncurses::Form.new_field 1, @width - question.length, @y, @x + question.length, 256, 0 @form = Ncurses::Form.new_form [@field] - @value = default + @value = default || '' Ncurses::Form.post_form @form - set_cursed_value default if default + set_cursed_value @value end def position_cursor @@ -112,11 +112,11 @@ class TextField unless @history.empty? value = get_cursed_value @i ||= @history.size - #Redwood::log "history before #{@history.inspect}" + #debug "history before #{@history.inspect}" @history[@i] = value #unless value =~ /^\s*$/ @i = (@i + (c == Ncurses::KEY_UP ? -1 : 1)) % @history.size @value = @history[@i] - #Redwood::log "history after #{@history.inspect}" + #debug "history after #{@history.inspect}" set_cursed_value @value Ncurses::Form::REQ_END_FIELD end