commit 0ebf10c4b4e62fc8c568f25ef1b9af0f1d9a0a8e
parent 16c0a92ee589e0d40802fddd9d9c0d75ef4b823d
Author: Hamish Downer <dmishd@gmail.com>
Date: Tue, 22 Feb 2011 16:57:12 +0000
ctrl-w: rename and neaten up private method
Diffstat:
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lib/sup/textfield.rb b/lib/sup/textfield.rb
@@ -120,7 +120,7 @@ class TextField
nop
Ncurses::Form::REQ_BEG_FIELD
when ?\C-w.ord
- while action = after_space
+ while action = remove_extra_space
Ncurses::Form.form_driver @form, action
end
Ncurses::Form.form_driver @form, Ncurses::Form::REQ_PREV_CHAR
@@ -170,7 +170,7 @@ private
end
end
- def after_space
+ def remove_extra_space
return nil unless @field
Ncurses::Form.form_driver @form, Ncurses::Form::REQ_VALIDATION
@@ -187,18 +187,20 @@ private
if v[v_index-1] == ?\s
# if there is a non-space char under cursor then go back
if v[v_index] != ?\s
- return Ncurses::Form::REQ_PREV_CHAR
+ Ncurses::Form::REQ_PREV_CHAR
# otherwise delete the space
else
- return Ncurses::Form::REQ_DEL_PREV
+ Ncurses::Form::REQ_DEL_PREV
end
+ else
+ nil
end
elsif v_index == v.length
# at end of string, with non-space before us
- return nil
+ nil
else
# trailing spaces
- return Ncurses::Form::REQ_PREV_CHAR
+ Ncurses::Form::REQ_PREV_CHAR
end
end