Refactoring of functions that operate with editor buffer.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>