Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Bind uv_tty_get_winsize
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Sep 23, 2011
1 parent fdeddb6 commit 0c4a424
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lib/readline.js
Expand Up @@ -95,12 +95,12 @@ function Interface(input, output, completer) {
this.history = [];
this.historyIndex = -1;

var winSize = tty.getWindowSize(output.fd);
var winSize = output.getWindowSize();
exports.columns = winSize[1];

if (process.listeners('SIGWINCH').length === 0) {
process.on('SIGWINCH', function() {
var winSize = tty.getWindowSize(output.fd);
var winSize = output.getWindowSize();
exports.columns = winSize[1];
});
}
Expand Down
4 changes: 4 additions & 0 deletions lib/tty_uv.js
Expand Up @@ -369,3 +369,7 @@ WriteStream.prototype.clearLine = function(dir) {
}
};


WriteStream.prototype.getWindowSize = function() {
return this._handle.getWindowSize();
};
30 changes: 11 additions & 19 deletions src/tty_wrap.cc
Expand Up @@ -6,16 +6,6 @@

namespace node {

#define UNWRAP \
assert(!args.Holder().IsEmpty()); \
assert(args.Holder()->InternalFieldCount() > 0); \
TTYWrap* wrap = \
static_cast<TTYWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
if (!wrap) { \
SetErrno(UV_EBADF); \
return scope.Close(Integer::New(-1)); \
}

using v8::Object;
using v8::Handle;
using v8::Local;
Expand All @@ -31,6 +21,16 @@ using v8::Arguments;
using v8::Integer;
using v8::Undefined;

#define UNWRAP \
assert(!args.Holder().IsEmpty()); \
assert(args.Holder()->InternalFieldCount() > 0); \
TTYWrap* wrap = \
static_cast<TTYWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
if (!wrap) { \
SetErrno(UV_EBADF); \
return scope.Close(Integer::New(-1)); \
}


class TTYWrap : StreamWrap {
public:
Expand Down Expand Up @@ -115,15 +115,7 @@ class TTYWrap : StreamWrap {
static Handle<Value> SetRawMode(const Arguments& args) {
HandleScope scope;

assert(!args.Holder().IsEmpty());
assert(args.Holder()->InternalFieldCount() > 0);
TTYWrap* wrap =
static_cast<TTYWrap*>(args.Holder()->GetPointerFromInternalField(0));

if (!wrap) {
SetErrno(UV_EBADF);
return scope.Close(Integer::New(-1));
}
UNWRAP

int r = uv_tty_set_mode(&wrap->handle_, args[0]->IsTrue());

Expand Down

0 comments on commit 0c4a424

Please sign in to comment.