lib/sup/textfield.rb in sup-0.3 vs lib/sup/textfield.rb in sup-0.4
- old
+ new
@@ -14,13 +14,11 @@
## to fill the screen (#roll_completions?).
##
## in sup, completion support is implemented through BufferManager#ask
## and CompletionMode.
class TextField
- def initialize window, y, x, width
- @w, @x, @y = window, x, y
- @width = width
+ def initialize
@i = nil
@history = []
@completion_block = nil
reset_completion_state
@@ -29,15 +27,15 @@
bool_reader :new_completions, :roll_completions
attr_reader :completions
def value; @value || get_cursed_value end
- def activate question, default=nil, &block
+ def activate window, y, x, width, question, default=nil, &block
+ @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, 0, 0
@form = Ncurses::Form.new_form [@field]
@value = default
Ncurses::Form.post_form @form
set_cursed_value default if default
end
@@ -45,11 +43,11 @@
def position_cursor
@w.attrset Colormap.color_for(:none)
@w.mvaddstr @y, 0, @question
Ncurses.curs_set 1
Ncurses::Form.form_driver @form, Ncurses::Form::REQ_END_FIELD
- Ncurses::Form.form_driver @form, Ncurses::Form::REQ_NEXT_CHAR if @value && @value =~ / $/ # fucking RETARDED!!!!
+ Ncurses::Form.form_driver @form, Ncurses::Form::REQ_NEXT_CHAR if @value && @value =~ / $/ # fucking RETARDED
end
def deactivate
reset_completion_state
@form.unpost_form
@@ -98,9 +96,11 @@
case c
when Ncurses::KEY_LEFT
Ncurses::Form::REQ_PREV_CHAR
when Ncurses::KEY_RIGHT
Ncurses::Form::REQ_NEXT_CHAR
+ when Ncurses::KEY_DC
+ Ncurses::Form::REQ_DEL_CHAR
when Ncurses::KEY_BACKSPACE
Ncurses::Form::REQ_DEL_PREV
when 1 #ctrl-a
Ncurses::Form::REQ_BEG_FIELD
when 5 #ctrl-e