Permalink
Browse files

Bunch of small bugfixes to set the stage for larger changes

  • Loading branch information...
1 parent 00c34a7 commit 5526e699542136e804dc673c7b7f7fbdab8d2ddb @Benvie committed Apr 3, 2012
Showing with 22 additions and 7 deletions.
  1. +1 −1 lib/ScopedModule.js
  2. +1 −1 lib/UltraREPL.js
  3. +17 −3 lib/utility/string-utils.js
  4. +3 −2 package.json
View
@@ -17,7 +17,7 @@ var vm, NativeModule;
})();
// Hide the pages and pages of sourcecode in case inspected in the REPL
-try { Object.defineProperty(NativeModule, '_source', { enumerable: false }); } catch(e){console.log(NativeModule)}
+try { Object.defineProperty(NativeModule, '_source', { enumerable: false }); } catch(e){ console.log(e)}
var util = require('util');
View
@@ -198,7 +198,7 @@ UltraREPL.prototype = {
var output = [];
var width = this.width || 60;
function header(text, color){
- return (' ' + text).pad(width).color(color);
+ return (' ' + text).pad(width+1).color(color);
}
if (result.error) {
@@ -6,27 +6,40 @@ function chunk(split, bounds, indent, source){
} else if (typeof this === 'string') {
source = this;
}
+
source += split;
bounds = Array.isArray(bounds) ? bounds : [bounds - 10, bounds]
var regex = new RegExp('.{'+bounds+'}'+split, 'g');
var result = [];
var match;
+ var total=0;
while (match = regex.exec(source)) {
result.push(match[0].slice(split.length));
+ total += result[result.length-1].length-split.length;
regex.lastIndex -= split.length;
}
- result[0] = source.slice(0, split.length) + result[0];
- result.push(result.pop().slice(0, -split.length));
+ if (result.length === 0) {
+ result = [source];
+ } else {
+ result[0] = source.slice(0, split.length) + result[0];
+ if (result.length > 1){
+ result.push(result.pop().slice(0, -split.length));
+ total += split.length;
+ }
+ var remainder = source.length-total;
+ if (remainder > 0) {
+ result.push(source.slice(total+(split.length*2)));
+ }
+ }
if (indent > 0) {
indent = space(indent);
return result.map(function(s){ return indent + s }).join('\n');
}
return result;
}
-var ansimatch = /\033\[(?:\d+;)*\d+m/g;
function ansilength(str){
return str.replace(ansimatch, '').length;
@@ -180,3 +193,4 @@ function columns(array){
if (typeof array[0] === 'string') array = [array];
return array.reduce(f, dense(array[0].length));
}
+
View
@@ -2,7 +2,7 @@
"author": "Brandon Benvie <brandon@bbenvie.com> (http://bbenvie.com)",
"name": "ultra-repl",
"description": "Starting with Node's built in REPL, add in a completely redone inspect formatter, actual functioning separate V8 contexts, keybindings to create, switch, and delete between them, combine it with a bunch of color. ULTRA REPL.",
- "version": "0.7.5",
+ "version": "0.7.6",
"keywords": ["repl", "context", "colors", "command line", "cli", "editor", "tty", "options", "toggle"],
"homepage": "https://github.com/Benvie/Node.js-Ultra-REPL",
"repository": {
@@ -17,6 +17,7 @@
"ultra-repl": "bin/ultra-repl.js"
},
"dependencies": {
- "esprima": ">=0.9.7"
+ "esprima": ">=0.9.7",
+ "repl-rainbow": "~0.0.3"
}
}

0 comments on commit 5526e69

Please sign in to comment.