]> git.cworth.org Git - sup/commitdiff
bugfix in question asking: update position when window is resized
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 27 Dec 2007 18:14:08 +0000 (10:14 -0800)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 27 Dec 2007 18:14:08 +0000 (10:14 -0800)
previously we stored the position and width only once, at textfield
creation time, but then later screen resizings would make that
invalid. now we set those values every time we activate the textfield.

lib/sup/buffer.rb
lib/sup/textfield.rb

index cd0ad78d6018f064d895bb0d754a346c53d5c255..522b9070b4f654ac4073d7074e7fe3ed731625c1 100644 (file)
@@ -494,22 +494,22 @@ EOS
     end
   end
 
-
   def ask domain, question, default=nil, &block
     raise "impossible!" if @asking
     @asking = true
 
-    @textfields[domain] ||= TextField.new Ncurses.stdscr, Ncurses.rows - 1, 0, Ncurses.cols
+    @textfields[domain] ||= TextField.new
     tf = @textfields[domain]
     completion_buf = nil
 
     ## this goddamn ncurses form shit is a fucking 1970's nightmare.
     ## jesus christ. the exact sequence of ncurses events that needs
     ## to happen in order to display a form and have the entire screen
-    ## not disappear and have the cursor in the right place is TOO
-    ## FUCKING COMPLICATED.
+    ## not disappear and have the cursor in the right place can only
+    ## be determined by hours of trial and error and is TOO FUCKING
+    ## COMPLICATED.
     Ncurses.sync do
-      tf.activate question, default, &block
+      tf.activate Ncurses.stdscr, Ncurses.rows - 1, 0, Ncurses.cols, question, default, &block
       @dirty = true
       draw_screen :skip_minibuf => true, :sync => false
       tf.position_cursor
index f4d7fbbf6d1e260ce441ae999e75416a298ee70a..e569ea8fc4a106b790582dedc6a9b9e455c03f0a 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,7 +29,8 @@ 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,