rstream: Extract some RStream functionality to RBuffer

RBuffer instances represent the internal buffer used by RStreams.

This changes RStream constructor to receive RBuffer pointers and adds a set of
RBuffer methods that expose the lower level buffer manipulation to consumers of
the RStream API.
ui: Refactor input buffer handling

All input buffer code was moved to os/input.c, and `inbuf` is now a `RBuffer`
instance(which abstracts static buffer manipulation).
Merge PR #1300 'Refactor input buffer'