Permalink
Browse files

tab completion for commands in debugger

  • Loading branch information...
1 parent fc634cd commit 1b63bd16ed56df5d03f04da6c19f9a50a451b638 @ry ry committed Jan 12, 2011
Showing with 37 additions and 1 deletion.
  1. +37 −1 lib/_debugger.js
View
38 lib/_debugger.js
@@ -351,7 +351,10 @@ function SourceInfo(body) {
// "node debug"
function Interface() {
var self = this;
- var term = this.term = readline.createInterface(process.stdout);
+ var term = this.term =
+ readline.createInterface(process.stdout, function (line) {
+ return self.complete(line);
+ });
var child;
var client;
var term;
@@ -396,6 +399,39 @@ function Interface() {
}
+var commands = [
+ 'backtrace',
+ 'continue',
+ 'help',
+ 'info breakpoints',
+ 'kill',
+ 'list',
+ 'next',
+ 'print',
+ 'quit',
+ 'run',
+ 'scripts',
+ 'step',
+ 'version',
+];
+
+
+Interface.prototype.complete = function(line) {
+ // Match me with a command.
+ var matches = [];
+ // Remove leading whitespace
+ line = line.replace(/^\s*/, '');
+
+ for (var i = 0; i < commands.length; i++) {
+ if (commands[i].indexOf(line) >= 0) {
+ matches.push(commands[i]);
+ }
+ }
+
+ return [matches, line];
+};
+
+
Interface.prototype.handleSIGINT = function() {
if (this.paused) {
this.child.kill('SIGINT');

0 comments on commit 1b63bd1

Please sign in to comment.