]> git.cworth.org Git - sup/blobdiff - lib/sup/textfield.rb
add --commit option to spawn a compose-mode upon startup
[sup] / lib / sup / textfield.rb
index f4d7fbbf6d1e260ce441ae999e75416a298ee70a..2c5259532fafb15e712787ed5826485c1e8f4050 100644 (file)
@@ -16,9 +16,7 @@ module Redwood
 ## 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 = []
 
@@ -31,11 +29,11 @@ class TextField
 
   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
@@ -47,7 +45,7 @@ class TextField
     @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
@@ -100,6 +98,8 @@ class TextField
         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