mirror of
https://github.com/danbulant/node-x11
synced 2026-05-27 14:01:52 +00:00
commit
4bddee6d5e
23 changed files with 58 additions and 50 deletions
|
|
@ -252,7 +252,7 @@ function genReq(req, last)
|
||||||
if (req.body.length == 0)
|
if (req.body.length == 0)
|
||||||
{
|
{
|
||||||
result.push(' function() {');
|
result.push(' function() {');
|
||||||
result.push(' return new Buffer([' + req.opcode + ', 0, 1, 0]);');
|
result.push(' return Buffer.from([' + req.opcode + ', 0, 1, 0]);');
|
||||||
} else {
|
} else {
|
||||||
result.push(' function (args) {');
|
result.push(' function (args) {');
|
||||||
result.push(' var extraLength = 0;');
|
result.push(' var extraLength = 0;');
|
||||||
|
|
@ -287,10 +287,10 @@ function genReq(req, last)
|
||||||
var reqLen4 = ((reqLen + 3) >> 2);
|
var reqLen4 = ((reqLen + 3) >> 2);
|
||||||
|
|
||||||
if (extraLength)
|
if (extraLength)
|
||||||
result.push(' var data = new Buffer(' + reqLen + ' + extraLength);');
|
result.push(' var data = Buffer.alloc(' + reqLen + ' + extraLength);');
|
||||||
else {
|
else {
|
||||||
result.pop();
|
result.pop();
|
||||||
result.push(' var data = new Buffer(' + reqLen + ');');
|
result.push(' var data = Buffer.alloc(' + reqLen + ');');
|
||||||
}
|
}
|
||||||
result.push(' data[0] = ' + req.opcode + ';');
|
result.push(' data[0] = ' + req.opcode + ';');
|
||||||
if (req.body.length != 0) {
|
if (req.body.length != 0) {
|
||||||
|
|
|
||||||
|
|
@ -571,7 +571,7 @@ module.exports.readJpeg = function(path)
|
||||||
var imageData = {};
|
var imageData = {};
|
||||||
imageData.width = j.width;
|
imageData.width = j.width;
|
||||||
imageData.height = j.height;
|
imageData.height = j.height;
|
||||||
imageData.data = new Buffer(j.width*j.height*4);
|
imageData.data = Buffer.from(j.width*j.height*4);
|
||||||
j.copyToImageData(imageData);
|
j.copyToImageData(imageData);
|
||||||
return imageData;
|
return imageData;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -874,7 +874,7 @@ module.exports.readPng = function(path)
|
||||||
var imageData = {};
|
var imageData = {};
|
||||||
imageData.width = j.width;
|
imageData.width = j.width;
|
||||||
imageData.height = j.height;
|
imageData.height = j.height;
|
||||||
imageData.data = new Buffer(j.width*j.height*4);
|
imageData.data = Buffer.alloc(j.width*j.height*4);
|
||||||
j.render(imageData);
|
j.render(imageData);
|
||||||
return imageData;
|
return imageData;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ function padWidth(buf, width) {
|
||||||
return buf;
|
return buf;
|
||||||
else {
|
else {
|
||||||
var stride = (width+3)&~3;
|
var stride = (width+3)&~3;
|
||||||
var res = new Buffer(height*stride);
|
var res = Buffer.alloc(height*stride);
|
||||||
res.fill(0);
|
res.fill(0);
|
||||||
for (var y=0; y < height; ++y) {
|
for (var y=0; y < height; ++y) {
|
||||||
// memcpy(tmpbitmap+y*stride, bitmap->buffer+y*ginfo.width, ginfo.width);
|
// memcpy(tmpbitmap+y*stride, bitmap->buffer+y*ginfo.width, ginfo.width);
|
||||||
|
|
@ -88,7 +88,7 @@ var xclient = x11.createClient({ debug: true }, function(err, display) {
|
||||||
var glyphFromCode = [];
|
var glyphFromCode = [];
|
||||||
glyphs.forEach(function(g) {
|
glyphs.forEach(function(g) {
|
||||||
if (!g.image || (g.image.length == 0)) {
|
if (!g.image || (g.image.length == 0)) {
|
||||||
g.image = new Buffer(64);
|
g.image = Buffer.alloc(64);
|
||||||
g.image.fill(0);
|
g.image.fill(0);
|
||||||
g.width = 8;
|
g.width = 8;
|
||||||
g.height = 8;
|
g.height = 8;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ var Pixmap = require('./pixmap').Pixmap;
|
||||||
var Buffer = require('buffer').Buffer;
|
var Buffer = require('buffer').Buffer;
|
||||||
require('../../lib/unpackbuffer').addUnpack(Buffer);
|
require('../../lib/unpackbuffer').addUnpack(Buffer);
|
||||||
|
|
||||||
var reversed = new Buffer(256);
|
var reversed = Buffer.alloc(256);
|
||||||
for (var i=0; i < 256; ++i)
|
for (var i=0; i < 256; ++i)
|
||||||
{
|
{
|
||||||
var res = 0;
|
var res = 0;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ var xclient = x11.createClient();
|
||||||
var Exposure = x11.eventMask.Exposure;
|
var Exposure = x11.eventMask.Exposure;
|
||||||
var PointerMotion = x11.eventMask.PointerMotion;
|
var PointerMotion = x11.eventMask.PointerMotion;
|
||||||
|
|
||||||
var bitmap = new Buffer(128*128/8); // 16384 bits, 2048 bytes bitmap
|
var bitmap = Buffer.alloc(128*128/8); // 16384 bits, 2048 bytes bitmap
|
||||||
for (var i=0; i < bitmap.length; ++i)
|
for (var i=0; i < bitmap.length; ++i)
|
||||||
{
|
{
|
||||||
bitmap[i] = i % 256;
|
bitmap[i] = i % 256;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ var x11 = require('../../lib');
|
||||||
var Exposure = x11.eventMask.Exposure;
|
var Exposure = x11.eventMask.Exposure;
|
||||||
var PointerMotion = x11.eventMask.PointerMotion;
|
var PointerMotion = x11.eventMask.PointerMotion;
|
||||||
|
|
||||||
var bitmap = new Buffer(128*128*4); // 16384 bits, 2048 bytes bitmap
|
var bitmap = Buffer.alloc(128*128*4); // 16384 bits, 2048 bytes bitmap
|
||||||
for (var i=0; i < bitmap.length; ++i)
|
for (var i=0; i < bitmap.length; ++i)
|
||||||
{
|
{
|
||||||
var byteNum = i%4;
|
var byteNum = i%4;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ var Buffer = require('buffer').Buffer;
|
||||||
|
|
||||||
var startpos = [4, 15];
|
var startpos = [4, 15];
|
||||||
var cupsize = [10, 20];
|
var cupsize = [10, 20];
|
||||||
var cup = new Buffer(cupsize[0]*cupsize[1]);
|
var cup = Buffer.alloc(cupsize[0]*cupsize[1]);
|
||||||
var moveInterval;
|
var moveInterval;
|
||||||
|
|
||||||
function clearCup()
|
function clearCup()
|
||||||
|
|
|
||||||
12
examples/vncviewer/d3des.js
vendored
12
examples/vncviewer/d3des.js
vendored
|
|
@ -56,8 +56,8 @@ var pc2 = [
|
||||||
function deskey(key, edf)
|
function deskey(key, edf)
|
||||||
{
|
{
|
||||||
var i, j, l, m, n;
|
var i, j, l, m, n;
|
||||||
var pc1m = new Buffer(56);
|
var pc1m = Buffer.alloc(56);
|
||||||
var pcr = new Buffer(56);
|
var pcr = Buffer.alloc(56);
|
||||||
var kn = new Array(32);
|
var kn = new Array(32);
|
||||||
|
|
||||||
for ( j = 0; j < 56; j++ ) {
|
for ( j = 0; j < 56; j++ ) {
|
||||||
|
|
@ -388,17 +388,17 @@ function desfunc(block, keys)
|
||||||
|
|
||||||
module.exports.response = function(challenge, password)
|
module.exports.response = function(challenge, password)
|
||||||
{
|
{
|
||||||
var key = new Buffer(8);
|
var key = Buffer.alloc(8);
|
||||||
key.fill(0);
|
key.fill(0);
|
||||||
key.write(password.substring(0,8));
|
key.write(password.substring(0,8));
|
||||||
var in1 = challenge.slice(0,8);
|
var in1 = challenge.slice(0,8);
|
||||||
var in2 = challenge.slice(8,16);
|
var in2 = challenge.slice(8,16);
|
||||||
var res1 = new Buffer(8);
|
var res1 = Buffer.alloc(8);
|
||||||
var res2 = new Buffer(8);
|
var res2 = Buffer.alloc(8);
|
||||||
deskey(key, EN0);
|
deskey(key, EN0);
|
||||||
des(in1, res1);
|
des(in1, res1);
|
||||||
des(in2, res2);
|
des(in2, res2);
|
||||||
var resp = new Buffer(16);
|
var resp = Buffer.alloc(16);
|
||||||
res1.copy(resp);
|
res1.copy(resp);
|
||||||
res2.copy(resp, 8);
|
res2.copy(resp, 8);
|
||||||
return resp;
|
return resp;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
// It should create a pleasant looking hex dumb by default:
|
// It should create a pleasant looking hex dumb by default:
|
||||||
//
|
//
|
||||||
// var hexy = require('hexy.js'),
|
// var hexy = require('hexy.js'),
|
||||||
// b = new Buffer("\000\001\003\005\037\012\011bcdefghijklmnopqrstuvwxyz0123456789")
|
// b = Buffer.from("\000\001\003\005\037\012\011bcdefghijklmnopqrstuvwxyz0123456789")
|
||||||
//
|
//
|
||||||
// console.log(hexy.hexy(b))
|
// console.log(hexy.hexy(b))
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -400,7 +400,7 @@ RfbClient.prototype.readHextileTile = function(rect, cb)
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tile.buffer = new Buffer(tilebuflen);
|
tile.buffer = Buffer.alloc(tilebuflen);
|
||||||
|
|
||||||
function solidBackground() {
|
function solidBackground() {
|
||||||
clog('solidBackground');
|
clog('solidBackground');
|
||||||
|
|
@ -667,8 +667,8 @@ function createConnection(params)
|
||||||
var wstream = fs.createWriteStream(params.rfbFileOut);
|
var wstream = fs.createWriteStream(params.rfbFileOut);
|
||||||
wstream.write('FBS 001.001\n');
|
wstream.write('FBS 001.001\n');
|
||||||
stream.on('data', function(data) {
|
stream.on('data', function(data) {
|
||||||
var sizeBuf = new Buffer(4);
|
var sizeBuf = Buffer.alloc(4);
|
||||||
var timeBuf = new Buffer(4);
|
var timeBuf = Buffer.alloc(4);
|
||||||
var size = data.length;
|
var size = data.length;
|
||||||
sizeBuf.writeInt32BE(size, 0);
|
sizeBuf.writeInt32BE(size, 0);
|
||||||
wstream.write(sizeBuf);
|
wstream.write(sizeBuf);
|
||||||
|
|
@ -676,7 +676,7 @@ function createConnection(params)
|
||||||
timeBuf.writeInt32BE(+new Date() - start, 0);
|
timeBuf.writeInt32BE(+new Date() - start, 0);
|
||||||
wstream.write(timeBuf);
|
wstream.write(timeBuf);
|
||||||
var padding = 3 - ((size - 1) & 0x03);
|
var padding = 3 - ((size - 1) & 0x03);
|
||||||
var pbuf = new Buffer(padding);
|
var pbuf = Buffer.alloc(padding);
|
||||||
wstream.write(pbuf);
|
wstream.write(pbuf);
|
||||||
}).on('end', function() {
|
}).on('end', function() {
|
||||||
wstream.end();
|
wstream.end();
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ RfbServer.prototype.processSecurity = function()
|
||||||
break;
|
break;
|
||||||
case rfb.security.VNC:
|
case rfb.security.VNC:
|
||||||
// generate random 16 byte challenge
|
// generate random 16 byte challenge
|
||||||
serv.challenge = new Buffer(16);
|
serv.challenge = Buffer.alloc(16);
|
||||||
serv.challenge.write('1234567890abcdef');
|
serv.challenge.write('1234567890abcdef');
|
||||||
console.log(['sending challenge', serv.challenge]);
|
console.log(['sending challenge', serv.challenge]);
|
||||||
serv.pack_stream.pack('a', [serv.challenge]).flush();
|
serv.pack_stream.pack('a', [serv.challenge]).flush();
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ function ReadFixedRequest(length, callback)
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
//clog(length);
|
//clog(length);
|
||||||
this.data = new Buffer(length);
|
this.data = Buffer.alloc(length);
|
||||||
this.received_bytes = 0;
|
this.received_bytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,7 +328,7 @@ UnpackStream.prototype.pack = function(format, args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf = new Buffer(packetlength);
|
var buf = Buffer.alloc(packetlength);
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
var arg = 0;
|
var arg = 0;
|
||||||
for (var i = 0; i < format.length; ++i)
|
for (var i = 0; i < format.length; ++i)
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ PixmapFromFile.prototype.mapColors = function(content,size){
|
||||||
}
|
}
|
||||||
|
|
||||||
PixmapFromFile.prototype.toBuffer = function (colors,content,size) {
|
PixmapFromFile.prototype.toBuffer = function (colors,content,size) {
|
||||||
var buf = new Buffer(size.width*size.height*4);
|
var buf = Buffer.alloc(size.width*size.height*4);
|
||||||
var offset = 0, byte,color;
|
var offset = 0, byte,color;
|
||||||
var copy;
|
var copy;
|
||||||
if( !this.options.format || this.options.format.toUpperCase() === "BGRA"){
|
if( !this.options.format || this.options.format.toUpperCase() === "BGRA"){
|
||||||
|
|
|
||||||
|
|
@ -464,7 +464,7 @@ var templates = {
|
||||||
function(mode, wid, name, type, units, data)
|
function(mode, wid, name, type, units, data)
|
||||||
{
|
{
|
||||||
var padded4 = (data.length + 3) >> 2;
|
var padded4 = (data.length + 3) >> 2;
|
||||||
var pad = new Buffer( (padded4<<2) - data.length);
|
var pad = Buffer.alloc( (padded4<<2) - data.length);
|
||||||
var format = 'CCSLLLCxxxLaa';
|
var format = 'CCSLLLCxxxLaa';
|
||||||
var requestLength = 6 + padded4;
|
var requestLength = 6 + padded4;
|
||||||
var dataLenInFormatUnits = data.length / (units >> 3);
|
var dataLenInFormatUnits = data.length / (units >> 3);
|
||||||
|
|
@ -850,7 +850,7 @@ var templates = {
|
||||||
var padded = xutil.padded_length(data.length);
|
var padded = xutil.padded_length(data.length);
|
||||||
var reqLen = 6 + padded/4; // (length + 3) >> 2 ???
|
var reqLen = 6 + padded/4; // (length + 3) >> 2 ???
|
||||||
var padLength = padded - data.length;
|
var padLength = padded - data.length;
|
||||||
var pad = new Buffer(padLength); // TODO: new pack format 'X' - skip amount of bytes supplied in numerical argument
|
var pad = Buffer.alloc(padLength); // TODO: new pack format 'X' - skip amount of bytes supplied in numerical argument
|
||||||
|
|
||||||
// TODO: move code to calculate reqLength and use BigReq if needed outside of corereq.js
|
// TODO: move code to calculate reqLength and use BigReq if needed outside of corereq.js
|
||||||
// NOTE: big req is used here (first 'L' in format, 0 and +1 in params), won't work if not enabled
|
// NOTE: big req is used here (first 'L' in format, 0 and +1 in params), won't work if not enabled
|
||||||
|
|
@ -1020,6 +1020,12 @@ var templates = {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
Bell: [
|
||||||
|
function(percent) {
|
||||||
|
return ["CxCs",[108,1]];
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
ForceScreenSaver: [
|
ForceScreenSaver: [
|
||||||
function(activate) {
|
function(activate) {
|
||||||
return [ 'CCS', [115, activate?1:0, 1] ];
|
return [ 'CCS', [115, activate?1:0, 1] ];
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ exports.requireExt = function(display, callback)
|
||||||
ext.BindTexImage = function(ctx, drawable, buffer, attribs) {
|
ext.BindTexImage = function(ctx, drawable, buffer, attribs) {
|
||||||
if (!attribs)
|
if (!attribs)
|
||||||
attribs = [];
|
attribs = [];
|
||||||
var data = new Buffer(12 + attribs.length*4);
|
var data = Buffer.alloc(12 + attribs.length*4);
|
||||||
data.writeUInt32LE(drawable, 0);
|
data.writeUInt32LE(drawable, 0);
|
||||||
data.writeUInt32LE(buffer, 4);
|
data.writeUInt32LE(buffer, 4);
|
||||||
data.writeUInt32LE(attribs.length, 8);
|
data.writeUInt32LE(attribs.length, 8);
|
||||||
|
|
@ -268,7 +268,7 @@ exports.requireExt = function(display, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.ReleaseTexImage = function(ctx, drawable, buffer) {
|
ext.ReleaseTexImage = function(ctx, drawable, buffer) {
|
||||||
var data = new Buffer(8);
|
var data = Buffer.alloc(8);
|
||||||
data.writeUint32LE(drawable, 0);
|
data.writeUint32LE(drawable, 0);
|
||||||
data.writeUint32LE(buffer, 4);
|
data.writeUint32LE(buffer, 4);
|
||||||
ext.VendorPrivate(ctx, 1331, data);
|
ext.VendorPrivate(ctx, 1331, data);
|
||||||
|
|
@ -287,7 +287,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSLSSL', [ext.majorOpcode, 2, length, ctx, requestNum, requestTotal, data.length]);
|
X.pack_stream.pack('CCSLSSL', [ext.majorOpcode, 2, length, ctx, requestNum, requestTotal, data.length]);
|
||||||
|
|
||||||
X.pack_stream.write_queue.push(data);
|
X.pack_stream.write_queue.push(data);
|
||||||
var pad = new Buffer(padLength);
|
var pad = Buffer.alloc(padLength);
|
||||||
pad.fill(0);
|
pad.fill(0);
|
||||||
X.pack_stream.write_queue.push(pad);
|
X.pack_stream.write_queue.push(pad);
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ module.exports = function(GLX, ctx) {
|
||||||
throw Error('Buffer too big. Make sure you are using RenderLarge for large commands');
|
throw Error('Buffer too big. Make sure you are using RenderLarge for large commands');
|
||||||
|
|
||||||
currentLength += len;
|
currentLength += len;
|
||||||
var res = Buffer(len);
|
var res = Buffer.alloc(len);
|
||||||
res.writeUInt16LE(len, 0);
|
res.writeUInt16LE(len, 0);
|
||||||
res.writeUInt16LE(opcode, 2);
|
res.writeUInt16LE(opcode, 2);
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -266,7 +266,7 @@ module.exports = function(GLX, ctx) {
|
||||||
typeSize[constants.BYTE] = 1;
|
typeSize[constants.BYTE] = 1;
|
||||||
typeSize[constants.UNSIGNED_BYTE] = 1;
|
typeSize[constants.UNSIGNED_BYTE] = 1;
|
||||||
|
|
||||||
var res = new Buffer(60 + data.length*typeSize[type]);
|
var res = Buffer.alloc(60 + data.length*typeSize[type]);
|
||||||
res.writeUInt32LE(res.length, 0);
|
res.writeUInt32LE(res.length, 0);
|
||||||
res.writeUInt32LE(110, 4);
|
res.writeUInt32LE(110, 4);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@ exports.requireExt = function(display, callback)
|
||||||
glyph = glyphs[i];
|
glyph = glyphs[i];
|
||||||
if (glyph.width % 4 !== 0) {
|
if (glyph.width % 4 !== 0) {
|
||||||
var stride = (glyph.width+3)&~3;
|
var stride = (glyph.width+3)&~3;
|
||||||
var res = new Buffer(glyph.height*stride);
|
var res = Buffer.alloc(glyph.height*stride);
|
||||||
res.fill(0);
|
res.fill(0);
|
||||||
for (var y=0; y < glyph.height; ++y) {
|
for (var y=0; y < glyph.height; ++y) {
|
||||||
glyph.image.copy(res, y*stride, y*glyph.width, y*glyph.width + glyph.width);
|
glyph.image.copy(res, y*stride, y*glyph.width, y*glyph.width + glyph.width);
|
||||||
|
|
@ -503,7 +503,7 @@ exports.requireExt = function(display, callback)
|
||||||
function wstring(bits, s) {
|
function wstring(bits, s) {
|
||||||
var charLength = bits / 8;
|
var charLength = bits / 8;
|
||||||
var dataLength = s.length*charLength;
|
var dataLength = s.length*charLength;
|
||||||
var res = new Buffer(xutil.padded_length(dataLength));
|
var res = Buffer.alloc(xutil.padded_length(dataLength));
|
||||||
debugger;
|
debugger;
|
||||||
var write = res[bufferWriteBits[bits]]
|
var write = res[bufferWriteBits[bits]]
|
||||||
res.fill(0);
|
res.fill(0);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
// It should create a pleasant looking hex dumb by default:
|
// It should create a pleasant looking hex dumb by default:
|
||||||
//
|
//
|
||||||
// var hexy = require('hexy.js'),
|
// var hexy = require('hexy.js'),
|
||||||
// b = new Buffer("\000\001\003\005\037\012\011bcdefghijklmnopqrstuvwxyz0123456789")
|
// b = Buffer.alloc("\000\001\003\005\037\012\011bcdefghijklmnopqrstuvwxyz0123456789")
|
||||||
//
|
//
|
||||||
// console.log(hexy.hexy(b))
|
// console.log(hexy.hexy(b))
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ function ReadFixedRequest(length, callback)
|
||||||
{
|
{
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
this.data = new Buffer(length);
|
this.data = Buffer.alloc(length);
|
||||||
this.received_bytes = 0;
|
this.received_bytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,7 +201,7 @@ UnpackStream.prototype.pstr = function(str)
|
||||||
var len = xutil.padded_length(str.length);
|
var len = xutil.padded_length(str.length);
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return; // nothing to write
|
return; // nothing to write
|
||||||
var buf = new Buffer(len);
|
var buf = Buffer.alloc(len);
|
||||||
buf.write(str, 'binary');
|
buf.write(str, 'binary');
|
||||||
this.write_queue.push(buf);
|
this.write_queue.push(buf);
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +231,7 @@ UnpackStream.prototype.pack = function(format, args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf = new Buffer(packetlength);
|
var buf = Buffer.alloc(packetlength);
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
var arg = 0;
|
var arg = 0;
|
||||||
for (var i = 0; i < format.length; ++i)
|
for (var i = 0; i < format.length; ++i)
|
||||||
|
|
@ -269,12 +269,14 @@ UnpackStream.prototype.pack = function(format, args)
|
||||||
buf[offset++] = (n >> 16) & 0xff;
|
buf[offset++] = (n >> 16) & 0xff;
|
||||||
buf[offset++] = (n >> 24) & 0xff;
|
buf[offset++] = (n >> 24) & 0xff;
|
||||||
break;
|
break;
|
||||||
case 'a': // string or buffer
|
case 'a': // string, buffer, or array
|
||||||
var str = args[arg++];
|
var str = args[arg++];
|
||||||
if (Buffer.isBuffer(str))
|
if (Buffer.isBuffer(str))
|
||||||
{
|
{
|
||||||
str.copy(buf, offset);
|
str.copy(buf, offset);
|
||||||
offset += str.length;
|
offset += str.length;
|
||||||
|
} else if(Array.isArray(str)) {
|
||||||
|
for(var item of str) buf[offset++] = item;
|
||||||
} else {
|
} else {
|
||||||
// TODO: buffer.write could be faster
|
// TODO: buffer.write could be faster
|
||||||
for (var c = 0; c < str.length; ++c)
|
for (var c = 0; c < str.length; ++c)
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,7 @@ XClient.prototype.expectReplyHeader = function()
|
||||||
|
|
||||||
// raw event 32-bytes packet (primarily for use in SendEvent);
|
// raw event 32-bytes packet (primarily for use in SendEvent);
|
||||||
// TODO: Event::pack based on event parameters, inverse to unpackEvent
|
// TODO: Event::pack based on event parameters, inverse to unpackEvent
|
||||||
ev.rawData = new Buffer(32);
|
ev.rawData = Buffer.alloc(32);
|
||||||
headerBuf.copy(ev.rawData);
|
headerBuf.copy(ev.rawData);
|
||||||
buf.copy(ev.rawData, 8);
|
buf.copy(ev.rawData, 8);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ describe('ChangeProperty', function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.X.InternAtom(false, TEST_PROPERTY, function(err, atom) {
|
this.X.InternAtom(false, TEST_PROPERTY, function(err, atom) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
var raw = new Buffer(4);
|
var raw = Buffer.alloc(4);
|
||||||
raw.writeUInt32LE(self.wid, 0);
|
raw.writeUInt32LE(self.wid, 0);
|
||||||
self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.WINDOW, 32, raw);
|
self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.WINDOW, 32, raw);
|
||||||
self.X.once('event', function(ev) {
|
self.X.once('event', function(ev) {
|
||||||
|
|
@ -47,7 +47,7 @@ describe('ChangeProperty', function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.X.InternAtom(false, TEST_PROPERTY, function(err, atom) {
|
this.X.InternAtom(false, TEST_PROPERTY, function(err, atom) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
var raw = new Buffer(new Array(8));
|
var raw = Buffer.from(new Array(8));
|
||||||
raw.writeUInt32LE(self.wid, 0);
|
raw.writeUInt32LE(self.wid, 0);
|
||||||
raw.writeUInt32LE(self.wid_helper, 4);
|
raw.writeUInt32LE(self.wid_helper, 4);
|
||||||
self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.ATOM, 32, raw);
|
self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.ATOM, 32, raw);
|
||||||
|
|
@ -69,7 +69,7 @@ describe('ChangeProperty', function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.X.InternAtom(false, TEST_PROPERTY, function(err, atom) {
|
this.X.InternAtom(false, TEST_PROPERTY, function(err, atom) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
var raw = new Buffer(0);
|
var raw = Buffer.alloc(0);
|
||||||
self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.WINDOW, 32, raw);
|
self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.WINDOW, 32, raw);
|
||||||
self.X.once('event', function(ev) {
|
self.X.once('event', function(ev) {
|
||||||
ev.type.should.equal(28);
|
ev.type.should.equal(28);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ describe('ClientMessage', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var X = dpy.client;
|
var X = dpy.client;
|
||||||
var eventData = new Buffer(32);
|
var eventData = Buffer.alloc(32);
|
||||||
eventData.writeInt8(33, 0); //Event Type 33 = ClientMessage
|
eventData.writeInt8(33, 0); //Event Type 33 = ClientMessage
|
||||||
eventData.writeInt8(8, 1); //Format
|
eventData.writeInt8(8, 1); //Format
|
||||||
eventData.writeInt32LE(self.wid, 4); //Window ID
|
eventData.writeInt32LE(self.wid, 4); //Window ID
|
||||||
|
|
@ -67,7 +67,7 @@ describe('ClientMessage', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var X = dpy.client;
|
var X = dpy.client;
|
||||||
var eventData = new Buffer(32);
|
var eventData = Buffer.alloc(32);
|
||||||
eventData.writeInt8(33, 0); //Event Type 33 = ClientMessage
|
eventData.writeInt8(33, 0); //Event Type 33 = ClientMessage
|
||||||
eventData.writeInt8(16, 1); //Format
|
eventData.writeInt8(16, 1); //Format
|
||||||
eventData.writeInt32LE(self.wid, 4); //Window ID
|
eventData.writeInt32LE(self.wid, 4); //Window ID
|
||||||
|
|
@ -94,7 +94,7 @@ describe('ClientMessage', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var X = dpy.client;
|
var X = dpy.client;
|
||||||
var eventData = new Buffer(32);
|
var eventData = Buffer.alloc(32);
|
||||||
eventData.writeInt8(33, 0); //Event Type 33 = ClientMessage
|
eventData.writeInt8(33, 0); //Event Type 33 = ClientMessage
|
||||||
eventData.writeInt8(32, 1); //Format
|
eventData.writeInt8(32, 1); //Format
|
||||||
eventData.writeInt32LE(self.wid, 4); //Window ID
|
eventData.writeInt32LE(self.wid, 4); //Window ID
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue