mozilla/rust — pull request #14013 by erinui (2014-05-07 09:29:53+00:00)
Title: libterm: Use Windows Console API to color texts.

This patch adds the coloring function on Windows console to libterm.
Fixes #13400, and makes working on MSYS slightly more pleasant.

*Quick Notes*
- Extract `trait TerminalOps` from `Terminal`.
- Add `struct WindowsConsole` along with `Terminal`, both implements `TerminalOps`.
- `term::Terminal::new` is now `term::new_terminal`, returns `~TerminalOps`.
- Windows-specific code, including `WindowsConsole`, is in the module `windows`.
- It will assume it's running on terminal that understands ASCII if $TERM is "xterm". Attempts to not break rxvt.exe.
- It spams `:Send` to deal with libsyntax, which packs Terminal into a RefCell. I couldn't come up with any smarter fix.

I had to remove `Terminal::unwrap()` to implement `Drop` on `WindowsConsole`, thus it lose the way to manually destroy itself. I suppose it's okay, since I couldn't find any use of it in the tree.
Also, it will not be possible to access the members of `Terminal`, such as TermInfo. It's still possible to see terminfo by calling `term::terminfo::parser::compiled::parse`, though.

As this is Windows-only improvement, I'm not sure about breaking change is acceptable. I can consider more humble way to do this, if it doesn't pay.