From 96fbffda42682308637207eee9048a39e2185642 Mon Sep 17 00:00:00 2001 From: William Morgan Date: Thu, 27 Dec 2007 10:14:08 -0800 Subject: [PATCH] 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. --- lib/sup/buffer.rb | 10 +++++----- lib/sup/textfield.rb | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb index cd0ad78..522b907 100644 --- 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 index f4d7fbb..e569ea8 100644 --- 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, -- 2.45.2