mscdex / node-ncurses

An ncurses binding for node.js
MIT License
386 stars 25 forks source link

Can't resize my windows after SIGWINCH #23

Closed vslinko closed 9 years ago

vslinko commented 11 years ago

Thanks @mscdex for your bindings!

* Find out why after calling endwin and refresh, the LINES and COLS globals are
  not updated appropriately after SIGWINCH.
  Also, ncurses' SIGWINCH handler that is included by default during build time
  does not cause a keyboard event to fire when it inserts KEY_RESIZE into the
  keyboard buffer, it merely uses ungetch to push it onto the top of the buffer.

Do you have some information about this point from TODO? I can't resize my windows:

var redrawNowPlayingWindow = function () {
    var lineNo = parseInt(nowPlayingWindow.height / 2 - 1);

    nowPlayingWindow.erase();
    nowPlayingWindow.centertext(lineNo, currentTrackMetadata.artist.join(', '));
    nowPlayingWindow.centertext(lineNo + 1, nc.lines.toString());
    nowPlayingWindow.refresh();
};

process.on('SIGWINCH', function () {
    nowPlayingWindow.resize(nc.lines, nc.cols);
    redrawNowPlayingWindow();
});
bpytlik commented 11 years ago

Try doing a nc.cleanup before your call to resize. I don't know if it's the "right" thing to do, or if there's a better way to do it. But it works for me at least.

katanacrimson commented 11 years ago

This is a bit of a killer, would really like to see this one fixed because it means that we're stuck with window sizes on startup. :\

James-Snow commented 11 years ago

I've just bumped up against this as well. Anyone have any insight into where the problem might lie? I think I've chased the nc.lines and nc.cols properties to here in binding.cc:

 static Handle<Value> LinesStateGetter (Local<String> property,
                                        const AccessorInfo& info) {
   assert(property == lines_state_symbol);

   HandleScope scope;

   return scope.Close(Integer::New(LINES));
 }

 static Handle<Value> ColsStateGetter (Local<String> property,
                                       const AccessorInfo& info) {
   assert(property == cols_state_symbol);

   HandleScope scope;

   return scope.Close(Integer::New(COLS));
 }

But I'm way beyond my C++ knowledge at this point.