]> git.cworth.org Git - sup/blobdiff - lib/sup/buffer.rb
bugfix: backgrounding of thread loading not actually happening due to recent changes
[sup] / lib / sup / buffer.rb
index 36244304827d14b4c72240785c274d7fd0b50ddf..1bd03321a0ded5740882630e7c3dd718fa042157 100644 (file)
@@ -16,24 +16,10 @@ module Ncurses
   def mutex; @mutex ||= Mutex.new; end
   def sync &b; mutex.synchronize(&b); end
 
-  ## aaahhh, user input. who would have though that such a simple
-  ## idea would be SO FUCKING COMPLICATED?! because apparently
-  ## Ncurses.getch (and Curses.getch), even in cbreak mode, BLOCKS
-  ## ALL THREAD ACTIVITY. as in, no threads anywhere will run while
-  ## it's waiting for input. ok, fine, so we wrap it in a select. Of
-  ## course we also rely on Ncurses.getch to tell us when an xterm
-  ## resize has occurred, which select won't catch, so we won't
-  ## resize outselves after a sigwinch until the user hits a key.
-  ## and installing our own sigwinch handler means that the screen
-  ## size returned by getmaxyx() DOESN'T UPDATE! and Kernel#trap
-  ## RETURNS NIL as the previous handler! 
-  ##
-  ## so basically, resizing with multi-threaded ruby Ncurses
-  ## applications will always be broken.
-  ##
-  ## i've coined a new word for this: lametarded.
+  ## magically, this stuff seems to work now. i could swear it didn't
+  ## before. hm.
   def nonblocking_getch
-    if IO.select([$stdin], nil, nil, nil)
+    if IO.select([$stdin], nil, nil, 1)
       Ncurses.getch
     else
       nil
@@ -161,7 +147,7 @@ class BufferManager
 
     @buffers.delete buf
     if @buffers.length > 0 && @buffers.last.force_to_top?
-      @buffers.insert -2, buf
+      @buffers.insert(-2, buf)
     else
       @buffers.push buf
       focus_on buf
@@ -196,6 +182,7 @@ class BufferManager
   def [] n; @name_map[n]; end
   def []= n, b
     raise ArgumentError, "duplicate buffer name" if b && @name_map.member?(n)
+    raise ArgumentError, "title must be a string" unless n.is_a? String
     @name_map[n] = b
   end
 
@@ -209,14 +196,6 @@ class BufferManager
     end
   end
 
-  def handle_resize
-    return if @shelled
-    rows, cols = Ncurses.rows, Ncurses.cols
-    @buffers.each { |b| b.resize rows - minibuf_lines, cols }
-    completely_redraw_screen
-    flash "Resized to #{rows}x#{cols}"
-  end
-
   def draw_screen opts={}
     return if @shelled
 
@@ -258,6 +237,7 @@ class BufferManager
   end
 
   def spawn title, mode, opts={}
+    raise ArgumentError, "title must be a string" unless title.is_a? String
     realtitle = title
     num = 2
     while @name_map.member? realtitle