Skip to content

Commit

Permalink
Merge pull request heapwolf#13 from st-luke/master
Browse files Browse the repository at this point in the history
Added an option to show line numbers
  • Loading branch information
Paolo Fragomeni committed Apr 28, 2012
2 parents c235023 + 2433184 commit 934361c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -20,6 +20,9 @@ Use `console.dir(someobject)` somewhere in your program and then hit `tab`, `shi
## Search
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) /`.

## Line Numbers
You can add comprehensive line numbers by pressing `:` while not in search mode. These line numbers include collapsed nodes so expanding one will not change numbers of later items.

## Quit
Hit `ctrl+c` or `q` to quit!

Expand Down
14 changes: 14 additions & 0 deletions cdir.js
Expand Up @@ -16,6 +16,7 @@ var searchbuffer = '';
var lastsearch = '';
var repeat = false;
var lastIndex = 0;
var linemode = false;

var meta = [], map = [0];

Expand Down Expand Up @@ -279,6 +280,9 @@ var renderMeta = function renderMeta () {
write(meta[i].description.replace(/\033\[[0-9;]*m/g, '') + '\n');
write('\033[0m');
}
else if (linemode === true) {
write(meta[i].index + ': ' + meta[i].description + '\n');
}
else {
write(meta[i].description + '\n');
}
Expand Down Expand Up @@ -559,6 +563,16 @@ var listener = function listener (chunk, key) {
}

}

//
// Toggle for linemode
//
if (chunk === ':' && searchmode === false) {
linemode ? linemode = false : linemode = true;
up(displayed);
renderMeta();
}

};

if (typeof JSON.decycle !== 'function') {
Expand Down

0 comments on commit 934361c

Please sign in to comment.