[RDY] Refactor input buffer-related code

Some cleanup of input buffer code(moved from ui.c to os/input.c). Still needs some tests(for `'termencoding'`, though it will be irrelevant once all terminal code is externalized to a UI)
We need `rv->rstream = NULL` otherwise `input_buffer` could try to start/stop the uninitialized stream.