cpjreynolds / rustty

A terminal UI library
https://docs.rs/rustty
MIT License
153 stars 14 forks source link

Checking terminal capabilities on each operation #45

Open gridbugs opened 8 years ago

gridbugs commented 8 years ago

Hi again. This is a more controversial change than my previous one as it removes the capability check during initialization. When a terminal tries to perform some function, it only sends the relevant sequence if the terminal actually has that capability. The result is this library now works on more terminals (I specifically made this change because the library didn't work on urxvt due to a lack of "cnorm"). I tested it on urxvt/gnome-terminal and it appears to work fine, though I guess it's possible to run the library on an incompatible terminal and have it produce garbled output where previously it would have bailed out during init. Let me know what you think.

This removes the check performed during driver initialization that ensures the terminal supports all the required capabilities. Driver::get now returns an Option<_> which is Some("escape sequence") if the terminal has the requested functionality, and None otherwise.