Comparing version 0.0.6 to 0.0.7
53
cdir.js
@@ -17,2 +17,4 @@ | ||
var lastsearch = ''; | ||
var repeat = false; | ||
var lastIndex = 0; | ||
@@ -330,2 +332,3 @@ var meta = [], map = [0]; | ||
var started = false; | ||
var toggledCount = 0; | ||
@@ -355,2 +358,3 @@ if (meta[index].type === 'string' && | ||
started = true; | ||
toggledCount++; | ||
} | ||
@@ -374,2 +378,3 @@ else if (started && meta[i].depth < next) { | ||
started = true; | ||
toggledCount++; | ||
} | ||
@@ -392,2 +397,3 @@ else if (started && meta[i].depth < next) { | ||
renderMeta(); | ||
return toggledCount; | ||
} | ||
@@ -432,14 +438,16 @@ | ||
// | ||
// preserve the old selection in case nothing is found. | ||
// | ||
var oldSelection = selection; | ||
selection = 0; | ||
// | ||
// if the user enters nothing, assume we want to repeat the last search. | ||
// | ||
if (searchbuffer === '') { | ||
searchbuffer = lastsearch; | ||
repeat = true; | ||
} | ||
else { | ||
// | ||
// start from the top if this is a unique search. | ||
// | ||
selection = 0; | ||
repeat = false; | ||
} | ||
@@ -469,14 +477,21 @@ | ||
for (var i = selection, l = meta.length; i < l; i++) { | ||
var l = meta.length; | ||
var startIndex = meta[selection].index; | ||
if (repeat) { | ||
startIndex = lastIndex + 1; | ||
} | ||
for (var i = startIndex; i < l; i++) { | ||
// | ||
// if there is a match | ||
// | ||
if (regexp.test(meta[i].description)) { | ||
// | ||
// we have a match now we need to unfold the appropriate nodes. | ||
// | ||
var currentDepth = meta[i].depth; | ||
var currentSelection = meta[i].index; | ||
var newSelection = 0; | ||
var matchedIndex = meta[i].index; | ||
found = true; | ||
lastIndex = meta[i].index; | ||
@@ -487,4 +502,4 @@ for (var j = i; j >= 0; j--) { | ||
currentDepth--; | ||
if (meta[j].expanded === false) { | ||
currentDepth--; | ||
toggle(j); | ||
@@ -495,8 +510,7 @@ } | ||
for (var i = 0, l = meta.length; i < l; i++) { | ||
if (meta[i].displayed === true) { | ||
newSelection++; | ||
for (var k = 0; k < l; k++) { | ||
if (meta[k].displayed === true) { | ||
selection++; | ||
} | ||
if (meta[i].index === currentSelection) { | ||
if (meta[k].index === matchedIndex) { | ||
break; | ||
@@ -507,3 +521,2 @@ } | ||
up(displayed); | ||
selection = newSelection; | ||
renderMeta(); | ||
@@ -513,2 +526,3 @@ break; | ||
} | ||
} | ||
@@ -519,2 +533,3 @@ | ||
write('Not found\r'); | ||
selection = oldSelection; | ||
} | ||
@@ -521,0 +536,0 @@ |
@@ -72,3 +72,3 @@ { | ||
"ensgines" : ["node >= 0.6.x"], | ||
"masin" : "./dir", | ||
"f2" : "./dir", | ||
"sscripts": { | ||
@@ -75,0 +75,0 @@ "test": "node tests/test.js" |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version" : "0.0.6", | ||
"version" : "0.0.7", | ||
"author" : "Paolo Fragomeni <paolo@nodejisu.com>", | ||
@@ -14,0 +14,0 @@ "repository" : { |
@@ -8,6 +8,13 @@ # Synopsis | ||
# Usage | ||
## Navigation | ||
First, require the module. Then use `console.dir(somecode)` in your program and then use `tab` or `shift+tab` to cycle through the object's members. You can hit `space`, `return` or `enter` to expand a member. See the example below. | ||
## Searching throught JSON | ||
Search by pressing the `/` key. This will display a `/` prompt. If you have already searched for something it will be displayed before the `/` prompt. For instance if you searched for "foobar" it would appear as `(foobar) /`. | ||
## How to quit | ||
Hit `ctrl+c` or `q` to quit! | ||
## An example | ||
There is a CLI version too if you want to use it. `npm install cdir -g`. | ||
@@ -14,0 +21,0 @@ |
108498
623
49