mscdex / node-ncurses

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

call get_wch instead of getch #18

Closed tokuhirom closed 11 years ago

tokuhirom commented 12 years ago

get_wch is required to support multi-byte unicode character input.

This is a example code:

var nc=require('../ncurses'),
    sl=require('setlocale');
sl.setlocale(sl.LC_ALL, ''); // must first.

var w = new nc.Window(),
    buf = '',
    tmo;

process.on('SIGINT', function () {
    nc.cleanup();
    console.log(buf);
    process.exit();
});
w.on('inputChar', function(c, x) {
    buf += c;

    w.clear();
    w.cursor(0,0);
    w.addstr(buf);
    w.cursor(w.height-1,0);
    w.addstr(''+x);
    w.refresh();
});
w.refresh();
tmo = setTimeout(function() { w.close(); }, 10*1000);

Notes: ncurses requires setlocale(3) to support unicode. node's setlocale module is a simple wrapper for setlocale(3).

mscdex commented 11 years ago

This should be fixed in master