diff --git a/src/utils.cpp b/src/utils.cpp index 42a1e71..08b9345 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -66,3 +66,12 @@ cursor_hider::cursor_hider(std::ostream* out) : _out {out} { cursor_hider::~cursor_hider() { *_out << io::show_cursor; } + +// ------------------------------------------------------------------------ + +sc::io::clear_line::clear_line(const term& t) : _term {t} {} + +std::ostream& sc::io::operator<<(std::ostream& out, const sc::io::clear_line& obj) { + out << '\r' << std::string(obj._term.cols(), ' ') << '\r'; + return out; +} diff --git a/src/utils.hpp b/src/utils.hpp index 5776c91..9f84843 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -33,6 +33,17 @@ namespace sc { ~cursor_hider(); }; + namespace io { + + class clear_line { + const term& _term; + + public: + clear_line(const term& t); + friend std::ostream& operator<<(std::ostream& out, const clear_line& obj); + }; + + } } #endif // UTILS_H_