commit 96fbffda42682308637207eee9048a39e2185642
parent 7914429bb85086d411760d27e3755dbc90d5f329
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Thu, 27 Dec 2007 10:14:08 -0800
bugfix in question asking: update position when window is resized
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.
Diffstat:
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -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
diff --git a/lib/sup/textfield.rb b/lib/sup/textfield.rb
@@ -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,