From 0191990eca2a30d29f3dd4878f017271bec32a63 Mon Sep 17 00:00:00 2001 From: Daniil Rozanov Date: Fri, 4 Apr 2025 14:50:18 +0400 Subject: wip --- include/ncurses/basic_winbuf.hpp | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 include/ncurses/basic_winbuf.hpp (limited to 'include/ncurses/basic_winbuf.hpp') diff --git a/include/ncurses/basic_winbuf.hpp b/include/ncurses/basic_winbuf.hpp new file mode 100644 index 0000000..adc424a --- /dev/null +++ b/include/ncurses/basic_winbuf.hpp @@ -0,0 +1,48 @@ +#ifndef INCLUDE_NCURSES_BASIC_WINBUF_HPP_ +#define INCLUDE_NCURSES_BASIC_WINBUF_HPP_ + +#include + +#include + +#include +#include + +namespace NCURSES_CPP_NAMESPACE { + +template > +class basic_winbuf final : public std::basic_streambuf { +public: + using Base = std::basic_streambuf; + using typename Base::char_type; + using typename Base::int_type; + using typename Base::off_type; + using typename Base::pos_type; + + explicit basic_winbuf(window &win) : win_(win), x_pos_(0), y_pos_(0) {} + + /*int_type uflow() override {}*/ + /*int_type underflow() override {}*/ + int_type overflow(int_type ch = Traits::eof()) override {} + std::streamsize xsputn(const char_type *s, std::streamsize n) override { + // TODO: change to call to new trait's callback for each supported type + // for char/wchar_t/other_chars use wadd(w)nstr + // for curs_char/curs_wchar use for loop of wadd(w)ch + waddnstr(static_cast(win_), s, n); + } + // TODO: overload << operator with full_attrs to do attr_on, etc... + + void pos(int y_pos, int x_pos) NCURSES_CPP_NOEXCEPT { + y_pos_ = y_pos; + x_pos_ = x_pos; + } + +private: + window &win_; + int x_pos_; + int y_pos_; +}; + +} // namespace NCURSES_CPP_NAMESPACE + +#endif // INCLUDE_NCURSES_BASIC_WINBUF_HPP_ -- cgit v1.2.3