├── .gitignore ├── README.md ├── binding.gyp ├── curses.js ├── example ├── hello.js └── matrix.js ├── gcc-build-arm.sh ├── gcc-build-ia32.sh ├── gcc-build-x64.sh ├── gcc.js ├── msvc-build-ia32.bat ├── msvc-build-x64.bat ├── msvc.js ├── package.json ├── pre-build.js ├── source-urls.json ├── src ├── curses.cc └── ptrwrap.h └── test └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | deps 10 | build 11 | 12 | pids 13 | logs 14 | results 15 | 16 | node_modules 17 | npm-debug.log 18 | .cproject 19 | .externalToolBuilders 20 | .project 21 | .settings 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # curses 3 | 4 | Bindings for the native curses library, a full featured console IO library. 5 | Compiles on Windows with Visual Studio 10 or Linux/UNIX with GCC toolchain. 6 | The curses library for the target system will automatically be downloaded 7 | and compiled into a static library on installation. 8 | 9 | On Windows the PDCurses library will be used and on Linux/UNIX it links against 10 | the ncurses library. 11 | 12 | 13 | ## Installation 14 | 15 | To install curses just type: 16 | 17 | ``` 18 | npm install curses 19 | ``` 20 | 21 | or install from GIT 22 | 23 | ``` 24 | git clone git://github.com/fresc81/node-curses curses 25 | cd curses 26 | npm install . 27 | ``` 28 | 29 | 30 | ## Rebuild 31 | 32 | If you have changed the C++ sources: 33 | 34 | ``` 35 | node-gyp rebuild 36 | ``` 37 | 38 | 39 | ## Usage 40 | 41 | ```javascript 42 | /* load curses */ 43 | var curses = require('curses') 44 | 45 | /* initialize top level window */ 46 | , stdwin = curses.initscr() 47 | 48 | /* color pair definitions */ 49 | , GLYPH_COLOR = 1 50 | , BORDER_COLOR = 2 51 | 52 | ; 53 | 54 | /* initialize color pairs (id, FG, BG) */ 55 | if (curses.has_colors()) { 56 | curses.start_color(); 57 | 58 | /* glyph color */ 59 | curses.init_pair(GLYPH_COLOR, curses.COLOR_GREEN, curses.COLOR_BLACK); 60 | 61 | /* border color */ 62 | curses.init_pair(BORDER_COLOR, curses.COLOR_WHITE, curses.COLOR_BLACK); 63 | 64 | } 65 | 66 | /* clear toplevel window and draw border */ 67 | curses.wattrset(stdwin, curses.color_pair(BORDER_COLOR)); 68 | curses.wclear(stdwin); 69 | curses.box(stdwin, 0, 0); 70 | curses.wrefresh(stdwin); 71 | 72 | /* create a subwindow */ 73 | var sub_height = 20 74 | , sub_width = 30 75 | , sub_top = 1 76 | , sub_left = 1 77 | , subwin = curses.subwin(stdwin, sub_height, sub_width, sub_top, sub_left) 78 | ; 79 | 80 | /* setup the subwindow's background and echo Hello world! into it */ 81 | curses.wbkgd(subwin, ' '.charCodeAt(0)|curses.color_pair(GLYPH_COLOR)|curses.A_REVERSE); 82 | curses.wclear(subwin); 83 | curses.box(subwin, 0, 0); 84 | curses.wmove(subwin, 1, 8); 85 | curses.wattrset(subwin, curses.color_pair(GLYPH_COLOR)); 86 | curses.waddstr(subwin, "Hello world!"); 87 | curses.wrefresh(subwin); 88 | 89 | /* wait for a keystroke */ 90 | curses.wgetch(subwin); 91 | 92 | /* reset terminal (never forget this) */ 93 | curses.endwin(); 94 | ``` 95 | 96 | ![hello.js](https://github.com/fresc81/node-curses/wiki/hello.png) 97 | 98 | Look at the bottom of [curses.cc](https://github.com/fresc81/node-curses/blob/master/src/curses.cc "src/curses") to 99 | see what already has been implemented. 100 | 101 | See the ncurses manual for descriptions of the functions. 102 | 103 | [ncurses HOWTO](http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/ "ncurses HOWTO") 104 | 105 | [ncurses manual](http://invisible-island.net/ncurses/man/ncurses.3x.html "ncurses manual") 106 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'target_defaults' : { 3 | 'default_configuration' : 'Release', 4 | 'configurations' : { 5 | 'Debug' : { 6 | 'defines' : ['DEBUG', '_DEBUG'], 7 | }, 8 | 'Release' : { 9 | 'defines' : ['NDEBUG'], 10 | } 11 | }, 12 | 'msvs_settings' : { 13 | 'VCLinkerTool' : { 14 | 'GenerateDebugInformation' : 'true', 15 | }, 16 | }, 17 | 'conditions' : [ 18 | [ 19 | 'OS=="win"', 20 | { 21 | 'defines' : ['PDC_WIDE'], 22 | 'include_dirs' : [ 23 | 'deps/PDCurses-3.4' 24 | ], 25 | 'libraries' : [ 26 | '../deps/PDCurses-3.4/win32/pdcurses.lib', 27 | '../deps/PDCurses-3.4/win32/panel.lib' 28 | ] 29 | } 30 | ], 31 | [ 32 | 'OS!="win"', 33 | { 34 | 'include_dirs' : [ 35 | 'deps/ncurses-5.7/include' 36 | ], 37 | 'ldflags' : [ 38 | '-L../deps/ncurses-5.7/lib' 39 | ], 40 | 'libraries' : [ 41 | '-lncursestw', 42 | '-lpaneltw' 43 | ] 44 | } 45 | ] 46 | ], 47 | }, 48 | 49 | 'targets' : [ 50 | { 51 | 'target_name': 'curses', 52 | 'sources': [ 53 | 'src/curses.cc' 54 | ] 55 | } 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /curses.js: -------------------------------------------------------------------------------- 1 | 2 | /* this module loads the native curses module */ 3 | 4 | /* --- SETUP DEBUGGING --- */ 5 | var DEBUG = false; 6 | 7 | /* --- NATIVE MODULE --- */ 8 | exports = module.exports = require('./build/'+(DEBUG?'Debug':'Release')+'/curses'); 9 | exports.CURSES_DEBUG = DEBUG; 10 | -------------------------------------------------------------------------------- /example/hello.js: -------------------------------------------------------------------------------- 1 | /* load curses */ 2 | var curses = require('../curses') 3 | 4 | /* initialize top level window */ 5 | , stdwin = curses.initscr() 6 | 7 | /* color pair definitions */ 8 | , GLYPH_COLOR = 1 9 | , BORDER_COLOR = 2 10 | 11 | ; 12 | 13 | /* initialize color pairs (id, FG, BG) */ 14 | if (curses.has_colors()) { 15 | curses.start_color(); 16 | 17 | /* glyph color */ 18 | curses.init_pair(GLYPH_COLOR, curses.COLOR_GREEN, curses.COLOR_BLACK); 19 | 20 | /* border color */ 21 | curses.init_pair(BORDER_COLOR, curses.COLOR_WHITE, curses.COLOR_BLACK); 22 | 23 | } 24 | 25 | /* clear toplevel window and draw border */ 26 | curses.wattrset(stdwin, curses.color_pair(BORDER_COLOR)); 27 | curses.wclear(stdwin); 28 | curses.box(stdwin, 0, 0); 29 | curses.wrefresh(stdwin); 30 | 31 | /* create a subwindow */ 32 | var sub_height = 20 33 | , sub_width = 30 34 | , sub_top = 1 35 | , sub_left = 1 36 | , subwin = curses.subwin(stdwin, sub_height, sub_width, sub_top, sub_left) 37 | ; 38 | 39 | /* setup the subwindow's background and echo Hello world! into it */ 40 | curses.wbkgd(subwin, ' '.charCodeAt(0)|curses.color_pair(GLYPH_COLOR)|curses.A_REVERSE); 41 | curses.wclear(subwin); 42 | curses.box(subwin, 0, 0); 43 | curses.wmove(subwin, 1, 8); 44 | curses.wattrset(subwin, curses.color_pair(GLYPH_COLOR)); 45 | curses.waddstr(subwin, "Hello world!"); 46 | curses.wrefresh(subwin); 47 | 48 | /* wait for a keystroke */ 49 | curses.wgetch(subwin); 50 | 51 | /* reset terminal (never forget this) */ 52 | curses.endwin(); 53 | -------------------------------------------------------------------------------- /example/matrix.js: -------------------------------------------------------------------------------- 1 | 2 | /***********************\ 3 | * ENTER THE MATRIX 8-) * 4 | \***********************/ 5 | 6 | var curses = require('../curses') 7 | 8 | /* top level window */ 9 | , stdwin = curses.initscr() 10 | 11 | /* get screen size */ 12 | , maxyx = curses.getmaxyx(stdwin) 13 | 14 | ; 15 | 16 | /* initialize color pairs (id, FG, BG) */ 17 | if (curses.has_colors()) { 18 | curses.start_color(); 19 | 20 | /* glyph color */ 21 | curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK); 22 | 23 | /* border color */ 24 | curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK); 25 | 26 | } 27 | 28 | /* draw border */ 29 | curses.wattrset(stdwin, curses.color_pair(2)); 30 | curses.wclear(stdwin); 31 | curses.box(stdwin, 0, 0); 32 | curses.wrefresh(stdwin); 33 | 34 | /* draw bands */ 35 | maxyx.x -= 2; 36 | maxyx.y -= 2; 37 | var subwins = new Array(maxyx.x); 38 | for (var i=0; i=0.1.13" 8 | }, 9 | "scripts": { 10 | "install": "node ./pre-build.js", 11 | "postinstall": "node-gyp rebuild --release", 12 | "test": "node ./test/test.js" 13 | }, 14 | "keywords": [ 15 | "curses", 16 | "console", 17 | "IO", 18 | "window", 19 | "panel", 20 | "UI", 21 | "color", 22 | "terminal" 23 | ], 24 | "repository": "git://github.com/fresc81/node-curses.git", 25 | "author": "Paul Bottin", 26 | "license": "BSD" 27 | } 28 | -------------------------------------------------------------------------------- /pre-build.js: -------------------------------------------------------------------------------- 1 | 2 | /* downloads and unpacks a curses library then builds a static lib */ 3 | 4 | var fs = require('fs') 5 | , os = require('os') 6 | , tar = require('tar') 7 | , url = require('url') 8 | , path = require('path') 9 | , http = require('http') 10 | , zlib = require('zlib') 11 | 12 | /* the operating system ['win32'|'linux'] */ 13 | , OS_PLATFORM = os.platform() 14 | 15 | /* the URL of the sources to build */ 16 | , SOURCE_URL = require('./source-urls')[OS_PLATFORM] 17 | 18 | /* the source directory without the ./deps/ prefix */ 19 | , TARGET_DIR = path.basename(url.parse(SOURCE_URL).pathname, '.tar.gz') 20 | 21 | /* show a fancy download progress bar*/ 22 | , PROGRESS_BAR = '0% 50% 100%\n'+ 23 | '| . . . . | . . . . |' 24 | 25 | /* extracts the contents of the tarball stream to ./deps/[TARGET_DIR] */ 26 | , tarExtract = tar.Extract(path.resolve(__dirname, 'deps')) 27 | 28 | /* unzips the gzip stream */ 29 | , gzExtract = zlib.createUnzip() 30 | 31 | /* load the module that performs the build in a platform specific manner */ 32 | , buildTask = require( (OS_PLATFORM==='win32') ? './msvc' : './gcc' ) 33 | 34 | ; 35 | 36 | /* error out on existing deps folder... */ 37 | if (fs.existsSync(path.resolve(__dirname, 'deps'))) { 38 | console.log("a ./deps folder was found, stopping download so nothing gets overwritten"); 39 | process.exit(1); 40 | } 41 | 42 | /* DOWNLOAD DEPENDENCIES ... */ 43 | console.log("download and unpack '%s' to folder '%s'...", SOURCE_URL, path.resolve(__dirname, 'deps', TARGET_DIR)); 44 | http 45 | . get(SOURCE_URL, function (res) { 46 | 47 | var length = Number(res.headers['content-length']) 48 | , bytesRead = 0 49 | , percent = 0 50 | , diff = 0 51 | ; 52 | 53 | console.log("filesize: %s bytes", length); 54 | console.log("\n%s", PROGRESS_BAR); 55 | process.stdout.write('#'); 56 | res 57 | . on('data', function (chunk) { 58 | 59 | bytesRead += chunk.length; 60 | var newPercent = Math.round(bytesRead/length*100); 61 | 62 | if (percent != newPercent) { 63 | diff += newPercent-percent; 64 | percent = newPercent; 65 | 66 | while (diff >= 5) { 67 | process.stdout.write('#'); 68 | diff -= 5; 69 | } 70 | 71 | } 72 | 73 | }) 74 | . pipe(gzExtract) 75 | . pipe(tarExtract) 76 | . on('end', function () { 77 | 78 | console.log("\ndownload successful"); 79 | 80 | /* BUILD DEPENDENCIES ... */ 81 | buildTask(function (err) { 82 | if (err) { 83 | console.log("ERROR: %s", err); 84 | process.exit(1); 85 | } else { 86 | console.log("sucessfully built dependencies"); 87 | process.exit(0); 88 | } 89 | }); 90 | 91 | }) 92 | ; 93 | 94 | }) 95 | . on('error', function (err) { 96 | 97 | console.log("\ndownload failed: %s", err); 98 | process.exit(1); 99 | 100 | }) 101 | ; 102 | -------------------------------------------------------------------------------- /source-urls.json: -------------------------------------------------------------------------------- 1 | { 2 | "win32" : "http://switch.dl.sourceforge.net/project/pdcurses/pdcurses/3.4/PDCurses-3.4.tar.gz", 3 | "linux" : "http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz", 4 | "mac" : "http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz", 5 | "solaris" : "http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz" 6 | } -------------------------------------------------------------------------------- /src/curses.cc: -------------------------------------------------------------------------------- 1 | /* Public Domain */ 2 | 3 | #ifndef BUILDING_NODE_EXTENSION 4 | # define BUILDING_NODE_EXTENSION 5 | #endif 6 | 7 | #include 8 | #include 9 | 10 | // the windows header already defines MOUSE_MOVED 11 | #ifdef MOUSE_MOVED 12 | # undef MOUSE_MOVED 13 | #endif 14 | 15 | #include 16 | #include 17 | 18 | #include "ptrwrap.h" 19 | 20 | using namespace v8; 21 | 22 | 23 | // checks if the number of arguments is n 24 | #define NODE_ARGS(n) \ 25 | if (args.Length() != n) { \ 26 | ThrowException(Exception::TypeError(String::New("Wrong number of arguments."))); \ 27 | return scope.Close(Undefined()); \ 28 | } \ 29 | 30 | // checks if the i'th argument is of type t 31 | #define NODE_ARG(i, t) \ 32 | if (!args[i]->Is##t()) { \ 33 | ThrowException(Exception::TypeError(String::New("Wrong type for argument " #i ", expected " #t "."))); \ 34 | return scope.Close(Undefined()); \ 35 | } \ 36 | 37 | // checks if the i'th argument is pointer to t 38 | #define NODE_PARG(i, t) \ 39 | if ( \ 40 | !args[i]->IsObject() || \ 41 | !PtrWrap< t >::InstanceOf(args[i]) \ 42 | ) { \ 43 | ThrowException(Exception::TypeError(String::New("Wrong type for argument " #i ", expected " #t "."))); \ 44 | return scope.Close(Undefined()); \ 45 | } \ 46 | 47 | #define CAST_INT8(i) static_cast( i ) 48 | #define CAST_INT16(i) static_cast( i ) 49 | #define CAST_INT32(i) static_cast( i ) 50 | #define CAST_INT64(i) static_cast( i ) 51 | 52 | #define CAST_CHTYPE(c) static_cast( c ) 53 | #define CAST_BOOL(b) static_cast( b ) 54 | 55 | #define CAST_PWINDOW(w) PtrWrap::Unwrap( w ) 56 | #define CAST_PSCREEN(s) PtrWrap::Unwrap( s ) 57 | 58 | #define CAST_POINTER(t, p) PtrWrap::New( p ) 59 | 60 | PTRWRAP_DECLARE(WINDOW) 61 | PTRWRAP_DECLARE(SCREEN) 62 | 63 | Handle node_color_pair(const Arguments& args) { 64 | HandleScope scope; 65 | NODE_ARGS(1) 66 | NODE_ARG(0, Number) 67 | int32_t n = CAST_INT32(args[0]->Int32Value()); 68 | int32_t result = COLOR_PAIR(n); 69 | return scope.Close(Int32::New( result )); 70 | } 71 | 72 | Handle node_addch(const Arguments& args) { 73 | HandleScope scope; 74 | NODE_ARGS(1) 75 | NODE_ARG(0, Number) 76 | chtype ch = CAST_CHTYPE(args[0]->Int32Value()); 77 | int32_t result = addch( ch ); 78 | return scope.Close(Int32::New( result )); 79 | } 80 | 81 | Handle node_box(const Arguments& args) { 82 | HandleScope scope; 83 | NODE_ARGS(3) 84 | NODE_PARG(0, WINDOW) 85 | NODE_ARG(1, Number) 86 | NODE_ARG(2, Number) 87 | WINDOW* win = CAST_PWINDOW(args[0]); 88 | chtype v = CAST_CHTYPE(args[1]->Int32Value()); 89 | chtype h = CAST_CHTYPE(args[2]->Int32Value()); 90 | int32_t result = box( win, v, h ); 91 | return scope.Close(Int32::New( result )); 92 | } 93 | 94 | Handle node_cbreak(const Arguments& args) { 95 | HandleScope scope; 96 | NODE_ARGS(0) 97 | int32_t result = cbreak( ); 98 | return scope.Close(Int32::New( result )); 99 | } 100 | 101 | Handle node_delwin(const Arguments& args) { 102 | HandleScope scope; 103 | NODE_ARGS(1) 104 | NODE_PARG(0, WINDOW) 105 | WINDOW* win = CAST_PWINDOW(args[0]); 106 | int32_t result = delwin( win ); 107 | return scope.Close(Int32::New( result )); 108 | } 109 | 110 | Handle node_derwin(const Arguments& args) { 111 | HandleScope scope; 112 | NODE_ARGS(5) 113 | NODE_PARG(0, WINDOW) 114 | NODE_ARG(1, Number) 115 | NODE_ARG(2, Number) 116 | NODE_ARG(3, Number) 117 | NODE_ARG(4, Number) 118 | WINDOW* win = CAST_PWINDOW(args[0]); 119 | chtype h = CAST_CHTYPE(args[1]->Int32Value()); 120 | chtype w = CAST_CHTYPE(args[2]->Int32Value()); 121 | chtype y = CAST_CHTYPE(args[3]->Int32Value()); 122 | chtype x = CAST_CHTYPE(args[4]->Int32Value()); 123 | WINDOW* result = derwin( win, h, w, y, x ); 124 | return scope.Close( CAST_POINTER(WINDOW, result) ); 125 | } 126 | 127 | Handle node_doupdate(const Arguments& args) { 128 | HandleScope scope; 129 | NODE_ARGS(0) 130 | int32_t result = doupdate( ); 131 | return scope.Close(Number::New( result )); 132 | } 133 | 134 | Handle node_dupwin(const Arguments& args) { 135 | HandleScope scope; 136 | NODE_ARGS(1) 137 | NODE_PARG(0, WINDOW) 138 | WINDOW* win = CAST_PWINDOW(args[0]); 139 | WINDOW* result = dupwin( win ); 140 | return scope.Close(CAST_POINTER(WINDOW, result)); 141 | } 142 | 143 | Handle node_echo(const Arguments& args) { 144 | HandleScope scope; 145 | NODE_ARGS(0) 146 | int32_t result = echo( ); 147 | return scope.Close(Int32::New( result )); 148 | } 149 | 150 | Handle node_endwin(const Arguments& args) { 151 | HandleScope scope; 152 | NODE_ARGS(0) 153 | int32_t result = endwin( ); 154 | return scope.Close(Int32::New( result )); 155 | } 156 | 157 | Handle node_getmaxyx(const Arguments& args) { 158 | HandleScope scope; 159 | NODE_ARGS(1) 160 | NODE_PARG(0, WINDOW) 161 | WINDOW* win = CAST_PWINDOW(args[0]); 162 | int32_t y = 0, 163 | x = 0; 164 | getmaxyx( win, y, x ); 165 | Local result = Object::New(); 166 | result->Set( 167 | String::NewSymbol("y"), 168 | Int32::New(y) 169 | ); 170 | result->Set( 171 | String::NewSymbol("x"), 172 | Int32::New(x) 173 | ); 174 | return scope.Close(result); 175 | } 176 | 177 | Handle node_has_colors(const Arguments& args) { 178 | HandleScope scope; 179 | NODE_ARGS(0) 180 | bool result = (has_colors() != 0); 181 | return scope.Close(Boolean::New( result )); 182 | } 183 | 184 | Handle node_whline(const Arguments& args) { 185 | HandleScope scope; 186 | NODE_ARGS(3) 187 | NODE_PARG(0, WINDOW) 188 | NODE_ARG(1, Number) 189 | NODE_ARG(2, Number) 190 | WINDOW* win = CAST_PWINDOW(args[0]); 191 | chtype ch = CAST_CHTYPE(args[1]->Int32Value()); 192 | int32_t n = CAST_INT32(args[2]->Int32Value()); 193 | int32_t result = whline( win, ch, n ); 194 | return scope.Close(Int32::New( result )); 195 | } 196 | 197 | Handle node_init_color(const Arguments& args) { 198 | HandleScope scope; 199 | NODE_ARGS(4) 200 | NODE_ARG(0, Number) 201 | NODE_ARG(1, Number) 202 | NODE_ARG(2, Number) 203 | NODE_ARG(3, Number) 204 | int16_t a = CAST_INT16(args[0]->Int32Value()); 205 | int16_t b = CAST_INT16(args[1]->Int32Value()); 206 | int16_t c = CAST_INT16(args[2]->Int32Value()); 207 | int16_t d = CAST_INT16(args[3]->Int32Value()); 208 | int result = init_color( a, b, c, d ); 209 | return scope.Close(Int32::New( result )); 210 | } 211 | 212 | Handle node_init_pair(const Arguments& args) { 213 | HandleScope scope; 214 | NODE_ARGS(3) 215 | NODE_ARG(0, Number) 216 | NODE_ARG(1, Number) 217 | NODE_ARG(2, Number) 218 | int16_t a = CAST_INT16(args[0]->Int32Value()); 219 | int16_t b = CAST_INT16(args[1]->Int32Value()); 220 | int16_t c = CAST_INT16(args[2]->Int32Value()); 221 | int result = init_pair( a, b, c ); 222 | return scope.Close(Int32::New( result )); 223 | } 224 | 225 | Handle node_initscr(const Arguments& args) { 226 | HandleScope scope; 227 | NODE_ARGS(0) 228 | WINDOW* result = initscr( ); 229 | return scope.Close(CAST_POINTER(WINDOW, result)); 230 | } 231 | 232 | Handle node_keyname(const Arguments& args) { 233 | HandleScope scope; 234 | NODE_ARGS(1) 235 | NODE_ARG(0, Number) 236 | int32_t k = CAST_INT32(args[0]->Int32Value()); 237 | char* result = keyname( k ); 238 | return scope.Close(String::New( result )); 239 | } 240 | 241 | Handle node_keypad(const Arguments& args) { 242 | HandleScope scope; 243 | NODE_ARGS(2) 244 | NODE_PARG(0, WINDOW) 245 | NODE_ARG(1, Boolean) 246 | WINDOW* win = CAST_PWINDOW(args[0]); 247 | bool b = CAST_BOOL(args[1]->BooleanValue()); 248 | int32_t result = keypad( win, b ); 249 | return scope.Close(Int32::New( result )); 250 | } 251 | 252 | Handle node_killchar(const Arguments& args) { 253 | HandleScope scope; 254 | NODE_ARGS(0) 255 | char result = killchar( ); 256 | return scope.Close(Int32::New( result )); 257 | } 258 | 259 | Handle node_leaveok(const Arguments& args) { 260 | HandleScope scope; 261 | NODE_ARGS(2) 262 | NODE_PARG(0, WINDOW) 263 | NODE_ARG(1, Boolean) 264 | WINDOW* win = CAST_PWINDOW(args[0]); 265 | bool b = CAST_BOOL(args[1]->BooleanValue()); 266 | int32_t result = leaveok( win, b ); 267 | return scope.Close(Int32::New( result )); 268 | } 269 | 270 | Handle node_longname(const Arguments& args) { 271 | HandleScope scope; 272 | NODE_ARGS(0) 273 | char* result = longname( ); 274 | return scope.Close(String::New( result )); 275 | } 276 | 277 | Handle node_meta(const Arguments& args) { 278 | HandleScope scope; 279 | NODE_ARGS(2) 280 | NODE_PARG(0, WINDOW) 281 | NODE_ARG(1, Boolean) 282 | WINDOW* win = CAST_PWINDOW(args[0]); 283 | bool b = CAST_BOOL(args[1]->BooleanValue()); 284 | int32_t result = meta( win, b ); 285 | return scope.Close(Int32::New( result )); 286 | } 287 | 288 | Handle node_newpad(const Arguments& args) { 289 | HandleScope scope; 290 | NODE_ARGS(2) 291 | NODE_ARG(0, Number) 292 | NODE_ARG(1, Number) 293 | int32_t h = CAST_INT32(args[0]->Int32Value()); 294 | int32_t w = CAST_INT32(args[1]->Int32Value()); 295 | WINDOW* result = newpad( h, w ); 296 | return scope.Close(CAST_POINTER(WINDOW, result)); 297 | } 298 | 299 | Handle node_newwin(const Arguments& args) { 300 | HandleScope scope; 301 | NODE_ARGS(4) 302 | NODE_ARG(0, Number) 303 | NODE_ARG(1, Number) 304 | NODE_ARG(2, Number) 305 | NODE_ARG(3, Number) 306 | int32_t h = CAST_INT32(args[0]->Int32Value()); 307 | int32_t w = CAST_INT32(args[1]->Int32Value()); 308 | int32_t y = CAST_INT32(args[2]->Int32Value()); 309 | int32_t x = CAST_INT32(args[3]->Int32Value()); 310 | WINDOW* result = newwin( h, w, y, x ); 311 | return scope.Close(CAST_POINTER(WINDOW, result)); 312 | } 313 | 314 | Handle node_nocbreak(const Arguments& args) { 315 | HandleScope scope; 316 | NODE_ARGS(0) 317 | int32_t result = nocbreak( ); 318 | return scope.Close(Int32::New( result )); 319 | } 320 | 321 | Handle node_nodelay(const Arguments& args) { 322 | HandleScope scope; 323 | NODE_ARGS(2) 324 | NODE_PARG(0, WINDOW) 325 | NODE_ARG(1, Boolean) 326 | WINDOW* win = CAST_PWINDOW(args[0]); 327 | bool b = CAST_BOOL(args[1]->BooleanValue()); 328 | int32_t result = nodelay( win, b ); 329 | return scope.Close(Int32::New( result )); 330 | } 331 | 332 | Handle node_noecho(const Arguments& args) { 333 | HandleScope scope; 334 | NODE_ARGS(0) 335 | int32_t result = noecho( ); 336 | return scope.Close(Int32::New( result )); 337 | } 338 | 339 | Handle node_scrollok(const Arguments& args) { 340 | HandleScope scope; 341 | NODE_ARGS(2) 342 | NODE_PARG(0, WINDOW) 343 | NODE_ARG(1, Boolean) 344 | WINDOW* win = CAST_PWINDOW(args[0]); 345 | bool b = CAST_BOOL(args[1]->BooleanValue()); 346 | int32_t result = scrollok( win, b ); 347 | return scope.Close(Int32::New( result )); 348 | } 349 | 350 | Handle node_start_color(const Arguments& args) { 351 | HandleScope scope; 352 | NODE_ARGS(0) 353 | int32_t result = start_color( ); 354 | return scope.Close(Int32::New( result )); 355 | } 356 | 357 | Handle node_subpad(const Arguments& args) { 358 | HandleScope scope; 359 | NODE_ARGS(5) 360 | NODE_PARG(0, WINDOW) 361 | NODE_ARG(1, Number) 362 | NODE_ARG(2, Number) 363 | NODE_ARG(3, Number) 364 | NODE_ARG(4, Number) 365 | WINDOW* win = CAST_PWINDOW(args[0]); 366 | int32_t h = CAST_INT32(args[1]->Int32Value()); 367 | int32_t w = CAST_INT32(args[2]->Int32Value()); 368 | int32_t y = CAST_INT32(args[3]->Int32Value()); 369 | int32_t x = CAST_INT32(args[4]->Int32Value()); 370 | WINDOW* result = subpad( win, h, w, y, x ); 371 | return scope.Close(CAST_POINTER(WINDOW, result)); 372 | } 373 | 374 | Handle node_subwin(const Arguments& args) { 375 | HandleScope scope; 376 | NODE_ARGS(5) 377 | NODE_PARG(0, WINDOW) 378 | NODE_ARG(1, Number) 379 | NODE_ARG(2, Number) 380 | NODE_ARG(3, Number) 381 | NODE_ARG(4, Number) 382 | WINDOW* win = CAST_PWINDOW(args[0]); 383 | int32_t h = CAST_INT32(args[1]->Int32Value()); 384 | int32_t w = CAST_INT32(args[2]->Int32Value()); 385 | int32_t y = CAST_INT32(args[3]->Int32Value()); 386 | int32_t x = CAST_INT32(args[4]->Int32Value()); 387 | WINDOW* result = subwin( win, h, w, y, x ); 388 | return scope.Close(CAST_POINTER(WINDOW, result)); 389 | } 390 | 391 | Handle node_waddchnstr(const Arguments& args) { 392 | HandleScope scope; 393 | NODE_ARGS(3) 394 | NODE_PARG(0, WINDOW) 395 | NODE_ARG(1, String) 396 | NODE_ARG(2, Number) 397 | WINDOW *win = CAST_PWINDOW(args[0]); 398 | String::Value str(args[1]); 399 | int32_t n = CAST_INT32(args[2]->Int32Value()); 400 | int32_t result = waddchnstr( win, (chtype*) *str, n ); 401 | return scope.Close(Int32::New( result )); 402 | } 403 | 404 | Handle node_waddchstr(const Arguments& args) { 405 | HandleScope scope; 406 | NODE_ARGS(2) 407 | NODE_PARG(0, WINDOW) 408 | NODE_ARG(1, String) 409 | WINDOW* win = CAST_PWINDOW(args[0]); 410 | String::Value str(args[1]); 411 | int32_t result = waddchstr( win, (chtype*) *str ); 412 | return scope.Close(Int32::New( result )); 413 | } 414 | 415 | Handle node_waddch(const Arguments& args) { 416 | HandleScope scope; 417 | NODE_ARGS(2) 418 | NODE_PARG(0, WINDOW) 419 | NODE_ARG(1, Number) 420 | WINDOW* win = CAST_PWINDOW(args[0]); 421 | chtype ch = CAST_CHTYPE(args[1]->Int32Value()); 422 | int32_t result = waddch( win, ch ); 423 | return scope.Close(Int32::New( result )); 424 | } 425 | 426 | Handle node_waddnstr(const Arguments& args) { 427 | HandleScope scope; 428 | NODE_ARGS(3) 429 | NODE_PARG(0, WINDOW) 430 | NODE_ARG(1, String) 431 | NODE_ARG(2, Number) 432 | WINDOW *win = CAST_PWINDOW(args[0]); 433 | String::Utf8Value str(args[1]); 434 | int32_t n = CAST_INT32(args[2]->Int32Value()); 435 | int32_t result = waddnstr( win, *str, n ); 436 | return scope.Close(Int32::New( result )); 437 | } 438 | 439 | Handle node_waddstr(const Arguments& args) { 440 | HandleScope scope; 441 | NODE_ARGS(2) 442 | NODE_PARG(0, WINDOW) 443 | NODE_ARG(1, String) 444 | WINDOW* win = CAST_PWINDOW(args[0]); 445 | String::Utf8Value str(args[1]); 446 | int32_t result = waddstr( win, (char*) *str ); 447 | return scope.Close(Int32::New( result )); 448 | } 449 | 450 | Handle node_wattroff(const Arguments& args) { 451 | HandleScope scope; 452 | NODE_ARGS(2) 453 | NODE_PARG(0, WINDOW) 454 | NODE_ARG(1, Number) 455 | WINDOW* win = CAST_PWINDOW(args[0]); 456 | chtype ch = CAST_CHTYPE(args[1]->Int32Value()); 457 | int32_t result = wattroff( win, ch ); 458 | return scope.Close(Int32::New( result )); 459 | } 460 | 461 | Handle node_wattron(const Arguments& args) { 462 | HandleScope scope; 463 | NODE_ARGS(2) 464 | NODE_PARG(0, WINDOW) 465 | NODE_ARG(1, Number) 466 | WINDOW* win = CAST_PWINDOW(args[0]); 467 | chtype ch = CAST_CHTYPE(args[1]->Int32Value()); 468 | int32_t result = wattron( win, ch ); 469 | return scope.Close(Int32::New( result )); 470 | } 471 | 472 | Handle node_wattrset(const Arguments& args) { 473 | HandleScope scope; 474 | NODE_ARGS(2) 475 | NODE_PARG(0, WINDOW) 476 | NODE_ARG(1, Number) 477 | WINDOW* win = CAST_PWINDOW(args[0]); 478 | chtype ch = CAST_CHTYPE(args[1]->Int32Value()); 479 | int32_t result = wattrset( win, ch ); 480 | return scope.Close(Int32::New( result )); 481 | } 482 | 483 | Handle node_wbkgd(const Arguments& args) { 484 | HandleScope scope; 485 | NODE_ARGS(2) 486 | NODE_PARG(0, WINDOW) 487 | NODE_ARG(1, Number) 488 | WINDOW* win = CAST_PWINDOW(args[0]); 489 | chtype ch = CAST_CHTYPE(args[1]->Int32Value()); 490 | int32_t result = wbkgd( win, ch ); 491 | return scope.Close(Int32::New( result )); 492 | } 493 | 494 | Handle node_wclear(const Arguments& args) { 495 | HandleScope scope; 496 | NODE_ARGS(1) 497 | NODE_PARG(0, WINDOW) 498 | WINDOW* win = CAST_PWINDOW(args[0]); 499 | int32_t result = wclear( win ); 500 | return scope.Close(Int32::New( result )); 501 | } 502 | 503 | Handle node_wdelch(const Arguments& args) { 504 | HandleScope scope; 505 | NODE_ARGS(1) 506 | NODE_PARG(0, WINDOW) 507 | WINDOW* win = CAST_PWINDOW(args[0]); 508 | int32_t result = wdelch( win ); 509 | return scope.Close(Int32::New( result )); 510 | } 511 | 512 | Handle node_wdeleteln(const Arguments& args) { 513 | HandleScope scope; 514 | NODE_ARGS(1) 515 | NODE_PARG(0, WINDOW) 516 | WINDOW* win = CAST_PWINDOW(args[0]); 517 | int32_t result = wdeleteln( win ); 518 | return scope.Close(Int32::New( result )); 519 | } 520 | 521 | Handle node_wechochar(const Arguments& args) { 522 | HandleScope scope; 523 | NODE_ARGS(2) 524 | NODE_PARG(0, WINDOW) 525 | NODE_ARG(1, Number) 526 | WINDOW* win = CAST_PWINDOW(args[0]); 527 | chtype c = CAST_CHTYPE(args[0]->Int32Value()); 528 | int32_t result = wechochar( win, c ); 529 | return scope.Close(Int32::New( result )); 530 | } 531 | 532 | Handle node_werase(const Arguments& args) { 533 | HandleScope scope; 534 | NODE_ARGS(1) 535 | NODE_PARG(0, WINDOW) 536 | WINDOW* win = CAST_PWINDOW(args[0]); 537 | int32_t result = werase( win ); 538 | return scope.Close(Int32::New( result )); 539 | } 540 | 541 | Handle node_wgetch(const Arguments& args) { 542 | HandleScope scope; 543 | NODE_ARGS(1) 544 | NODE_PARG(0, WINDOW) 545 | WINDOW* win = CAST_PWINDOW(args[0]); 546 | int32_t result = wgetch( win ); 547 | return scope.Close(Int32::New( result )); 548 | } 549 | 550 | Handle node_wmove(const Arguments& args) { 551 | HandleScope scope; 552 | NODE_ARGS(3) 553 | NODE_PARG(0, WINDOW) 554 | NODE_ARG(1, Number) 555 | NODE_ARG(2, Number) 556 | WINDOW* win = CAST_PWINDOW(args[0]); 557 | int32_t y = CAST_INT32(args[1]->Int32Value()); 558 | int32_t x = CAST_INT32(args[2]->Int32Value()); 559 | int32_t result = wmove( win, y, x ); 560 | return scope.Close(Int32::New( result )); 561 | } 562 | 563 | Handle node_wnoutrefresh(const Arguments& args) { 564 | HandleScope scope; 565 | NODE_ARGS(1) 566 | NODE_PARG(0, WINDOW) 567 | WINDOW* win = CAST_PWINDOW(args[0]); 568 | int32_t result = wnoutrefresh( win ); 569 | return scope.Close(Int32::New( result )); 570 | } 571 | 572 | Handle node_wrefresh(const Arguments& args) { 573 | HandleScope scope; 574 | NODE_ARGS(1) 575 | NODE_PARG(0, WINDOW) 576 | WINDOW* win = CAST_PWINDOW(args[0]); 577 | int32_t result = wrefresh( win ); 578 | return scope.Close(Int32::New( result )); 579 | } 580 | 581 | Handle node_wscrl(const Arguments& args) { 582 | HandleScope scope; 583 | NODE_ARGS(2) 584 | NODE_PARG(0, WINDOW) 585 | NODE_ARG(1, Number) 586 | WINDOW* win = CAST_PWINDOW(args[0]); 587 | int32_t i = CAST_INT32(args[1]->Int32Value()); 588 | int32_t result = wscrl( win, i ); 589 | return scope.Close(Int32::New( result )); 590 | } 591 | 592 | Handle node_wvline(const Arguments& args) { 593 | HandleScope scope; 594 | NODE_ARGS(3) 595 | NODE_PARG(0, WINDOW) 596 | NODE_ARG(1, Number) 597 | NODE_ARG(2, Number) 598 | WINDOW* win = CAST_PWINDOW(args[0]); 599 | chtype ch = CAST_CHTYPE(args[1]->Int32Value()); 600 | int32_t n = CAST_INT32(args[2]->Int32Value()); 601 | int32_t result = wvline( win, ch, n ); 602 | return scope.Close(Int32::New( result )); 603 | } 604 | 605 | Handle node_curses_version(const Arguments& args) { 606 | HandleScope scope; 607 | NODE_ARGS(0) 608 | const char * result = curses_version(); 609 | return scope.Close(String::New( result )); 610 | } 611 | 612 | Handle node_assume_default_colors(const Arguments& args) { 613 | HandleScope scope; 614 | NODE_ARGS(2) 615 | NODE_ARG(0, Number) 616 | NODE_ARG(1, Number) 617 | int32_t a = CAST_INT32(args[0]->Int32Value()); 618 | int32_t b = CAST_INT32(args[1]->Int32Value()); 619 | int32_t result = assume_default_colors(a, b); 620 | return scope.Close(Int32::New( result )); 621 | } 622 | 623 | Handle node_has_key(const Arguments& args) { 624 | HandleScope scope; 625 | NODE_ARGS(1) 626 | NODE_ARG(0, Number) 627 | int32_t k = CAST_INT32(args[0]->Int32Value()); 628 | bool result = has_key(k)!=0; 629 | return scope.Close(Boolean::New( result )); 630 | } 631 | 632 | Handle node_use_default_colors(const Arguments& args) { 633 | HandleScope scope; 634 | NODE_ARGS(0) 635 | int32_t result = use_default_colors(); 636 | return scope.Close(Int32::New( result )); 637 | } 638 | 639 | Handle node_wresize(const Arguments& args) { 640 | HandleScope scope; 641 | NODE_ARGS(3) 642 | NODE_PARG(0, WINDOW) 643 | NODE_ARG(1, Number) 644 | NODE_ARG(2, Number) 645 | WINDOW* win = CAST_PWINDOW(args[0]); 646 | int32_t h = CAST_INT32(args[1]->Int32Value()); 647 | int32_t w = CAST_INT32(args[2]->Int32Value()); 648 | int32_t result = wresize(win, h, w); 649 | return scope.Close(Int32::New( result )); 650 | } 651 | 652 | #ifdef NODE_CURSES_WINDOWS 653 | 654 | Handle node_mouse_set(const Arguments& args) { 655 | HandleScope scope; 656 | NODE_ARGS(2) 657 | NODE_ARG(0, Number) 658 | NODE_ARG(1, Number) 659 | int32_t fh = CAST_INT32(args[0]->IntegerValue()); 660 | int32_t fl = CAST_INT32(args[1]->IntegerValue()); 661 | uint64_t f = ((uint64_t)fl) & (((uint64_t)fh) << 32); 662 | int32_t result = mouse_set(static_cast(f)); 663 | return scope.Close(Int32::New(result)); 664 | } 665 | 666 | Handle node_mouse_on(const Arguments& args) { 667 | HandleScope scope; 668 | NODE_ARGS(2) 669 | NODE_ARG(0, Number) 670 | NODE_ARG(1, Number) 671 | int32_t fh = CAST_INT32(args[0]->IntegerValue()); 672 | int32_t fl = CAST_INT32(args[1]->IntegerValue()); 673 | uint64_t f = ((uint64_t)fl) & (((uint64_t)fh) << 32); 674 | int32_t result = mouse_on(static_cast(f)); 675 | return scope.Close(Int32::New(result)); 676 | } 677 | 678 | Handle node_mouse_off(const Arguments& args) { 679 | HandleScope scope; 680 | NODE_ARGS(2) 681 | NODE_ARG(0, Number) 682 | NODE_ARG(1, Number) 683 | int32_t fh = CAST_INT32(args[0]->IntegerValue()); 684 | int32_t fl = CAST_INT32(args[1]->IntegerValue()); 685 | uint64_t f = ((uint64_t)fl) & (((uint64_t)fh) << 32); 686 | int32_t result = mouse_off(static_cast(f)); 687 | return scope.Close(Int32::New(result)); 688 | } 689 | 690 | Handle node_request_mouse_pos(const Arguments& args) { 691 | HandleScope scope; 692 | NODE_ARGS(0) 693 | int32_t result = request_mouse_pos(); 694 | return scope.Close(Int32::New(result)); 695 | } 696 | 697 | Handle node_map_button(const Arguments& args) { 698 | HandleScope scope; 699 | NODE_ARGS(2) 700 | NODE_ARG(0, Number) 701 | NODE_ARG(1, Number) 702 | int32_t fh = CAST_INT32(args[0]->IntegerValue()); 703 | int32_t fl = CAST_INT32(args[1]->IntegerValue()); 704 | uint64_t f = ((uint64_t)fl) & (((uint64_t)fh) << 32); 705 | int32_t result = map_button(static_cast(f)); 706 | return scope.Close(Int32::New(result)); 707 | } 708 | 709 | Handle node_wmouse_position(const Arguments& args) { 710 | HandleScope scope; 711 | NODE_ARGS(1) 712 | NODE_PARG(0, WINDOW) 713 | WINDOW* win = CAST_PWINDOW(args[0]); 714 | int32_t y = 0, 715 | x = 0; 716 | wmouse_position( win, &y, &x ); 717 | Local result = Object::New(); 718 | result->Set( 719 | String::NewSymbol("y"), 720 | Int32::New(y) 721 | ); 722 | result->Set( 723 | String::NewSymbol("x"), 724 | Int32::New(x) 725 | ); 726 | return scope.Close(result); 727 | } 728 | 729 | Handle node_getmouse(const Arguments& args) { 730 | HandleScope scope; 731 | NODE_ARGS(0) 732 | uint64_t m = getmouse(); 733 | int32_t mh = (int32_t)((m >> 32) & 0xffffffff); 734 | int32_t ml = (int32_t)(m & 0xffffffff); 735 | Local result = Object::New(); 736 | result->Set( 737 | String::NewSymbol("high"), 738 | Int32::New(mh) 739 | ); 740 | result->Set( 741 | String::NewSymbol("low"), 742 | Int32::New(ml) 743 | ); 744 | return scope.Close(result); 745 | } 746 | 747 | Handle node_getbmap(const Arguments& args) { 748 | HandleScope scope; 749 | NODE_ARGS(0) 750 | uint64_t m = getbmap(); 751 | int32_t mh = (int32_t)((m >> 32) & 0xffffffff); 752 | int32_t ml = (int32_t)(m & 0xffffffff); 753 | Local result = Object::New(); 754 | result->Set( 755 | String::NewSymbol("high"), 756 | Int32::New(mh) 757 | ); 758 | result->Set( 759 | String::NewSymbol("low"), 760 | Int32::New(ml) 761 | ); 762 | return scope.Close(result); 763 | } 764 | 765 | #endif 766 | 767 | void init(Handle target) { 768 | 769 | target->Set( 770 | String::NewSymbol("CURSES_RGB"), 771 | #ifdef PDC_RGB 772 | Boolean::New(true) 773 | #else 774 | # ifdef NCURSES_VERSION 775 | Boolean::New(true) 776 | # else 777 | Boolean::New(false) 778 | # endif 779 | #endif 780 | ); 781 | 782 | target->Set( 783 | String::NewSymbol("CHTYPE_SIZE"), 784 | Int32::New(sizeof(chtype)) 785 | ); 786 | 787 | target->Set( 788 | String::NewSymbol("COLOR_BLACK"), 789 | Int32::New(COLOR_BLACK) 790 | ); 791 | 792 | target->Set( 793 | String::NewSymbol("COLOR_RED"), 794 | Int32::New(COLOR_RED) 795 | ); 796 | 797 | target->Set( 798 | String::NewSymbol("COLOR_GREEN"), 799 | Int32::New(COLOR_GREEN) 800 | ); 801 | 802 | target->Set( 803 | String::NewSymbol("COLOR_BLUE"), 804 | Int32::New(COLOR_BLUE) 805 | ); 806 | 807 | target->Set( 808 | String::NewSymbol("COLOR_CYAN"), 809 | Int32::New(COLOR_CYAN) 810 | ); 811 | 812 | target->Set( 813 | String::NewSymbol("COLOR_MAGENTA"), 814 | Int32::New(COLOR_MAGENTA) 815 | ); 816 | 817 | target->Set( 818 | String::NewSymbol("COLOR_YELLOW"), 819 | Int32::New(COLOR_YELLOW) 820 | ); 821 | 822 | target->Set( 823 | String::NewSymbol("COLOR_WHITE"), 824 | Int32::New(COLOR_WHITE) 825 | ); 826 | 827 | target->Set( 828 | String::NewSymbol("A_NORMAL"), 829 | Int32::New(A_NORMAL) 830 | ); 831 | 832 | target->Set( 833 | String::NewSymbol("A_ALTCHARSET"), 834 | Int32::New(A_ALTCHARSET) 835 | ); 836 | 837 | target->Set( 838 | String::NewSymbol("A_INVIS"), 839 | Int32::New(A_INVIS) 840 | ); 841 | 842 | target->Set( 843 | String::NewSymbol("A_UNDERLINE"), 844 | Int32::New(A_UNDERLINE) 845 | ); 846 | 847 | target->Set( 848 | String::NewSymbol("A_REVERSE"), 849 | Int32::New(A_REVERSE) 850 | ); 851 | 852 | target->Set( 853 | String::NewSymbol("A_BLINK"), 854 | Int32::New(A_BLINK) 855 | ); 856 | 857 | target->Set( 858 | String::NewSymbol("A_BOLD"), 859 | Int32::New(A_BOLD) 860 | ); 861 | 862 | target->Set( 863 | String::NewSymbol("A_ATTRIBUTES"), 864 | Int32::New(A_ATTRIBUTES) 865 | ); 866 | 867 | target->Set( 868 | String::NewSymbol("A_CHARTEXT"), 869 | Int32::New(A_CHARTEXT) 870 | ); 871 | 872 | target->Set( 873 | String::NewSymbol("A_COLOR"), 874 | Int32::New(A_COLOR) 875 | ); 876 | 877 | target->Set( 878 | String::NewSymbol("A_PROTECT"), 879 | Int32::New(A_PROTECT) 880 | ); 881 | 882 | target->Set( 883 | String::NewSymbol("ATTR_SHIFT"), 884 | #ifdef NCURSES_VERSION 885 | Int32::New(NCURSES_ATTR_SHIFT) 886 | #else 887 | Int32::New(PDC_ATTR_SHIFT) 888 | #endif 889 | ); 890 | 891 | target->Set( 892 | String::NewSymbol("A_STANDOUT"), 893 | Int32::New(A_STANDOUT) 894 | ); 895 | 896 | target->Set( 897 | String::NewSymbol("A_DIM"), 898 | Int32::New(A_DIM) 899 | ); 900 | 901 | target->Set( 902 | String::NewSymbol("color_pair"), 903 | FunctionTemplate::New(node_color_pair)->GetFunction() 904 | ); 905 | 906 | target->Set( 907 | String::NewSymbol("addch"), 908 | FunctionTemplate::New(node_addch)->GetFunction() 909 | ); 910 | 911 | target->Set( 912 | String::NewSymbol("box"), 913 | FunctionTemplate::New(node_box)->GetFunction() 914 | ); 915 | 916 | target->Set( 917 | String::NewSymbol("cbreak"), 918 | FunctionTemplate::New(node_cbreak)->GetFunction() 919 | ); 920 | 921 | target->Set( 922 | String::NewSymbol("delwin"), 923 | FunctionTemplate::New(node_delwin)->GetFunction() 924 | ); 925 | 926 | target->Set( 927 | String::NewSymbol("derwin"), 928 | FunctionTemplate::New(node_derwin)->GetFunction() 929 | ); 930 | 931 | target->Set( 932 | String::NewSymbol("doupdate"), 933 | FunctionTemplate::New(node_doupdate)->GetFunction() 934 | ); 935 | 936 | target->Set( 937 | String::NewSymbol("dupwin"), 938 | FunctionTemplate::New(node_dupwin)->GetFunction() 939 | ); 940 | 941 | target->Set( 942 | String::NewSymbol("echo"), 943 | FunctionTemplate::New(node_echo)->GetFunction() 944 | ); 945 | 946 | target->Set( 947 | String::NewSymbol("endwin"), 948 | FunctionTemplate::New(node_endwin)->GetFunction() 949 | ); 950 | 951 | target->Set( 952 | String::NewSymbol("getmaxyx"), 953 | FunctionTemplate::New(node_getmaxyx)->GetFunction() 954 | ); 955 | 956 | target->Set( 957 | String::NewSymbol("has_colors"), 958 | FunctionTemplate::New(node_has_colors)->GetFunction() 959 | ); 960 | 961 | target->Set( 962 | String::NewSymbol("init_color"), 963 | FunctionTemplate::New(node_init_color)->GetFunction() 964 | ); 965 | 966 | target->Set( 967 | String::NewSymbol("init_pair"), 968 | FunctionTemplate::New(node_init_pair)->GetFunction() 969 | ); 970 | 971 | target->Set( 972 | String::NewSymbol("initscr"), 973 | FunctionTemplate::New(node_initscr)->GetFunction() 974 | ); 975 | 976 | target->Set( 977 | String::NewSymbol("keyname"), 978 | FunctionTemplate::New(node_keyname)->GetFunction() 979 | ); 980 | 981 | target->Set( 982 | String::NewSymbol("keypad"), 983 | FunctionTemplate::New(node_keypad)->GetFunction() 984 | ); 985 | 986 | target->Set( 987 | String::NewSymbol("killchar"), 988 | FunctionTemplate::New(node_killchar)->GetFunction() 989 | ); 990 | 991 | target->Set( 992 | String::NewSymbol("leaveok"), 993 | FunctionTemplate::New(node_leaveok)->GetFunction() 994 | ); 995 | 996 | target->Set( 997 | String::NewSymbol("longname"), 998 | FunctionTemplate::New(node_longname)->GetFunction() 999 | ); 1000 | 1001 | target->Set( 1002 | String::NewSymbol("meta"), 1003 | FunctionTemplate::New(node_meta)->GetFunction() 1004 | ); 1005 | 1006 | target->Set( 1007 | String::NewSymbol("newpad"), 1008 | FunctionTemplate::New(node_newpad)->GetFunction() 1009 | ); 1010 | 1011 | target->Set( 1012 | String::NewSymbol("newwin"), 1013 | FunctionTemplate::New(node_newwin)->GetFunction() 1014 | ); 1015 | 1016 | target->Set( 1017 | String::NewSymbol("nocbreak"), 1018 | FunctionTemplate::New(node_nocbreak)->GetFunction() 1019 | ); 1020 | 1021 | target->Set( 1022 | String::NewSymbol("nodelay"), 1023 | FunctionTemplate::New(node_nodelay)->GetFunction() 1024 | ); 1025 | 1026 | target->Set( 1027 | String::NewSymbol("noecho"), 1028 | FunctionTemplate::New(node_noecho)->GetFunction() 1029 | ); 1030 | 1031 | target->Set( 1032 | String::NewSymbol("scrollok"), 1033 | FunctionTemplate::New(node_scrollok)->GetFunction() 1034 | ); 1035 | 1036 | target->Set( 1037 | String::NewSymbol("start_color"), 1038 | FunctionTemplate::New(node_start_color)->GetFunction() 1039 | ); 1040 | 1041 | target->Set( 1042 | String::NewSymbol("subpad"), 1043 | FunctionTemplate::New(node_subpad)->GetFunction() 1044 | ); 1045 | 1046 | target->Set( 1047 | String::NewSymbol("subwin"), 1048 | FunctionTemplate::New(node_subwin)->GetFunction() 1049 | ); 1050 | 1051 | target->Set( 1052 | String::NewSymbol("waddchnstr"), 1053 | FunctionTemplate::New(node_waddchnstr)->GetFunction() 1054 | ); 1055 | 1056 | target->Set( 1057 | String::NewSymbol("waddchstr"), 1058 | FunctionTemplate::New(node_waddchstr)->GetFunction() 1059 | ); 1060 | 1061 | target->Set( 1062 | String::NewSymbol("waddch"), 1063 | FunctionTemplate::New(node_waddch)->GetFunction() 1064 | ); 1065 | 1066 | target->Set( 1067 | String::NewSymbol("waddnstr"), 1068 | FunctionTemplate::New(node_waddnstr)->GetFunction() 1069 | ); 1070 | 1071 | target->Set( 1072 | String::NewSymbol("waddstr"), 1073 | FunctionTemplate::New(node_waddstr)->GetFunction() 1074 | ); 1075 | 1076 | target->Set( 1077 | String::NewSymbol("wattroff"), 1078 | FunctionTemplate::New(node_wattroff)->GetFunction() 1079 | ); 1080 | 1081 | target->Set( 1082 | String::NewSymbol("wattron"), 1083 | FunctionTemplate::New(node_wattron)->GetFunction() 1084 | ); 1085 | 1086 | target->Set( 1087 | String::NewSymbol("wattrset"), 1088 | FunctionTemplate::New(node_wattrset)->GetFunction() 1089 | ); 1090 | 1091 | target->Set( 1092 | String::NewSymbol("wbkgd"), 1093 | FunctionTemplate::New(node_wbkgd)->GetFunction() 1094 | ); 1095 | 1096 | target->Set( 1097 | String::NewSymbol("wclear"), 1098 | FunctionTemplate::New(node_wclear)->GetFunction() 1099 | ); 1100 | 1101 | target->Set( 1102 | String::NewSymbol("wdelch"), 1103 | FunctionTemplate::New(node_wdelch)->GetFunction() 1104 | ); 1105 | 1106 | target->Set( 1107 | String::NewSymbol("wdeleteln"), 1108 | FunctionTemplate::New(node_wdeleteln)->GetFunction() 1109 | ); 1110 | 1111 | target->Set( 1112 | String::NewSymbol("wechochar"), 1113 | FunctionTemplate::New(node_wechochar)->GetFunction() 1114 | ); 1115 | 1116 | target->Set( 1117 | String::NewSymbol("werase"), 1118 | FunctionTemplate::New(node_werase)->GetFunction() 1119 | ); 1120 | 1121 | target->Set( 1122 | String::NewSymbol("wgetch"), 1123 | FunctionTemplate::New(node_wgetch)->GetFunction() 1124 | ); 1125 | 1126 | target->Set( 1127 | String::NewSymbol("whline"), 1128 | FunctionTemplate::New(node_whline)->GetFunction() 1129 | ); 1130 | 1131 | target->Set( 1132 | String::NewSymbol("wmove"), 1133 | FunctionTemplate::New(node_wmove)->GetFunction() 1134 | ); 1135 | 1136 | target->Set( 1137 | String::NewSymbol("wnoutrefresh"), 1138 | FunctionTemplate::New(node_wnoutrefresh)->GetFunction() 1139 | ); 1140 | 1141 | target->Set( 1142 | String::NewSymbol("wrefresh"), 1143 | FunctionTemplate::New(node_wrefresh)->GetFunction() 1144 | ); 1145 | 1146 | target->Set( 1147 | String::NewSymbol("wscrl"), 1148 | FunctionTemplate::New(node_wscrl)->GetFunction() 1149 | ); 1150 | 1151 | target->Set( 1152 | String::NewSymbol("wvline"), 1153 | FunctionTemplate::New(node_wvline)->GetFunction() 1154 | ); 1155 | 1156 | target->Set( 1157 | String::NewSymbol("assume_default_colors"), 1158 | FunctionTemplate::New(node_assume_default_colors)->GetFunction() 1159 | ); 1160 | 1161 | target->Set( 1162 | String::NewSymbol("curses_version"), 1163 | FunctionTemplate::New(node_curses_version)->GetFunction() 1164 | ); 1165 | 1166 | target->Set( 1167 | String::NewSymbol("has_key"), 1168 | FunctionTemplate::New(node_has_key)->GetFunction() 1169 | ); 1170 | 1171 | target->Set( 1172 | String::NewSymbol("use_default_colors"), 1173 | FunctionTemplate::New(node_use_default_colors)->GetFunction() 1174 | ); 1175 | 1176 | target->Set( 1177 | String::NewSymbol("wresize"), 1178 | FunctionTemplate::New(node_wresize)->GetFunction() 1179 | ); 1180 | 1181 | #ifdef NODE_CURSES_WINDOWS 1182 | 1183 | target->Set( 1184 | String::NewSymbol("mouse_set"), 1185 | FunctionTemplate::New(node_mouse_set)->GetFunction() 1186 | ); 1187 | 1188 | target->Set( 1189 | String::NewSymbol("mouse_on"), 1190 | FunctionTemplate::New(node_mouse_on)->GetFunction() 1191 | ); 1192 | 1193 | target->Set( 1194 | String::NewSymbol("mouse_off"), 1195 | FunctionTemplate::New(node_mouse_off)->GetFunction() 1196 | ); 1197 | 1198 | target->Set( 1199 | String::NewSymbol("request_mouse_pos"), 1200 | FunctionTemplate::New(node_request_mouse_pos)->GetFunction() 1201 | ); 1202 | 1203 | target->Set( 1204 | String::NewSymbol("map_button"), 1205 | FunctionTemplate::New(node_map_button)->GetFunction() 1206 | ); 1207 | 1208 | target->Set( 1209 | String::NewSymbol("wmouse_position"), 1210 | FunctionTemplate::New(node_wmouse_position)->GetFunction() 1211 | ); 1212 | 1213 | target->Set( 1214 | String::NewSymbol("getmouse"), 1215 | FunctionTemplate::New(node_getmouse)->GetFunction() 1216 | ); 1217 | 1218 | target->Set( 1219 | String::NewSymbol("getbmap"), 1220 | FunctionTemplate::New(node_getbmap)->GetFunction() 1221 | ); 1222 | 1223 | #endif 1224 | 1225 | } 1226 | 1227 | NODE_MODULE(curses, init) 1228 | 1229 | 1230 | /* 1231 | 1232 | TODO: implement functions and tag with # 1233 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1234 | 1235 | # int addch(const chtype); 1236 | int addchnstr(const chtype *, int); 1237 | int addchstr(const chtype *); 1238 | int addnstr(const char *, int); 1239 | int addstr(const char *); 1240 | int attroff(chtype); 1241 | int attron(chtype); 1242 | int attrset(chtype); 1243 | int attr_get(attr_t *, short *, void *); 1244 | int attr_off(attr_t, void *); 1245 | int attr_on(attr_t, void *); 1246 | int attr_set(attr_t, short, void *); 1247 | int baudrate(void); 1248 | int beep(void); 1249 | int bkgd(chtype); 1250 | void bkgdset(chtype); 1251 | int border(chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype); 1252 | # int box(WINDOW *, chtype, chtype); 1253 | bool can_change_color(void); 1254 | # int cbreak(void); 1255 | int chgat(int, attr_t, short, const void *); 1256 | int clearok(WINDOW *, bool); 1257 | int clear(void); 1258 | int clrtobot(void); 1259 | int clrtoeol(void); 1260 | int color_content(short, short *, short *, short *); 1261 | int color_set(short, void *); 1262 | int copywin(const WINDOW *, WINDOW *, int, int, int, int, int, int, int); 1263 | int curs_set(int); 1264 | int def_prog_mode(void); 1265 | int def_shell_mode(void); 1266 | int delay_output(int); 1267 | int delch(void); 1268 | int deleteln(void); 1269 | void delscreen(SCREEN *); 1270 | # int delwin(WINDOW *); 1271 | # WINDOW *derwin(WINDOW *, int, int, int, int); 1272 | # int doupdate(void); 1273 | # WINDOW *dupwin(WINDOW *); 1274 | int echochar(const chtype); 1275 | # int echo(void); 1276 | # int endwin(void); 1277 | char erasechar(void); 1278 | int erase(void); 1279 | void filter(void); 1280 | int flash(void); 1281 | int flushinp(void); 1282 | chtype getbkgd(WINDOW *); 1283 | int getnstr(char *, int); 1284 | int getstr(char *); 1285 | WINDOW *getwin(FILE *); 1286 | int halfdelay(int); 1287 | # bool has_colors(void); 1288 | bool has_ic(void); 1289 | bool has_il(void); 1290 | int hline(chtype, int); 1291 | void idcok(WINDOW *, bool); 1292 | int idlok(WINDOW *, bool); 1293 | void immedok(WINDOW *, bool); 1294 | int inchnstr(chtype *, int); 1295 | int inchstr(chtype *); 1296 | chtype inch(void); 1297 | # int init_color(short, short, short, short); 1298 | # int init_pair(short, short, short); 1299 | # WINDOW *initscr(void); 1300 | int innstr(char *, int); 1301 | int insch(chtype); 1302 | int insdelln(int); 1303 | int insertln(void); 1304 | int insnstr(const char *, int); 1305 | int insstr(const char *); 1306 | int instr(char *); 1307 | int intrflush(WINDOW *, bool); 1308 | bool isendwin(void); 1309 | bool is_linetouched(WINDOW *, int); 1310 | bool is_wintouched(WINDOW *); 1311 | # char *keyname(int); 1312 | # int keypad(WINDOW *, bool); 1313 | # char killchar(void); 1314 | # int leaveok(WINDOW *, bool); 1315 | # char *longname(void); 1316 | # int meta(WINDOW *, bool); 1317 | int move(int, int); 1318 | int mvaddch(int, int, const chtype); 1319 | int mvaddchnstr(int, int, const chtype *, int); 1320 | int mvaddchstr(int, int, const chtype *); 1321 | int mvaddnstr(int, int, const char *, int); 1322 | int mvaddstr(int, int, const char *); 1323 | int mvchgat(int, int, int, attr_t, short, const void *); 1324 | int mvcur(int, int, int, int); 1325 | int mvdelch(int, int); 1326 | int mvderwin(WINDOW *, int, int); 1327 | int mvgetch(int, int); 1328 | int mvgetnstr(int, int, char *, int); 1329 | int mvgetstr(int, int, char *); 1330 | int mvhline(int, int, chtype, int); 1331 | chtype mvinch(int, int); 1332 | int mvinchnstr(int, int, chtype *, int); 1333 | int mvinchstr(int, int, chtype *); 1334 | int mvinnstr(int, int, char *, int); 1335 | int mvinsch(int, int, chtype); 1336 | int mvinsnstr(int, int, const char *, int); 1337 | int mvinsstr(int, int, const char *); 1338 | int mvinstr(int, int, char *); 1339 | int mvprintw(int, int, const char *, ...); 1340 | int mvscanw(int, int, const char *, ...); 1341 | int mvvline(int, int, chtype, int); 1342 | int mvwaddchnstr(WINDOW *, int, int, const chtype *, int); 1343 | int mvwaddchstr(WINDOW *, int, int, const chtype *); 1344 | int mvwaddch(WINDOW *, int, int, const chtype); 1345 | int mvwaddnstr(WINDOW *, int, int, const char *, int); 1346 | int mvwaddstr(WINDOW *, int, int, const char *); 1347 | int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *); 1348 | int mvwdelch(WINDOW *, int, int); 1349 | int mvwgetch(WINDOW *, int, int); 1350 | int mvwgetnstr(WINDOW *, int, int, char *, int); 1351 | int mvwgetstr(WINDOW *, int, int, char *); 1352 | int mvwhline(WINDOW *, int, int, chtype, int); 1353 | int mvwinchnstr(WINDOW *, int, int, chtype *, int); 1354 | int mvwinchstr(WINDOW *, int, int, chtype *); 1355 | chtype mvwinch(WINDOW *, int, int); 1356 | int mvwinnstr(WINDOW *, int, int, char *, int); 1357 | int mvwinsch(WINDOW *, int, int, chtype); 1358 | int mvwinsnstr(WINDOW *, int, int, const char *, int); 1359 | int mvwinsstr(WINDOW *, int, int, const char *); 1360 | int mvwinstr(WINDOW *, int, int, char *); 1361 | int mvwin(WINDOW *, int, int); 1362 | int mvwprintw(WINDOW *, int, int, const char *, ...); 1363 | int mvwscanw(WINDOW *, int, int, const char *, ...); 1364 | int mvwvline(WINDOW *, int, int, chtype, int); 1365 | int napms(int); 1366 | # WINDOW *newpad(int, int); 1367 | SCREEN *newterm(const char *, FILE *, FILE *); 1368 | # WINDOW *newwin(int, int, int, int); 1369 | int nl(void); 1370 | # int nocbreak(void); 1371 | # int nodelay(WINDOW *, bool); 1372 | # int noecho(void); 1373 | int nonl(void); 1374 | void noqiflush(void); 1375 | int noraw(void); 1376 | int notimeout(WINDOW *, bool); 1377 | int overlay(const WINDOW *, WINDOW *); 1378 | int overwrite(const WINDOW *, WINDOW *); 1379 | int pair_content(short, short *, short *); 1380 | int pechochar(WINDOW *, chtype); 1381 | int pnoutrefresh(WINDOW *, int, int, int, int, int, int); 1382 | int prefresh(WINDOW *, int, int, int, int, int, int); 1383 | int printw(const char *, ...); 1384 | int putwin(WINDOW *, FILE *); 1385 | void qiflush(void); 1386 | int raw(void); 1387 | int redrawwin(WINDOW *); 1388 | int refresh(void); 1389 | int reset_prog_mode(void); 1390 | int reset_shell_mode(void); 1391 | int resetty(void); 1392 | int ripoffline(int, int (*)(WINDOW *, int)); 1393 | int savetty(void); 1394 | int scanw(const char *, ...); 1395 | int scr_dump(const char *); 1396 | int scr_init(const char *); 1397 | int scr_restore(const char *); 1398 | int scr_set(const char *); 1399 | int scrl(int); 1400 | int scroll(WINDOW *); 1401 | # int scrollok(WINDOW *, bool); 1402 | SCREEN *set_term(SCREEN *); 1403 | int setscrreg(int, int); 1404 | int slk_attroff(const chtype); 1405 | int slk_attr_off(const attr_t, void *); 1406 | int slk_attron(const chtype); 1407 | int slk_attr_on(const attr_t, void *); 1408 | int slk_attrset(const chtype); 1409 | int slk_attr_set(const attr_t, short, void *); 1410 | int slk_clear(void); 1411 | int slk_color(short); 1412 | int slk_init(int); 1413 | char *slk_label(int); 1414 | int slk_noutrefresh(void); 1415 | int slk_refresh(void); 1416 | int slk_restore(void); 1417 | int slk_set(int, const char *, int); 1418 | int slk_touch(void); 1419 | int standend(void); 1420 | int standout(void); 1421 | int start_color(void); 1422 | # WINDOW *subpad(WINDOW *, int, int, int, int); 1423 | # WINDOW *subwin(WINDOW *, int, int, int, int); 1424 | int syncok(WINDOW *, bool); 1425 | chtype termattrs(void); 1426 | attr_t term_attrs(void); 1427 | char *termname(void); 1428 | void timeout(int); 1429 | int touchline(WINDOW *, int, int); 1430 | int touchwin(WINDOW *); 1431 | int typeahead(int); 1432 | int untouchwin(WINDOW *); 1433 | void use_env(bool); 1434 | int vidattr(chtype); 1435 | int vid_attr(attr_t, short, void *); 1436 | int vidputs(chtype, int (*)(int)); 1437 | int vid_puts(attr_t, short, void *, int (*)(int)); 1438 | int vline(chtype, int); 1439 | int vw_printw(WINDOW *, const char *, va_list); 1440 | int vwprintw(WINDOW *, const char *, va_list); 1441 | int vw_scanw(WINDOW *, const char *, va_list); 1442 | int vwscanw(WINDOW *, const char *, va_list); 1443 | # int waddchnstr(WINDOW *, const chtype *, int); 1444 | # int waddchstr(WINDOW *, const chtype *); 1445 | # int waddch(WINDOW *, const chtype); 1446 | # int waddnstr(WINDOW *, const char *, int); 1447 | # int waddstr(WINDOW *, const char *); 1448 | # int wattroff(WINDOW *, chtype); 1449 | # int wattron(WINDOW *, chtype); 1450 | # int wattrset(WINDOW *, chtype); 1451 | int wattr_get(WINDOW *, attr_t *, short *, void *); 1452 | int wattr_off(WINDOW *, attr_t, void *); 1453 | int wattr_on(WINDOW *, attr_t, void *); 1454 | int wattr_set(WINDOW *, attr_t, short, void *); 1455 | void wbkgdset(WINDOW *, chtype); 1456 | # int wbkgd(WINDOW *, chtype); 1457 | int wborder(WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype); 1458 | int wchgat(WINDOW *, int, attr_t, short, const void *); 1459 | # int wclear(WINDOW *); 1460 | int wclrtobot(WINDOW *); 1461 | int wclrtoeol(WINDOW *); 1462 | int wcolor_set(WINDOW *, short, void *); 1463 | void wcursyncup(WINDOW *); 1464 | # int wdelch(WINDOW *); 1465 | # int wdeleteln(WINDOW *); 1466 | # int wechochar(WINDOW *, const chtype); 1467 | # int werase(WINDOW *); 1468 | # int wgetch(WINDOW *); 1469 | int wgetnstr(WINDOW *, char *, int); 1470 | int wgetstr(WINDOW *, char *); 1471 | # int whline(WINDOW *, chtype, int); 1472 | int winchnstr(WINDOW *, chtype *, int); 1473 | int winchstr(WINDOW *, chtype *); 1474 | chtype winch(WINDOW *); 1475 | int winnstr(WINDOW *, char *, int); 1476 | int winsch(WINDOW *, chtype); 1477 | int winsdelln(WINDOW *, int); 1478 | int winsertln(WINDOW *); 1479 | int winsnstr(WINDOW *, const char *, int); 1480 | int winsstr(WINDOW *, const char *); 1481 | int winstr(WINDOW *, char *); 1482 | # int wmove(WINDOW *, int, int); 1483 | # int wnoutrefresh(WINDOW *); 1484 | int wprintw(WINDOW *, const char *, ...); 1485 | int wredrawln(WINDOW *, int, int); 1486 | # int wrefresh(WINDOW *); 1487 | int wscanw(WINDOW *, const char *, ...); 1488 | # int wscrl(WINDOW *, int); 1489 | int wsetscrreg(WINDOW *, int, int); 1490 | int wstandend(WINDOW *); 1491 | int wstandout(WINDOW *); 1492 | void wsyncdown(WINDOW *); 1493 | void wsyncup(WINDOW *); 1494 | void wtimeout(WINDOW *, int); 1495 | int wtouchln(WINDOW *, int, int, int); 1496 | # int wvline(WINDOW *, chtype, int); 1497 | 1498 | chtype getattrs(WINDOW *); 1499 | int getbegx(WINDOW *); 1500 | int getbegy(WINDOW *); 1501 | int getmaxx(WINDOW *); 1502 | int getmaxy(WINDOW *); 1503 | int getparx(WINDOW *); 1504 | int getpary(WINDOW *); 1505 | int getcurx(WINDOW *); 1506 | int getcury(WINDOW *); 1507 | void traceoff(void); 1508 | void traceon(void); 1509 | char *unctrl(chtype); 1510 | 1511 | int crmode(void); 1512 | int nocrmode(void); 1513 | int draino(int); 1514 | int resetterm(void); 1515 | int fixterm(void); 1516 | int saveterm(void); 1517 | int setsyx(int, int); 1518 | 1519 | # int mouse_set(unsigned long); 1520 | # int mouse_on(unsigned long); 1521 | # int mouse_off(unsigned long); 1522 | # int request_mouse_pos(void); 1523 | # int map_button(unsigned long); 1524 | # void wmouse_position(WINDOW *, int *, int *); 1525 | # unsigned long getmouse(void); 1526 | # unsigned long getbmap(void); 1527 | 1528 | # int assume_default_colors(int, int); 1529 | # const char *curses_version(void); 1530 | # bool has_key(int); 1531 | # int use_default_colors(void); 1532 | # int wresize(WINDOW *, int, int); 1533 | 1534 | int mouseinterval(int); 1535 | mmask_t mousemask(mmask_t, mmask_t *); 1536 | bool mouse_trafo(int *, int *, bool); 1537 | int nc_getmouse(MEVENT *); 1538 | int ungetmouse(MEVENT *); 1539 | bool wenclose(const WINDOW *, int, int); 1540 | bool wmouse_trafo(const WINDOW *, int *, int *, bool); 1541 | 1542 | */ 1543 | -------------------------------------------------------------------------------- /src/ptrwrap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ptrwrap.h 3 | * 4 | * Created on: 21.11.2012 5 | * Author: Paul Bottin 6 | */ 7 | 8 | #ifndef PTRWRAP_H_ 9 | #define PTRWRAP_H_ 10 | 11 | #ifndef BUILDING_NODE_EXTENSION 12 | # define BUILDING_NODE_EXTENSION 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | /** 21 | * declares a PtrWrap class for the type t 22 | */ 23 | #define PTRWRAP_DECLARE(t) \ 24 | template <> v8::Persistent PtrWrap< t >::ctor_ = PtrWrap< t >::Init( #t ); \ 25 | 26 | 27 | /** 28 | * wraps a pointer to the type T into a JSObject 29 | */ 30 | template 31 | class PtrWrap : public node::ObjectWrap 32 | { 33 | private: 34 | /** 35 | * the wrapped pointer 36 | */ 37 | T *ptr_; 38 | 39 | /** 40 | * constructor function 41 | */ 42 | static v8::Persistent ctor_; 43 | 44 | public: 45 | 46 | /** 47 | * test, if obj is an instance of this class, no inheritance 48 | */ 49 | static inline bool InstanceOf(v8::Handle obj) 50 | { 51 | v8::HandleScope scope; 52 | if (obj.IsEmpty()) return false; 53 | if (!obj->IsObject()) return false; 54 | v8::Handle asObj = obj.As(); 55 | return asObj->Get(v8::String::NewSymbol("constructor")) == ctor_; 56 | } 57 | 58 | /** 59 | * initializes this class, will be called through PTRWRAP_INIT macro 60 | */ 61 | static inline v8::Persistent Init(const char *name) 62 | { 63 | v8::Local tpl = v8::FunctionTemplate::New(New); 64 | v8::Local symbol = v8::String::NewSymbol(name); 65 | tpl->SetClassName(symbol); 66 | tpl->InstanceTemplate()->SetInternalFieldCount(1); 67 | tpl->PrototypeTemplate()->Set( 68 | v8::String::NewSymbol("toString"), 69 | v8::FunctionTemplate::New(ToString) 70 | ); 71 | tpl->ReadOnlyPrototype(); 72 | return v8::Persistent::New(tpl->GetFunction()); 73 | } 74 | 75 | /** 76 | * unwrap the pointer, obj must be an instance of this class 77 | */ 78 | static inline T * Unwrap (v8::Handle obj) 79 | { 80 | v8::HandleScope scope; 81 | return node::ObjectWrap::Unwrap >(obj->ToObject())->ptr_; 82 | } 83 | 84 | /** 85 | * this class never will be instantiated from the VM, 86 | * calls the private New method through the constructor field 87 | */ 88 | static inline v8::Handle New(T* ptr) 89 | { 90 | v8::HandleScope scope; 91 | v8::Local instance = ctor_->NewInstance(); 92 | 93 | // ptr_ will always be NULL if instantiated by VM 94 | node::ObjectWrap::Unwrap >(instance)->ptr_ = ptr; 95 | 96 | return scope.Close(instance); 97 | } 98 | 99 | private: 100 | inline PtrWrap() : 101 | ptr_(0) 102 | { 103 | } 104 | 105 | virtual ~PtrWrap() 106 | { 107 | } 108 | 109 | /** 110 | * called by the constructor 111 | */ 112 | static v8::Handle New(const v8::Arguments& args) 113 | { 114 | v8::HandleScope scope; 115 | if (!args.IsConstructCall()) { 116 | v8::ThrowException(v8::Exception::TypeError(v8::String::New("Not constructed via new keyword."))); 117 | return scope.Close(v8::Undefined()); 118 | } 119 | 120 | PtrWrap* obj = new PtrWrap(); 121 | obj->ptr_ = NULL; 122 | obj->Wrap(args.This()); 123 | 124 | return args.This(); 125 | } 126 | 127 | /** 128 | * to string method 129 | */ 130 | static v8::Handle ToString(const v8::Arguments& args) { 131 | v8::HandleScope scope; 132 | char buff[256]; 133 | memset(buff, 0, 256); 134 | v8::String::Utf8Value tp(args.This()->GetConstructorName()); 135 | sprintf(buff, "[object %s(%p)]", *tp, Unwrap(args.This())); 136 | return scope.Close(v8::String::New(buff)); 137 | } 138 | 139 | }; 140 | 141 | #endif /* PTRWRAP_H_ */ 142 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 2 | var curses = require('../curses') 3 | 4 | /* top level window */ 5 | , stdwin = curses.initscr() 6 | 7 | /* color pair indices */ 8 | , TITLECOLOR = 1 9 | , MAINMENUCOLOR = (2 | curses.A_BOLD) 10 | , MAINMENUREVCOLOR = (3 | curses.A_BOLD | curses.A_REVERSE) 11 | , SUBMENUCOLOR = (4 | curses.A_BOLD) 12 | , SUBMENUREVCOLOR = (5 | curses.A_BOLD | curses.A_REVERSE) 13 | , BODYCOLOR = 6 14 | , STATUSCOLOR = (7 | curses.A_BOLD) 15 | , INPUTBOXCOLOR = 8 16 | , EDITBOXCOLOR = (9 | curses.A_BOLD | curses.A_REVERSE) 17 | ; 18 | 19 | /* initialize color pairs */ 20 | if (curses.has_colors()) { 21 | curses.start_color(); // cp index (0 = default) 22 | curses.init_pair(TITLECOLOR & ~curses.A_ATTR, curses.COLOR_BLACK, curses.COLOR_CYAN); // 1 23 | curses.init_pair(MAINMENUCOLOR & ~curses.A_ATTR, curses.COLOR_WHITE, curses.COLOR_CYAN); // 2 24 | curses.init_pair(MAINMENUREVCOLOR & ~curses.A_ATTR, curses.COLOR_WHITE, curses.COLOR_BLACK);// 3 25 | curses.init_pair(SUBMENUCOLOR & ~curses.A_ATTR, curses.COLOR_WHITE, curses.COLOR_CYAN); // 4 26 | curses.init_pair(SUBMENUREVCOLOR & ~curses.A_ATTR, curses.COLOR_WHITE, curses.COLOR_BLACK);// 5 27 | curses.init_pair(BODYCOLOR & ~curses.A_ATTR, curses.COLOR_WHITE, curses.COLOR_BLUE); // 6 28 | curses.init_pair(STATUSCOLOR & ~curses.A_ATTR, curses.COLOR_WHITE, curses.COLOR_CYAN); // 7 29 | curses.init_pair(INPUTBOXCOLOR & ~curses.A_ATTR, curses.COLOR_BLACK, curses.COLOR_CYAN); // 8 30 | curses.init_pair(EDITBOXCOLOR & ~curses.A_ATTR, curses.COLOR_WHITE, curses.COLOR_BLACK);// 9 31 | } 32 | 33 | /* draw border */ 34 | curses.wattrset(stdwin, curses.color_pair(8)); 35 | curses.wclear(stdwin); 36 | curses.box(stdwin, 0, 0); 37 | curses.wmove(stdwin, 1, 1); 38 | 39 | /* create subwindow 20x20 */ 40 | var subwin = curses.subwin(stdwin, 20, 20, 1, 1) 41 | , cp = 0 42 | ; 43 | 44 | curses.wrefresh(stdwin); 45 | curses.wrefresh(subwin); 46 | 47 | /* print to subwindow */ 48 | setInterval(function () { 49 | ++cp; 50 | if (cp % 10 == 0) cp = 1; 51 | curses.wattrset(subwin, curses.color_pair(cp)); 52 | curses.waddch(subwin, '#'.charCodeAt(0)); 53 | curses.wrefresh(subwin); 54 | }, 25); 55 | 56 | /* exit after 10s */ 57 | setTimeout(function () { 58 | curses.endwin(); 59 | process.exit(0); 60 | }, 10000); 61 | --------------------------------------------------------------------------------