ajaxorg/cloud9 — pull request #878 by sergi (2012-01-29 13:07:26+00:00)
Title: The Console Refactor

This refactor shoves around 1000 lines away from our Console plugin, keeping all the functionality, improving speed and fixing some bugs. The code was very tightly coupled and there was too much hardcoded variables and conditions. The code is now more modular, clearer and maintanable. The high-level changes are the following:

- Separation of `Console` and `ConsoleHints` into two different plugins.
- The console is completely independent of the hint/autocompletion system and has a bit less knowledge of the `view` part of the plugin.

- The console is much more extensible due to having abstracted away its key-handling and message-listening parts. Note how `ConsoleHints` makes use of this extensibility.

- Autocompletion is not based on Tries anymore
- Our search/autocompletion scenario is very simple, and using tries for that purpose is overkill. Tries are great for massive dictionary-like lists, but counter-productive for wordlists like ours, which contains 20 entries at its maximum length..
- This saves a lot of space by avoiding loading an unnecessary third-party library to filter console commands
- In my tests, search is now much faster (and uses less memory). Our current search function is `filterCommands`, located in `consolehints.js`.

- Lazy evaluation has been used whenever possible. This is noticeable in the Logger (which ideally should be it's own plugin, application-wide)

- Buffer balancing (deleting old output lines in the console) has been optimized and shouldn't bring the browser to its knees when having a massive and continuous amount of output.
- There are tests for essential components such as the `Parser` and the `Logger`.
- CSS cleanup

Testing procedure
--------------------------

In order to test the new console behavior, please enter random commands in it, test auto completion for first and second level completion (keywords like `git` should have autocompletion for sub-commands). Make sure that IO works as expected and that no visual glitches or other problems affect the console.

Please @zefhemel AND @janjongboom review.