Skip to content

Commit

Permalink
cleanup and fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Aug 11, 2015
1 parent 5e143e7 commit a79e810
Show file tree
Hide file tree
Showing 39 changed files with 282 additions and 361 deletions.
18 changes: 10 additions & 8 deletions lib/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ exports.mixColors = function(c1, c2, alpha) {
};

exports.blend = function blend(attr, attr2, alpha) {
var name, i, c, nc;

var bg = attr & 0x1ff;
if (attr2 != null) {
var bg2 = attr2 & 0x1ff;
Expand All @@ -136,12 +138,12 @@ exports.blend = function blend(attr, attr2, alpha) {
} else if (bg >= 8 && bg <= 15) {
bg -= 8;
} else {
var name = exports.ncolors[bg];
name = exports.ncolors[bg];
if (name) {
for (var i = 0; i < exports.ncolors.length; i++) {
for (i = 0; i < exports.ncolors.length; i++) {
if (name === exports.ncolors[i] && i !== bg) {
var c = exports.vcolors[bg];
var nc = exports.vcolors[i];
c = exports.vcolors[bg];
nc = exports.vcolors[i];
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
blend._cache[bg] = i;
bg = i;
Expand Down Expand Up @@ -176,12 +178,12 @@ exports.blend = function blend(attr, attr2, alpha) {
} else if (fg >= 8 && fg <= 15) {
fg -= 8;
} else {
var name = exports.ncolors[fg];
name = exports.ncolors[fg];
if (name) {
for (var i = 0; i < exports.ncolors.length; i++) {
for (i = 0; i < exports.ncolors.length; i++) {
if (name === exports.ncolors[i] && i !== fg) {
var c = exports.vcolors[fg];
var nc = exports.vcolors[i];
c = exports.vcolors[fg];
nc = exports.vcolors[i];
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
blend._cache[fg] = i;
fg = i;
Expand Down
8 changes: 4 additions & 4 deletions lib/gpmclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
var net = require('net');
var fs = require('fs');
var EventEmitter = require('events').EventEmitter;
var util = require('util')

var GPM_USE_MAGIC = false;

Expand All @@ -33,8 +32,9 @@ var GPM_SOCKET = '/dev/gpmctl';
// } Gpm_Connect;

function send_config(socket, Gpm_Connect, callback) {
var buffer;
if (GPM_USE_MAGIC) {
var buffer = new Buffer(20);
buffer = new Buffer(20);
buffer.writeUInt32LE(GPM_MAGIC, 0);
buffer.writeUInt16LE(Gpm_Connect.eventMask, 4);
buffer.writeUInt16LE(Gpm_Connect.defaultMask, 6);
Expand All @@ -43,7 +43,7 @@ function send_config(socket, Gpm_Connect, callback) {
buffer.writeInt16LE(process.pid, 12);
buffer.writeInt16LE(Gpm_Connect.vc, 16);
} else {
var buffer = new Buffer(16);
buffer = new Buffer(16);
buffer.writeUInt16LE(Gpm_Connect.eventMask, 0);
buffer.writeUInt16LE(Gpm_Connect.defaultMask, 2);
buffer.writeUInt16LE(Gpm_Connect.minMod, 4);
Expand Down Expand Up @@ -183,7 +183,7 @@ function GpmClient(options) {
}
});

gpm.on('error', function(err) {
gpm.on('error', function() {
self.stop();
});
});
Expand Down
3 changes: 1 addition & 2 deletions lib/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// IN THE SOFTWARE.

var EventEmitter = require('events').EventEmitter;
var StringDecoder = require('string_decoder').StringDecoder;

// NOTE: node <=v0.8.x has no EventEmitter.listenerCount
function listenerCount(stream, event) {
Expand Down Expand Up @@ -56,7 +55,7 @@ function emitKeypressEvents(stream) {
}

function onNewListener(event) {
if (event == 'keypress') {
if (event === 'keypress') {
stream.on('data', onData);
stream.removeListener('newListener', onNewListener);
}
Expand Down
Loading

0 comments on commit a79e810

Please sign in to comment.