1

Is it possible to take control of the entire tab-completion feature in JQuery.Terminal? I want to manage the autocompletion that's displayed.

For instance, I want to support templates/regex so that I can do things like "visualize campaign CAMPAIGN_NAME where config = SOMETHING". I could write my own parser and handler for all this, but I'm not sure how/where to plug it in?

Nick
  • 4,002
  • 4
  • 30
  • 41

1 Answers1

1

In initialization settings, you need to make sure that the completion attribute is not set (default is false).

Then, you need to intercept the keydown function and handle the key you're interested in (tab in my case).

In there you can provide your own handler for auto-completion logic:

$('#terminal').terminal(function (command, term) 
        {
            // Command handlers
        },
        {
            keydown: function(event, term) {

            if (event.keyCode == 9) //Tab
            {
                // Call handler to handle your auto-completion logic

                // Sample to print stuff to the console and update the command
                term.echo("autocompletion commands...");
                term.set_command(term.get_command() + " completion text");

                // Tells the terminal to not handle the tab key
                return false;
            }
        }
    });
});
Nick
  • 4,002
  • 4
  • 30
  • 41