cpjreynolds / rustty

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

Major refactoring of CellBuffer API. #6

Closed cpjreynolds closed 9 years ago

cpjreynolds commented 9 years ago

This PR implements a major refactoring of the CellBuffer API and makes breaking changes to the Terminal interface.

Breaking changes:

Note: Out-of-bounds indexing with the index operator WILL panic and WILL cause the tty to be left in and indeterminate and possibly broken state. Rust does not guarantee that drop will run, so we cannot guarantee that the terminal state will be restored on panic. If you are not sure your index will be in bounds, use get and get_mut. This is especially important if the terminal re-sizes and your application is not prepared.

ghost commented 9 years ago

This mimics Vec's behavior, so it's a better idea than silently returning a dummy cell.

ghost commented 9 years ago

@cpjreynolds, as I looked more closely, I noticed that you inverted what was previously (y, x) into (x, y) everywhere. I just want to point out that this breaks with ncurses' convention. Not that it's necessarily a bad thing, but I thought it was worth mentioning.

cpjreynolds commented 9 years ago

@hsoft, regarding swapping (y, x) for (x, y). I thought about keeping it the same as ncurses' convention, but I found myself continually getting caught up confusing (y, x) with the more traditional (x, y). Since the actual indexing is all abstracted by the library anyway, it would be trivial to extend it later on to include (y, x) indexing if there is demand.