Closed ghost closed 9 years ago
Thanks for the PR!
I definitely agree that we should handle out of bounds indexes without crashing, and possibly leaving the TTY in a messed up state on exit. I chose to use term[y][x]
primarily for ergonomic reasons and didn't consider handling out of bounds indexes, however this is definitely something we should address.
I like what you have proposed, and I'm happy to merge it. Luckily since we're only version 0.1.3 (0.1.4 after this commit), we can still break things before committing to a stable API.
I've got a pretty free week coming up so I'll be able to put in a lot more work on this; I'm planning on finishing tidying up the driver module tomorrow and then I'll take a closer look at our cellbuffer implementation.
Accessing out of bounds indexes would make us panic (without message because of our messing up with the TTY). This commits handles out of bounds errors be returning a dummy cell.
This required to change the indexing API from
term[y][x]
toterm[(y, x)]
because otherwise, we would have had to overrideVec
's indexing methods (our rows are plain vectors and although our first indexing go throughCellBuffer
's indexing implementation, our second indexing is handled directly byVec
).The old API was left there for now, to avoid breakeage.
@cpjreynolds, what do you think of the proposed indexing API? Is there a particular reason why
term[y][x]
was chosen instead ofterm[(y, x)]
in the first place?