Added process.binding('stdio').getRows()

v0.7.4-release
Robert Keizer 2010-07-20 14:30:33 -05:00 committed by Ryan Dahl
parent d75b63bc3c
commit 5ebf6049d0
1 changed files with 13 additions and 0 deletions

View File

@ -91,6 +91,18 @@ static Handle<Value> GetColumns (const Arguments& args) {
return scope.Close(Integer::NewFromUnsigned(ws.ws_col)); return scope.Close(Integer::NewFromUnsigned(ws.ws_col));
} }
// process.binding('stdio').getRows();
static Handle<Value> GetRows (const Arguments& args) {
HandleScope scope;
struct winsize ws;
if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
return scope.Close(Integer::New(132));
}
return scope.Close(Integer::NewFromUnsigned(ws.ws_row));
}
/* STDERR IS ALWAY SYNC ALWAYS UTF8 */ /* STDERR IS ALWAY SYNC ALWAYS UTF8 */
static Handle<Value> static Handle<Value>
@ -208,6 +220,7 @@ void Stdio::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_METHOD(target, "isStdinBlocking", IsStdinBlocking); NODE_SET_METHOD(target, "isStdinBlocking", IsStdinBlocking);
NODE_SET_METHOD(target, "setRawMode", SetRawMode); NODE_SET_METHOD(target, "setRawMode", SetRawMode);
NODE_SET_METHOD(target, "getColumns", GetColumns); NODE_SET_METHOD(target, "getColumns", GetColumns);
NODE_SET_METHOD(target, "getRows", GetRows);
struct sigaction sa = {0}; struct sigaction sa = {0};
sa.sa_handler = HandleSIGCONT; sa.sa_handler = HandleSIGCONT;