Permalink
Browse files

raw example, fix arrow codes

  • Loading branch information...
substack committed Aug 8, 2013
1 parent 5043f34 commit c8381cb8b3fcb56a190b006dea3959520ecb79c8
Showing with 26 additions and 3 deletions.
  1. +23 −0 example/raw.js
  2. +2 −2 index.js
  3. +1 −1 package.json
View
@@ -0,0 +1,23 @@
+#!/usr/bin/env node
+var bash = require('../');
+var fs = require('fs');
+
+var sh = bash({
+ env: process.env,
+ spawn: require('child_process').spawn,
+ write: fs.createWriteStream,
+ read: fs.createReadStream,
+ exists: fs.exists
+});
+
+process.stdin.on('data', function (buf) {
+ if (buf[0] === 3) process.exit();
+ if (buf[0] === 13) process.stdout.write('\n');
+ else if (buf[0] > 27 || buf[0] === 13) {
+ process.stdout.write(buf);
+ }
+});
+process.stdin.setRawMode(true);
+
+var s = sh.createStream();
+process.stdin.pipe(s).pipe(process.stdout);
View
@@ -82,7 +82,7 @@ Bash.prototype.createStream = function () {
}
else if (mode === '[' && c >= 65 && c <= 68) {
var dir = {
- A: 'left', B: 'up', C: 'right', D: 'down'
+ A: 'up', B: 'down', C: 'right', D: 'left'
}[String.fromCharCode(c)];
if (dir === 'left' && self._cursorX) {
@@ -205,7 +205,7 @@ Bash.prototype.createStream = function () {
}
return write(buf.slice(i + 1));
}
- else if (c === 10) {
+ else if (c === 10 || c === 13) {
this.queue(line);
if (line.length) {
self.history.push(line);
View
@@ -1,6 +1,6 @@
{
"name": "bashful",
- "version": "1.3.2",
+ "version": "1.4.0",
"description": "parse and execute bash without doing any IO",
"main": "index.js",
"dependencies": {

0 comments on commit c8381cb

Please sign in to comment.