summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaniil Rozanov <dev@rozanov.info>2025-03-15 18:03:23 +0400
committerDaniil Rozanov <dev@rozanov.info>2025-03-15 18:03:23 +0400
commit4a9ce6e2555dfaf9155fa279f25667350377f688 (patch)
tree11bc0ea3a7b1c0be2c47419b7058d46d16e5f9f4 /include
feat: chtype wrap
Diffstat (limited to 'include')
-rw-r--r--include/ncurses/acs.hpp164
-rw-r--r--include/ncurses/char_attributes.hpp40
-rw-r--r--include/ncurses/colors.hpp87
-rw-r--r--include/ncurses/core.hpp6
-rw-r--r--include/ncurses/curs_char.hpp203
-rw-r--r--include/ncurses/keys.hpp174
-rw-r--r--include/ncurses/mouse_events.hpp47
-rw-r--r--include/ncurses/ncurses.hpp4
-rw-r--r--include/ncurses/types.hpp69
-rw-r--r--include/ncurses/utils/flags.hpp156
-rw-r--r--include/ncurses/utils/macros.hpp50
-rw-r--r--include/ncurses/utils/modifiers.hpp31
-rw-r--r--include/ncurses/utils/multiflags.hpp202
-rw-r--r--include/ncurses/utils/preamble.hpp8
-rw-r--r--include/ncurses/window.hpp17
15 files changed, 1258 insertions, 0 deletions
diff --git a/include/ncurses/acs.hpp b/include/ncurses/acs.hpp
new file mode 100644
index 0000000..5686385
--- /dev/null
+++ b/include/ncurses/acs.hpp
@@ -0,0 +1,164 @@
+#ifndef INCLUDE_NCURSES_ACS_HPP_
+#define INCLUDE_NCURSES_ACS_HPP_
+
+#include <ncurses/utils/flags.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+template <char U> class acs_type {
+public:
+ operator chtype() const NCURSES_CPP_NOEXCEPT { return NCURSES_ACS(U); }
+};
+
+namespace acs {
+
+static const auto ulcorner = acs_type<'l'>();
+static const auto llcorner = acs_type<'m'>();
+static const auto urcorner = acs_type<'k'>();
+static const auto lrcorner = acs_type<'j'>();
+static const auto ltee = acs_type<'t'>();
+static const auto rtee = acs_type<'u'>();
+static const auto btee = acs_type<'v'>();
+static const auto ttee = acs_type<'w'>();
+static const auto hline = acs_type<'q'>();
+static const auto vline = acs_type<'x'>();
+static const auto plus = acs_type<'n'>();
+static const auto s1 = acs_type<'o'>();
+static const auto s9 = acs_type<'s'>();
+static const auto diamond = acs_type<'`'>();
+static const auto ckboard = acs_type<'a'>();
+static const auto degree = acs_type<'f'>();
+static const auto plminus = acs_type<'g'>();
+static const auto bullet = acs_type<'~'>();
+static const auto larrow = acs_type<','>();
+static const auto rarrow = acs_type<'+'>();
+static const auto darrow = acs_type<'.'>();
+static const auto uarrow = acs_type<'-'>();
+static const auto board = acs_type<'h'>();
+static const auto lantern = acs_type<'i'>();
+static const auto block = acs_type<'0'>();
+static const auto s3 = acs_type<'p'>();
+static const auto s7 = acs_type<'r'>();
+static const auto lequal = acs_type<'y'>();
+static const auto gequal = acs_type<'z'>();
+static const auto pi = acs_type<'{'>();
+static const auto nequal = acs_type<'|'>();
+static const auto sterling = acs_type<'}'>();
+
+}; // namespace acs
+
+template <char U> class wacs_type {
+public:
+ // TODO: maybe not const, maybe smart ptr
+ operator const cchar_t *() const NCURSES_CPP_NOEXCEPT {
+ return NCURSES_WACS(U);
+ }
+};
+
+namespace wacs {
+
+static const auto bssb = wacs_type<'l'>();
+static const auto ssbb = wacs_type<'m'>();
+static const auto bbss = wacs_type<'k'>();
+static const auto sbbs = wacs_type<'j'>();
+static const auto sbss = wacs_type<'u'>();
+static const auto sssb = wacs_type<'t'>();
+static const auto ssbs = wacs_type<'v'>();
+static const auto bsss = wacs_type<'w'>();
+static const auto bsbs = wacs_type<'q'>();
+static const auto sbsb = wacs_type<'x'>();
+static const auto ssss = wacs_type<'n'>();
+
+static const auto ulcorner = bssb;
+static const auto llcorner = ssbb;
+static const auto urcorner = bbss;
+static const auto lrcorner = sbbs;
+static const auto rtee = sbss;
+static const auto ltee = sssb;
+static const auto btee = ssbs;
+static const auto ttee = bsss;
+static const auto hline = bsbs;
+static const auto vline = sbsb;
+static const auto plus = ssss;
+
+static const auto s1 = wacs_type<'o'>();
+static const auto s9 = wacs_type<'s'>();
+static const auto diamond = wacs_type<'`'>();
+static const auto ckboard = wacs_type<'a'>();
+static const auto degree = wacs_type<'f'>();
+static const auto plminus = wacs_type<'g'>();
+static const auto bullet = wacs_type<'~'>();
+
+/* Teletype 5410v1 symbols */
+static const auto larrow = wacs_type<','>();
+static const auto rarrow = wacs_type<'+'>();
+static const auto darrow = wacs_type<'.'>();
+static const auto uarrow = wacs_type<'-'>();
+static const auto board = wacs_type<'h'>();
+static const auto lantern = wacs_type<'i'>();
+static const auto block = wacs_type<'0'>();
+
+/* ncurses extensions */
+static const auto s3 = wacs_type<'p'>();
+static const auto s7 = wacs_type<'r'>();
+static const auto lequal = wacs_type<'y'>();
+static const auto gequal = wacs_type<'z'>();
+static const auto pi = wacs_type<'{'>();
+static const auto nequal = wacs_type<'|'>();
+static const auto sterling = wacs_type<'}'>();
+
+/* double lines */
+static const auto bddb = wacs_type<'C'>();
+static const auto ddbb = wacs_type<'D'>();
+static const auto bbdd = wacs_type<'B'>();
+static const auto dbbd = wacs_type<'A'>();
+static const auto dbdd = wacs_type<'G'>();
+static const auto dddb = wacs_type<'F'>();
+static const auto ddbd = wacs_type<'H'>();
+static const auto bddd = wacs_type<'I'>();
+static const auto bdbd = wacs_type<'R'>();
+static const auto dbdb = wacs_type<'Y'>();
+static const auto dddd = wacs_type<'E'>();
+
+static const auto d_ulcorner = bddb;
+static const auto d_llcorner = ddbb;
+static const auto d_urcorner = bbdd;
+static const auto d_lrcorner = dbbd;
+static const auto d_rtee = dbdd;
+static const auto d_ltee = dddb;
+static const auto d_btee = ddbd;
+static const auto d_ttee = bddd;
+static const auto d_hline = bdbd;
+static const auto d_vline = dbdb;
+static const auto d_plus = dddd;
+
+/* thick lines */
+static const auto bttb = wacs_type<'L'>();
+static const auto ttbb = wacs_type<'M'>();
+static const auto bbtt = wacs_type<'K'>();
+static const auto tbbt = wacs_type<'J'>();
+static const auto tbtt = wacs_type<'U'>();
+static const auto tttb = wacs_type<'T'>();
+static const auto ttbt = wacs_type<'V'>();
+static const auto bttt = wacs_type<'W'>();
+static const auto btbt = wacs_type<'Q'>();
+static const auto tbtb = wacs_type<'X'>();
+static const auto tttt = wacs_type<'N'>();
+
+static const auto t_ulcorner = bttb;
+static const auto t_llcorner = ttbb;
+static const auto t_urcorner = bbtt;
+static const auto t_lrcorner = tbbt;
+static const auto t_rtee = tbtt;
+static const auto t_ltee = tttb;
+static const auto t_btee = ttbt;
+static const auto t_ttee = bttt;
+static const auto t_hline = btbt;
+static const auto t_vline = tbtb;
+static const auto t_plus = tttt;
+
+} // namespace wacs
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_NCURSES_ACS_HPP_
diff --git a/include/ncurses/char_attributes.hpp b/include/ncurses/char_attributes.hpp
new file mode 100644
index 0000000..9d45488
--- /dev/null
+++ b/include/ncurses/char_attributes.hpp
@@ -0,0 +1,40 @@
+#ifndef INCLUDE_NCURSES_CHAR_ATTRIBUTES_HPP_
+#define INCLUDE_NCURSES_CHAR_ATTRIBUTES_HPP_
+
+#include <ncurses/utils/preamble.hpp>
+
+#include <ncurses/utils/flags.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+enum class attr : attr_t {
+ normal = A_NORMAL,
+ attributes = A_ATTRIBUTES,
+ chartext = A_CHARTEXT,
+ color = A_COLOR,
+ standout = A_STANDOUT,
+ underline = A_UNDERLINE,
+ reverse = A_REVERSE,
+ blink = A_BLINK,
+ dim = A_DIM,
+ bold = A_BOLD,
+ altcharset = A_ALTCHARSET,
+ invis = A_INVIS,
+ protect = A_PROTECT,
+ italic = A_ITALIC,
+ // WA attributes for only attr_on, attr_off and attr_set
+ horizontal = A_HORIZONTAL,
+ left = A_LEFT,
+ low = A_LOW,
+ right = A_RIGHT,
+ top = A_TOP,
+ vertical = A_VERTICAL,
+};
+
+template <> struct is_bitmask<attr> : public std::true_type {};
+
+using attr_flags = flags<attr>;
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_NCURSES_CHAR_ATTRIBUTES_HPP_
diff --git a/include/ncurses/colors.hpp b/include/ncurses/colors.hpp
new file mode 100644
index 0000000..a0622a9
--- /dev/null
+++ b/include/ncurses/colors.hpp
@@ -0,0 +1,87 @@
+#ifndef INCLUDE_NCURSES_COLORS_HPP_
+#define INCLUDE_NCURSES_COLORS_HPP_
+
+#include "ncurses/utils/macros.hpp"
+#include <ncurses.h>
+
+#include <ncurses/utils/preamble.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+enum class curs_color {
+ black = COLOR_BLACK,
+ red = COLOR_RED,
+ green = COLOR_GREEN,
+ yellow = COLOR_YELLOW,
+ blue = COLOR_BLUE,
+ magenta = COLOR_MAGENTA,
+ cyan = COLOR_CYAN,
+ white = COLOR_WHITE
+};
+
+struct rgb_color {
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+};
+
+NCURSES_CPP_CONSTEXPR static int
+rgb_to_curses(unsigned char c) NCURSES_CPP_NOEXCEPT {
+ return static_cast<int>(c) * 1000 / 255;
+}
+
+NCURSES_CPP_CONSTEXPR static unsigned char
+curses_to_rgb(int c) NCURSES_CPP_NOEXCEPT {
+ return static_cast<unsigned char>((c * 255 / 1000) +
+ (c * 255 % 1000 == 0 ? 0 : 1));
+}
+
+inline bool has_colors() { return static_cast<bool>(::has_colors()); }
+
+inline bool can_change_color() {
+ return static_cast<bool>(::can_change_color());
+}
+
+inline bool init_color(int index, int r, int g, int b) {
+ return init_extended_color(index, rgb_to_curses(r), rgb_to_curses(g),
+ rgb_to_curses(b)) == OK
+ ? true
+ : false;
+}
+
+inline bool color_content(int index, int *r, int *g, int *b) {
+ int res = extended_color_content(index, r, g, b);
+ if (res == ERR)
+ return false;
+ *r = curses_to_rgb(*r);
+ *g = curses_to_rgb(*g);
+ *b = curses_to_rgb(*b);
+ return true;
+}
+
+inline bool init_pair(int index, int fg, int bg) {
+ return init_extended_pair(index, fg, bg) == OK ? true : false;
+}
+
+inline bool pair_content(int index, int *fg, int *bg) {
+ return extended_pair_content(index, fg, bg);
+}
+
+class color_pair {
+public:
+ using value_type = chtype;
+ NCURSES_CPP_CONSTEXPR color_pair(int index) NCURSES_CPP_NOEXCEPT
+ : index_(index) {}
+
+ explicit NCURSES_CPP_CONSTEXPR
+ operator value_type() const NCURSES_CPP_NOEXCEPT {
+ return COLOR_PAIR(index_);
+ }
+
+private:
+ int index_;
+};
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_NCURSES_COLORS_HPP_
diff --git a/include/ncurses/core.hpp b/include/ncurses/core.hpp
new file mode 100644
index 0000000..28ae984
--- /dev/null
+++ b/include/ncurses/core.hpp
@@ -0,0 +1,6 @@
+#ifndef INCLUDE_NCURSES_CORE_HPP_
+#define INCLUDE_NCURSES_CORE_HPP_
+
+#include <ncurses/utils/preamble.hpp>
+
+#endif // INCLUDE_NCURSES_CORE_HPP_
diff --git a/include/ncurses/curs_char.hpp b/include/ncurses/curs_char.hpp
new file mode 100644
index 0000000..8c1cf4a
--- /dev/null
+++ b/include/ncurses/curs_char.hpp
@@ -0,0 +1,203 @@
+#ifndef INCLUDE_NCURSES_CURS_CHAR_HPP_
+#define INCLUDE_NCURSES_CURS_CHAR_HPP_
+
+#include "ncurses/utils/macros.hpp"
+#include <ncurses.h>
+#include <ncurses/char_attributes.hpp>
+#include <ncurses/colors.hpp>
+#include <ncurses/utils/multiflags.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+template <> struct is_applyable<color_pair, attr> : std::true_type {};
+
+using full_attrs = multiflags<attr, color_pair>;
+
+class curs_char {
+public:
+ using value_type = chtype;
+
+ NCURSES_CPP_CONSTEXPR curs_char(char c) NCURSES_CPP_NOEXCEPT
+ : value_(static_cast<chtype>(c)) {}
+
+ explicit NCURSES_CPP_CONSTEXPR curs_char(value_type c) NCURSES_CPP_NOEXCEPT
+ : value_(c) {}
+
+ NCURSES_CPP_CONSTEXPR attr_flags attributes() const NCURSES_CPP_NOEXCEPT {
+ return {};
+ };
+
+ NCURSES_CPP_CONSTEXPR int color() const NCURSES_CPP_NOEXCEPT {
+ return PAIR_NUMBER(value_);
+ };
+
+ NCURSES_CPP_CONSTEXPR char ch() const NCURSES_CPP_NOEXCEPT {
+ return static_cast<char>(value_);
+ };
+
+#define NCURSES_CPP_RELATIONAL(op) \
+ NCURSES_CPP_CONSTEXPR bool operator op(curs_char const &rhs) \
+ const NCURSES_CPP_NOEXCEPT { \
+ return value_ op rhs.value_; \
+ }
+
+#define NCURSES_CPP_BITWISE_ATTR(op) \
+ NCURSES_CPP_CONSTEXPR curs_char operator op(attr rhs) \
+ const NCURSES_CPP_NOEXCEPT { \
+ return curs_char( \
+ value_ op static_cast<std::underlying_type<attr>::type>(rhs)); \
+ }
+
+#define NCURSES_CPP_ASSIGNMENT_ATTR(op) \
+ NCURSES_CPP_CONSTEXPR_14 curs_char &operator op##=(attr rhs) \
+ NCURSES_CPP_NOEXCEPT { \
+ value_ op## = static_cast<std::underlying_type<attr>::type>(rhs); \
+ return *this; \
+ }
+
+#define NCURSES_CPP_BITWISE_ATTRS(op) \
+ NCURSES_CPP_CONSTEXPR curs_char operator op(attr_flags const &rhs) \
+ const NCURSES_CPP_NOEXCEPT { \
+ return curs_char(value_ op static_cast<attr_flags::mask_type>(rhs)); \
+ }
+
+#define NCURSES_CPP_ASSIGNMENT_ATTRS(op) \
+ NCURSES_CPP_CONSTEXPR_14 curs_char &operator op##=(attr_flags const &rhs) \
+ NCURSES_CPP_NOEXCEPT { \
+ value_ op## = static_cast<attr_flags::mask_type>(rhs); \
+ return *this; \
+ }
+
+#define NCURSES_CPP_BITWISE_COLORS(op) \
+ NCURSES_CPP_CONSTEXPR curs_char operator op(color_pair const &rhs) \
+ const NCURSES_CPP_NOEXCEPT { \
+ return curs_char(value_ op static_cast<color_pair::value_type>(rhs)); \
+ }
+
+#define NCURSES_CPP_ASSIGNMENT_COLORS(op) \
+ NCURSES_CPP_CONSTEXPR_14 curs_char &operator op##=(color_pair const &rhs) \
+ NCURSES_CPP_NOEXCEPT { \
+ value_ op## = static_cast<color_pair::value_type>(rhs); \
+ return *this; \
+ }
+
+#define NCURSES_CPP_BITWISE_FATTRS(op) \
+ NCURSES_CPP_CONSTEXPR curs_char operator op(full_attrs const &rhs) \
+ const NCURSES_CPP_NOEXCEPT { \
+ return curs_char(value_ op static_cast<full_attrs::value_type>(rhs)); \
+ }
+
+#define NCURSES_CPP_ASSIGNMENT_FATTRS(op) \
+ NCURSES_CPP_CONSTEXPR_14 curs_char &operator op##=(full_attrs const &rhs) \
+ NCURSES_CPP_NOEXCEPT { \
+ value_ op## = static_cast<full_attrs::value_type>(rhs); \
+ return *this; \
+ }
+
+ NCURSES_CPP_RELATIONAL(<)
+ NCURSES_CPP_RELATIONAL(<=)
+ NCURSES_CPP_RELATIONAL(>)
+ NCURSES_CPP_RELATIONAL(>=)
+ NCURSES_CPP_RELATIONAL(==)
+ NCURSES_CPP_RELATIONAL(!=)
+
+ NCURSES_CPP_BITWISE_ATTR(&)
+ NCURSES_CPP_BITWISE_ATTR(|)
+ NCURSES_CPP_BITWISE_ATTR(^)
+
+ NCURSES_CPP_BITWISE_ATTRS(&)
+ NCURSES_CPP_BITWISE_ATTRS(|)
+ NCURSES_CPP_BITWISE_ATTRS(^)
+
+ NCURSES_CPP_BITWISE_COLORS(&)
+ NCURSES_CPP_BITWISE_COLORS(|)
+ NCURSES_CPP_BITWISE_COLORS(^)
+
+ NCURSES_CPP_BITWISE_FATTRS(&)
+ NCURSES_CPP_BITWISE_FATTRS(|)
+ NCURSES_CPP_BITWISE_FATTRS(^)
+
+ NCURSES_CPP_ASSIGNMENT_ATTR(&)
+ NCURSES_CPP_ASSIGNMENT_ATTR(|)
+ NCURSES_CPP_ASSIGNMENT_ATTR(^)
+
+ NCURSES_CPP_ASSIGNMENT_ATTRS(&)
+ NCURSES_CPP_ASSIGNMENT_ATTRS(|)
+ NCURSES_CPP_ASSIGNMENT_ATTRS(^)
+
+ NCURSES_CPP_ASSIGNMENT_COLORS(&)
+ NCURSES_CPP_ASSIGNMENT_COLORS(|)
+ NCURSES_CPP_ASSIGNMENT_COLORS(^)
+
+ NCURSES_CPP_ASSIGNMENT_FATTRS(&)
+ NCURSES_CPP_ASSIGNMENT_FATTRS(|)
+ NCURSES_CPP_ASSIGNMENT_FATTRS(^)
+
+ NCURSES_CPP_CONSTEXPR bool operator!() const NCURSES_CPP_NOEXCEPT {
+ return !value_;
+ }
+
+ explicit NCURSES_CPP_CONSTEXPR operator char() const NCURSES_CPP_NOEXCEPT {
+ return static_cast<char>(value_);
+ }
+
+#if defined(NCURSES_CPP_CHAR_VALUE_AS_PUBLIC)
+public:
+#else
+private:
+#endif
+ chtype value_;
+};
+
+// TODO:const otype& - link may be not as good as copy
+#define NPP_DEF_GLOB_OP(type, op, otype) \
+ NCURSES_CPP_CONSTEXPR_INLINE type operator op( \
+ const otype &other, curs_char const &symbol) NCURSES_CPP_NOEXCEPT { \
+ return symbol.operator op(other); \
+ } \
+ NCURSES_CPP_CONSTEXPR_INLINE type operator op(const char &c, \
+ const otype &other) { \
+ return curs_char(static_cast<curs_char::value_type>(c) \
+ op static_cast<curs_char::value_type>(other)); \
+ }
+
+#define NPP_DEF_GLOB_OP_BOOL(op) \
+ NCURSES_CPP_CONSTEXPR_INLINE bool operator op(const char &lhs, \
+ const curs_char &rhs) { \
+ return rhs.operator op(lhs); \
+ }
+
+#define NPP_DEF_GLOB_OP_ATTR(op) NPP_DEF_GLOB_OP(curs_char, op, attr)
+#define NPP_DEF_GLOB_OP_ATTRS(op) NPP_DEF_GLOB_OP(curs_char, op, attr_flags)
+#define NPP_DEF_GLOB_OP_COLORS(op) NPP_DEF_GLOB_OP(curs_char, op, color_pair)
+#define NPP_DEF_GLOB_OP_FATTRS(op) NPP_DEF_GLOB_OP(curs_char, op, full_attrs)
+
+#if !defined(NCURSES_CPP_HAS_SPACESHIP_OPERATOR)
+// relational operators only needed for pre C++20
+NPP_DEF_GLOB_OP_BOOL(<)
+NPP_DEF_GLOB_OP_BOOL(<=)
+NPP_DEF_GLOB_OP_BOOL(>)
+NPP_DEF_GLOB_OP_BOOL(>=)
+NPP_DEF_GLOB_OP_BOOL(==)
+NPP_DEF_GLOB_OP_BOOL(!=)
+#endif
+
+NPP_DEF_GLOB_OP_ATTR(&)
+NPP_DEF_GLOB_OP_ATTR(|)
+NPP_DEF_GLOB_OP_ATTR(^)
+
+NPP_DEF_GLOB_OP_ATTRS(&)
+NPP_DEF_GLOB_OP_ATTRS(|)
+NPP_DEF_GLOB_OP_ATTRS(^)
+
+NPP_DEF_GLOB_OP_COLORS(&)
+NPP_DEF_GLOB_OP_COLORS(|)
+NPP_DEF_GLOB_OP_COLORS(^)
+
+NPP_DEF_GLOB_OP_FATTRS(&)
+NPP_DEF_GLOB_OP_FATTRS(|)
+NPP_DEF_GLOB_OP_FATTRS(^)
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_NCURSES_CURS_CHAR_HPP_
diff --git a/include/ncurses/keys.hpp b/include/ncurses/keys.hpp
new file mode 100644
index 0000000..d8f0fb5
--- /dev/null
+++ b/include/ncurses/keys.hpp
@@ -0,0 +1,174 @@
+#ifndef INCLUDE_NCURSES_KEYS_HPP_
+#define INCLUDE_NCURSES_KEYS_HPP_
+
+#include <ncurses/utils/preamble.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+enum class key : int {
+ code_yes = KEY_CODE_YES,
+ min = KEY_MIN,
+ break_k = KEY_BREAK,
+ sreset = KEY_SRESET,
+ reset = KEY_RESET,
+ down = KEY_DOWN,
+ up = KEY_UP,
+ left = KEY_LEFT,
+ right = KEY_RIGHT,
+ home = KEY_HOME,
+ backspace = KEY_BACKSPACE,
+ f0 = KEY_F0,
+ f1,
+ f2,
+ f3,
+ f4,
+ f5,
+ f6,
+ f7,
+ f8,
+ f9,
+ f10,
+ f11,
+ f12,
+ f13,
+ f14,
+ f15,
+ f16,
+ f17,
+ f18,
+ f19,
+ f20,
+ f21,
+ f22,
+ f23,
+ f24,
+ f25,
+ f26,
+ f27,
+ f28,
+ f29,
+ f30,
+ f31,
+ f32,
+ f33,
+ f34,
+ f35,
+ f36,
+ f37,
+ f38,
+ f39,
+ f40,
+ f41,
+ f42,
+ f43,
+ f44,
+ f45,
+ f46,
+ f47,
+ f48,
+ f49,
+ f50,
+ f51,
+ f52,
+ f53,
+ f54,
+ f55,
+ f56,
+ f57,
+ f58,
+ f59,
+ f60,
+ f61,
+ f62,
+ f63,
+ dl = KEY_DL,
+ il = KEY_IL,
+ dc = KEY_DC,
+ ic = KEY_IC,
+ eic = KEY_EIC,
+ clear = KEY_CLEAR,
+ eos = KEY_EOS,
+ eol = KEY_EOL,
+ sf = KEY_SF,
+ sr = KEY_SR,
+ npage = KEY_NPAGE,
+ ppage = KEY_PPAGE,
+ stab = KEY_STAB,
+ ctab = KEY_CTAB,
+ catab = KEY_CATAB,
+ enter = KEY_ENTER,
+ print = KEY_PRINT,
+ ll = KEY_LL,
+ a1 = KEY_A1,
+ a3 = KEY_A3,
+ b2 = KEY_B2,
+ c1 = KEY_C1,
+ c3 = KEY_C3,
+ btab = KEY_BTAB,
+ beg = KEY_BEG,
+ cancel = KEY_CANCEL,
+ close = KEY_CLOSE,
+ command = KEY_COMMAND,
+ copy = KEY_COPY,
+ create = KEY_CREATE,
+ end = KEY_END,
+ exit = KEY_EXIT,
+ find = KEY_FIND,
+ help = KEY_HELP,
+ mark = KEY_MARK,
+ message = KEY_MESSAGE,
+ move = KEY_MOVE,
+ next = KEY_NEXT,
+ open = KEY_OPEN,
+ options = KEY_OPTIONS,
+ previous = KEY_PREVIOUS,
+ redo = KEY_REDO,
+ reference = KEY_REFERENCE,
+ refresh = KEY_REFRESH,
+ replace = KEY_REPLACE,
+ restart = KEY_RESTART,
+ resume = KEY_RESUME,
+ save = KEY_SAVE,
+ sbeg = KEY_SBEG,
+ scancel = KEY_SCANCEL,
+ scommand = KEY_SCOMMAND,
+ scopy = KEY_SCOPY,
+ screate = KEY_SCREATE,
+ sdc = KEY_SDC,
+ sdl = KEY_SDL,
+ select = KEY_SELECT,
+ send = KEY_SEND,
+ seol = KEY_SEOL,
+ sexit = KEY_SEXIT,
+ sfind = KEY_SFIND,
+ shelp = KEY_SHELP,
+ shome = KEY_SHOME,
+ sic = KEY_SIC,
+ sleft = KEY_SLEFT,
+ smessage = KEY_SMESSAGE,
+ smove = KEY_SMOVE,
+ snext = KEY_SNEXT,
+ soptions = KEY_SOPTIONS,
+ sprevious = KEY_SPREVIOUS,
+ sprint = KEY_SPRINT,
+ sredo = KEY_SREDO,
+ sreplace = KEY_SREPLACE,
+ sright = KEY_SRIGHT,
+ srsume = KEY_SRSUME,
+ ssave = KEY_SSAVE,
+ ssuspend = KEY_SSUSPEND,
+ sundo = KEY_SUNDO,
+ suspend = KEY_SUSPEND,
+ undo = KEY_UNDO,
+ mouse = KEY_MOUSE,
+
+#ifdef NCURSES_EXT_FUNCS
+ resize = KEY_RESIZE,
+#endif
+
+ max = KEY_MAX,
+};
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_NCURSES_KEYS_HPP_
diff --git a/include/ncurses/mouse_events.hpp b/include/ncurses/mouse_events.hpp
new file mode 100644
index 0000000..43a91c3
--- /dev/null
+++ b/include/ncurses/mouse_events.hpp
@@ -0,0 +1,47 @@
+#ifndef INCLUDE_NCURSES_MOUSE_EVENTS_HPP_
+#define INCLUDE_NCURSES_MOUSE_EVENTS_HPP_
+
+#include <ncurses/utils/flags.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+enum class mouse_event {
+ button1_pressed = BUTTON1_PRESSED,
+ button1_released = BUTTON1_RELEASED,
+ button1_clicked = BUTTON1_CLICKED,
+ button1_double_clicked = BUTTON1_DOUBLE_CLICKED,
+ button1_triple_clicked = BUTTON1_TRIPLE_CLICKED,
+ button2_pressed = BUTTON2_PRESSED,
+ button2_released = BUTTON2_RELEASED,
+ button2_clicked = BUTTON2_CLICKED,
+ button2_double_clicked = BUTTON2_DOUBLE_CLICKED,
+ button2_triple_clicked = BUTTON2_TRIPLE_CLICKED,
+ button3_pressed = BUTTON3_PRESSED,
+ button3_released = BUTTON3_RELEASED,
+ button3_clicked = BUTTON3_CLICKED,
+ button3_double_clicked = BUTTON3_DOUBLE_CLICKED,
+ button3_triple_clicked = BUTTON3_TRIPLE_CLICKED,
+ button4_pressed = BUTTON4_PRESSED,
+ button4_released = BUTTON4_RELEASED,
+ button4_clicked = BUTTON4_CLICKED,
+ button4_double_clicked = BUTTON4_DOUBLE_CLICKED,
+ button4_triple_clicked = BUTTON4_TRIPLE_CLICKED,
+ button5_pressed = BUTTON5_PRESSED,
+ button5_released = BUTTON5_RELEASED,
+ button5_clicked = BUTTON5_CLICKED,
+ button5_double_clicked = BUTTON5_DOUBLE_CLICKED,
+ button5_triple_clicked = BUTTON5_TRIPLE_CLICKED,
+ button_shift = BUTTON_SHIFT,
+ button_ctrl = BUTTON_CTRL,
+ button_alt = BUTTON_ALT,
+ all_mouse_events = ALL_MOUSE_EVENTS,
+ report_mouse_position = REPORT_MOUSE_POSITION,
+};
+
+template <> struct is_bitmask<mouse_event> : public std::true_type {};
+
+using mouse_event_flags = flags<mouse_event>;
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_NCURSES_MOUSE_EVENTS_HPP_
diff --git a/include/ncurses/ncurses.hpp b/include/ncurses/ncurses.hpp
new file mode 100644
index 0000000..9da8db4
--- /dev/null
+++ b/include/ncurses/ncurses.hpp
@@ -0,0 +1,4 @@
+#ifndef INCLUDE_NCURSES_NCURSES_HPP_
+#define INCLUDE_NCURSES_NCURSES_HPP_
+
+#endif // INCLUDE_NCURSES_NCURSES_HPP_
diff --git a/include/ncurses/types.hpp b/include/ncurses/types.hpp
new file mode 100644
index 0000000..16d799f
--- /dev/null
+++ b/include/ncurses/types.hpp
@@ -0,0 +1,69 @@
+#ifndef INCLUDE_NCURSES_ENUMS_HPP_
+#define INCLUDE_NCURSES_ENUMS_HPP_
+
+extern "C" {
+#include <ncurses.h>
+}
+
+#include <ncurses/utils/macros.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+struct ok_type {
+ NCURSES_CPP_CONSTEXPR_INLINE operator bool() const { return true; }
+};
+
+NCURSES_CPP_CONSTEXPR_INLINE const ok_type ok;
+
+struct err_type {
+ NCURSES_CPP_CONSTEXPR_INLINE operator bool() const { return false; }
+};
+
+NCURSES_CPP_CONSTEXPR_INLINE const err_type err;
+
+class result_type {
+public:
+ NCURSES_CPP_CONSTEXPR result_type(int code) noexcept
+ : result_(code == OK ? true : false) {}
+
+ NCURSES_CPP_CONSTEXPR_INLINE operator bool() const { return result_; }
+ NCURSES_CPP_CONSTEXPR_INLINE bool operator==(const result_type &rhs) const {
+ return result_ == rhs.result_;
+ }
+ NCURSES_CPP_CONSTEXPR_INLINE bool operator!=(const result_type &rhs) const {
+ return result_ != rhs.result_;
+ }
+ NCURSES_CPP_CONSTEXPR_INLINE bool operator==(const ok_type &rhs) const {
+ return result_;
+ }
+ NCURSES_CPP_CONSTEXPR_INLINE bool operator==(const err_type &rhs) const {
+ return !result_;
+ }
+
+private:
+ bool result_;
+};
+
+NCURSES_CPP_CONSTEXPR bool operator==(const ok_type &ok,
+ const result_type &result) noexcept {
+ return result == ok;
+}
+
+NCURSES_CPP_CONSTEXPR bool operator!=(const ok_type &ok,
+ const result_type &result) noexcept {
+ return result != ok;
+}
+
+NCURSES_CPP_CONSTEXPR bool operator==(const err_type &err,
+ const result_type &result) noexcept {
+ return result == err;
+}
+
+NCURSES_CPP_CONSTEXPR bool operator!=(const err_type &err,
+ const result_type &result) noexcept {
+ return result != err;
+}
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_NCURSES_ENUMS_HPP_
diff --git a/include/ncurses/utils/flags.hpp b/include/ncurses/utils/flags.hpp
new file mode 100644
index 0000000..69b7aa9
--- /dev/null
+++ b/include/ncurses/utils/flags.hpp
@@ -0,0 +1,156 @@
+#ifndef INCLUDE_NCURSES_FLAGS_HPP_
+#define INCLUDE_NCURSES_FLAGS_HPP_
+
+#include <type_traits>
+
+#include <ncurses/utils/preamble.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+template <typename FlagBitsType> struct is_bitmask : public std::false_type {};
+
+template <typename BitType, typename std::enable_if<is_bitmask<BitType>::value,
+ bool>::type = true>
+class flags {
+public:
+ using mask_type = typename std::underlying_type<BitType>::type;
+
+ // constructors
+ NCURSES_CPP_CONSTEXPR flags() NCURSES_CPP_NOEXCEPT : mask_(0) {}
+
+ NCURSES_CPP_CONSTEXPR flags(BitType bit) NCURSES_CPP_NOEXCEPT
+ : mask_(static_cast<mask_type>(bit)) {}
+
+ NCURSES_CPP_CONSTEXPR
+ flags(flags<BitType> const &rhs) NCURSES_CPP_NOEXCEPT = default;
+
+ NCURSES_CPP_CONSTEXPR explicit flags(mask_type flags) : mask_(flags) {}
+
+ // relational operators
+
+#define NCURSES_CPP_RELATIONAL(op) \
+ NCURSES_CPP_CONSTEXPR bool operator op(flags<BitType> const &rhs) \
+ const NCURSES_CPP_NOEXCEPT { \
+ return mask_ op rhs.mask_; \
+ }
+
+#define NCURSES_CPP_BITWISE(op) \
+ NCURSES_CPP_CONSTEXPR flags<BitType> operator op(flags<BitType> const &rhs) \
+ const NCURSES_CPP_NOEXCEPT { \
+ return flags<BitType>(mask_ op rhs.mask_); \
+ }
+
+#define NCURSES_CPP_ASSIGNMENT(op) \
+ NCURSES_CPP_CONSTEXPR_14 flags<BitType> &operator op##=( \
+ flags<BitType> const &rhs) NCURSES_CPP_NOEXCEPT { \
+ mask_ op## = rhs.mask_; \
+ return *this; \
+ }
+
+ NCURSES_CPP_RELATIONAL(<)
+ NCURSES_CPP_RELATIONAL(<=)
+ NCURSES_CPP_RELATIONAL(>)
+ NCURSES_CPP_RELATIONAL(>=)
+ NCURSES_CPP_RELATIONAL(==)
+ NCURSES_CPP_RELATIONAL(!=)
+
+ // logical operator
+ NCURSES_CPP_CONSTEXPR bool operator!() const NCURSES_CPP_NOEXCEPT {
+ return !mask_;
+ }
+
+ // bitwise operators
+ NCURSES_CPP_BITWISE(&)
+ NCURSES_CPP_BITWISE(|)
+ NCURSES_CPP_BITWISE(^)
+
+ /*NCURSES_CPP_CONSTEXPR flags<BitType> operator~() const {*/
+ /* return flags<BitType>(m_mask ^ is_bitmask<BitType>::allflags.m_mask);*/
+ /*}*/
+
+ // assignment operators
+ NCURSES_CPP_CONSTEXPR_14 flags<BitType> &
+ operator=(flags<BitType> const &rhs) NCURSES_CPP_NOEXCEPT = default;
+
+ NCURSES_CPP_ASSIGNMENT(&)
+ NCURSES_CPP_ASSIGNMENT(|)
+ NCURSES_CPP_ASSIGNMENT(^)
+
+ // cast operators
+ explicit NCURSES_CPP_CONSTEXPR operator bool() const NCURSES_CPP_NOEXCEPT {
+ return !!mask_;
+ }
+
+ explicit NCURSES_CPP_CONSTEXPR
+ operator mask_type() const NCURSES_CPP_NOEXCEPT {
+ return mask_;
+ }
+
+#undef NCURSES_CPP_RELATIONAL
+#undef NCURSES_CPP_BITWISE
+#undef NCURSES_CPP_ASSIGNMENT
+
+#if defined(NCURSES_CPP_FLAGS_MASK_TYPE_AS_PUBLIC)
+public:
+#else
+private:
+#endif
+ mask_type mask_;
+};
+
+// TODO:const BitType& - link may be not as good as copy
+#define NPP_DEF_GLOB_OP(type_arg, op) \
+ template <typename BitType, \
+ typename std::enable_if<is_bitmask<BitType>::value, bool>::type = \
+ true> \
+ NCURSES_CPP_CONSTEXPR_INLINE type_arg operator op( \
+ const BitType &bit, flags<BitType> const &flags) NCURSES_CPP_NOEXCEPT { \
+ return flags.operator op(bit); \
+ }
+
+#define NPP_DEF_GLOB_BITTYPE(op) \
+ template <typename BitType, \
+ typename std::enable_if<is_bitmask<BitType>::value, bool>::type = \
+ true> \
+ NCURSES_CPP_CONSTEXPR_INLINE flags<BitType> operator op( \
+ BitType lhs, BitType rhs) NCURSES_CPP_NOEXCEPT { \
+ return flags<BitType>(lhs) op rhs; \
+ }
+
+#define NPP_DEF_GLOB_OP_BOOL(op) NPP_DEF_GLOB_OP(bool, op)
+#define NPP_DEF_GLOB_OP_FLAG(op) NPP_DEF_GLOB_OP(flags<BitType>, op)
+
+#if !defined(NCURSES_CPP_HAS_SPACESHIP_OPERATOR)
+// relational operators only needed for pre C++20
+NPP_DEF_GLOB_OP_BOOL(<)
+NPP_DEF_GLOB_OP_BOOL(<=)
+NPP_DEF_GLOB_OP_BOOL(>)
+NPP_DEF_GLOB_OP_BOOL(>=)
+NPP_DEF_GLOB_OP_BOOL(==)
+NPP_DEF_GLOB_OP_BOOL(!=)
+#endif
+
+NPP_DEF_GLOB_OP_FLAG(&)
+NPP_DEF_GLOB_OP_FLAG(|)
+NPP_DEF_GLOB_OP_FLAG(^)
+
+// bitwise operators on BitType
+NPP_DEF_GLOB_BITTYPE(&)
+NPP_DEF_GLOB_BITTYPE(|)
+NPP_DEF_GLOB_BITTYPE(^)
+
+#undef NPP_DEF_GLOB_OP
+#undef NPP_DEF_GLOB_OP_BOOL
+#undef NPP_DEF_GLOB_OP_FLAG
+#undef NPP_DEF_GLOB_BITTYPE
+
+template <typename BitType,
+ typename std::enable_if<is_bitmask<BitType>::value>::type>
+NCURSES_CPP_CONSTEXPR_INLINE flags<BitType>
+operator~(BitType bit) NCURSES_CPP_NOEXCEPT {
+ return ~(flags<BitType>(bit));
+}
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_NCURSES_FLAGS_HPP_
diff --git a/include/ncurses/utils/macros.hpp b/include/ncurses/utils/macros.hpp
new file mode 100644
index 0000000..d26423b
--- /dev/null
+++ b/include/ncurses/utils/macros.hpp
@@ -0,0 +1,50 @@
+#ifndef INCLUDE_NCURSES_MARCOS_HPP_
+#define INCLUDE_NCURSES_MARCOS_HPP_
+
+#if !defined(NCURSES_CPP_NAMESPACE)
+#define NCURSES_CPP_NAMESPACE ncurses
+#endif
+
+#if defined(__cpp_constexpr)
+#define NCURSES_CPP_CONSTEXPR constexpr
+#if 201304 <= __cpp_constexpr
+#define NCURSES_CPP_CONSTEXPR_14 constexpr
+#else
+#define NCURSES_CPP_CONSTEXPR_14
+#endif
+#if (201907 <= __cpp_constexpr) && \
+ (!defined(__GNUC__) || (110400 < GCC_VERSION))
+#define NCURSES_CPP_CONSTEXPR_20 constexpr
+#else
+#define NCURSES_CPP_CONSTEXPR_20
+#endif
+#define NCURSES_CPP_CONST_OR_CONSTEXPR constexpr
+#else
+#define NCURSES_CPP_CONSTEXPR
+#define NCURSES_CPP_CONSTEXPR_14
+#define NCURSES_CPP_CONST_OR_CONSTEXPR const
+#endif
+
+#if !defined(NCURSES_CPP_CONSTEXPR_INLINE)
+#if 201606L <= __cpp_inline_variables
+#define NCURSES_CPP_CONSTEXPR_INLINE NCURSES_CPP_CONSTEXPR inline
+#else
+#define NCURSES_CPP_CONSTEXPR_INLINE NCURSES_CPP_CONSTEXPR
+#endif
+#endif
+
+#if !defined(NCURSES_CPP_NOEXCEPT)
+#if defined(_MSC_VER) && (_MSC_VER <= 1800)
+#define NCURSES_CPP_NOEXCEPT
+#else
+#define NCURSES_CPP_NOEXCEPT noexcept
+#define NCURSES_CPP_HAS_NOEXCEPT 1
+#if defined(NCURSES_CPP_NO_EXCEPTIONS)
+#define NCURSES_CPP_NOEXCEPT_WHEN_NO_EXCEPTIONS noexcept
+#else
+#define NCURSES_CPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
+#endif
+#endif
+#endif
+
+#endif // INCLUDE_NCURSES_MARCOS_HPP_
diff --git a/include/ncurses/utils/modifiers.hpp b/include/ncurses/utils/modifiers.hpp
new file mode 100644
index 0000000..79e4139
--- /dev/null
+++ b/include/ncurses/utils/modifiers.hpp
@@ -0,0 +1,31 @@
+#ifndef INCLUDE_UTILS_MODIFIERS_HPP_
+#define INCLUDE_UTILS_MODIFIERS_HPP_
+
+#include <type_traits>
+
+#include <ncurses/utils/flags.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+template <typename Derived, typename ApplicantType> class composable {
+public:
+ using flags_type = multiflags<ApplicantType>;
+ using flags_mask_type = multiflags<ApplicantType>;
+
+ NCURSES_CPP_CONSTEXPR_14 composable &
+ operator&(const ApplicantType applicant) {
+ static_cast<Derived *>(this)->value_();
+ }
+
+ NCURSES_CPP_CONSTEXPR_14 composable &operator&(const flags_type &flags) {
+ value_ &= static_cast<flags_mask_type>(flags);
+ return *this;
+ }
+
+private:
+ value_type value_;
+};
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_UTILS_MODIFIERS_HPP_
diff --git a/include/ncurses/utils/multiflags.hpp b/include/ncurses/utils/multiflags.hpp
new file mode 100644
index 0000000..e6af6a6
--- /dev/null
+++ b/include/ncurses/utils/multiflags.hpp
@@ -0,0 +1,202 @@
+#ifndef INCLUDE_UTILS_MULTIFLAGS_HPP_
+#define INCLUDE_UTILS_MULTIFLAGS_HPP_
+
+#include <type_traits>
+
+#include "ncurses/utils/macros.hpp"
+#include <ncurses/utils/flags.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+template <typename FlagBitType, typename PrimaryType>
+struct is_applyable : public std::false_type {};
+
+template <typename BitType, typename SecondBitType>
+using is_combosable_types =
+ typename std::enable_if<is_bitmask<BitType>::value &&
+ is_applyable<SecondBitType, BitType>::value,
+ bool>::type;
+
+template <typename BitType, typename SecondBitType,
+ is_combosable_types<BitType, SecondBitType> = true>
+class multiflags {
+public:
+ using value_type = typename std::underlying_type<BitType>::type;
+ using second_value_type = typename SecondBitType::value_type;
+
+ // constructors
+ NCURSES_CPP_CONSTEXPR multiflags() NCURSES_CPP_NOEXCEPT : value_(0) {}
+
+ NCURSES_CPP_CONSTEXPR multiflags(BitType bit) NCURSES_CPP_NOEXCEPT
+ : value_(static_cast<value_type>(bit)) {}
+
+ NCURSES_CPP_CONSTEXPR multiflags(SecondBitType bit) NCURSES_CPP_NOEXCEPT
+ : value_(static_cast<value_type>(bit)) {}
+
+ NCURSES_CPP_CONSTEXPR multiflags(flags<BitType> flag) NCURSES_CPP_NOEXCEPT
+ : value_(static_cast<value_type>(flag)) {}
+
+ NCURSES_CPP_CONSTEXPR
+ multiflags(multiflags<BitType, SecondBitType> const &rhs)
+ NCURSES_CPP_NOEXCEPT = default;
+
+ NCURSES_CPP_CONSTEXPR explicit multiflags(value_type multiflags)
+ : value_(multiflags) {}
+
+ // relational operators
+
+#define NCURSES_CPP_RELATIONAL(op) \
+ NCURSES_CPP_CONSTEXPR bool operator op( \
+ multiflags<BitType, SecondBitType> const &rhs) \
+ const NCURSES_CPP_NOEXCEPT { \
+ return value_ op rhs.value_; \
+ }
+
+ NCURSES_CPP_RELATIONAL(==)
+ NCURSES_CPP_RELATIONAL(!=)
+
+ // logical operator
+
+ NCURSES_CPP_CONSTEXPR bool operator!() const NCURSES_CPP_NOEXCEPT {
+ return !value_;
+ }
+
+ // bitwise operators
+
+#define NCURSES_CPP_BITWISE(op) \
+ NCURSES_CPP_CONSTEXPR multiflags<BitType, SecondBitType> operator op( \
+ multiflags<BitType, SecondBitType> const &rhs) \
+ const NCURSES_CPP_NOEXCEPT { \
+ return multiflags<BitType, SecondBitType>(value_ op rhs.value_); \
+ }
+
+ NCURSES_CPP_BITWISE(&)
+ NCURSES_CPP_BITWISE(|)
+ NCURSES_CPP_BITWISE(^)
+
+ /*NCURSES_CPP_CONSTEXPR multiflags<BitType> operator~() const {*/
+ /* return multiflags<BitType>(m_mask ^
+ * is_bitmask<BitType>::allmultiflags.m_mask);*/
+ /*}*/
+
+ // assignment operators
+
+#define NCURSES_CPP_ASSIGNMENT(op) \
+ NCURSES_CPP_CONSTEXPR_14 multiflags<BitType, SecondBitType> &operator op##=( \
+ multiflags<BitType, SecondBitType> const &rhs) NCURSES_CPP_NOEXCEPT { \
+ value_ op## = rhs.value_; \
+ return *this; \
+ }
+
+ NCURSES_CPP_CONSTEXPR_14 multiflags<BitType, SecondBitType> &
+ operator=(multiflags<BitType, SecondBitType> const &rhs)
+ NCURSES_CPP_NOEXCEPT = default;
+
+ NCURSES_CPP_ASSIGNMENT(&)
+ NCURSES_CPP_ASSIGNMENT(|)
+ NCURSES_CPP_ASSIGNMENT(^)
+
+ // cast operators
+ explicit NCURSES_CPP_CONSTEXPR operator bool() const NCURSES_CPP_NOEXCEPT {
+ return !!value_;
+ }
+
+ explicit NCURSES_CPP_CONSTEXPR
+ operator value_type() const NCURSES_CPP_NOEXCEPT {
+ return value_;
+ }
+
+#undef NCURSES_CPP_RELATIONAL
+#undef NCURSES_CPP_BITWISE
+#undef NCURSES_CPP_ASSIGNMENT
+
+#if defined(NCURSES_CPP_FLAGS_MASK_TYPE_AS_PUBLIC)
+public:
+#else
+private:
+#endif
+ value_type value_;
+};
+
+// TODO:const BitType& - link may be not as good as copy
+#define NPP_DEF_GLOB_OP(type_arg, op, pos) \
+ template <typename BitType, typename SecondBitType, \
+ is_combosable_types<BitType, SecondBitType> = true> \
+ NCURSES_CPP_CONSTEXPR_INLINE type_arg operator op( \
+ const pos &bit, multiflags<BitType, SecondBitType> const &flag) \
+ NCURSES_CPP_NOEXCEPT { \
+ return flag.operator op(bit); \
+ }
+
+#define NPP_DEF_GLOB_OP_FLAGS(op) \
+ template <typename BitType, typename SecondBitType, \
+ is_combosable_types<BitType, SecondBitType> = true> \
+ NCURSES_CPP_CONSTEXPR_INLINE multiflags<BitType, SecondBitType> operator op( \
+ const flags<BitType> &flag, \
+ multiflags<BitType, SecondBitType> const &mflags) NCURSES_CPP_NOEXCEPT { \
+ return mflags.operator op( \
+ static_cast<typename flags<BitType>::mask_type>(flag)); \
+ }
+
+#define NPP_DEF_GLOB_BITTYPE(op) \
+ template <typename BitType, typename SecondBitType, \
+ is_combosable_types<BitType, SecondBitType> = true> \
+ NCURSES_CPP_CONSTEXPR_INLINE multiflags<BitType, SecondBitType> operator op( \
+ BitType lhs, SecondBitType rhs) NCURSES_CPP_NOEXCEPT { \
+ return multiflags<BitType, SecondBitType>( \
+ static_cast<typename multiflags<BitType, SecondBitType>::value_type>( \
+ lhs) \
+ op static_cast<typename multiflags< \
+ BitType, SecondBitType>::second_value_type>(rhs)); \
+ } \
+ template <typename BitType, typename SecondBitType, \
+ is_combosable_types<BitType, SecondBitType> = true> \
+ NCURSES_CPP_CONSTEXPR_INLINE multiflags<BitType, SecondBitType> operator op( \
+ SecondBitType lhs, BitType rhs) NCURSES_CPP_NOEXCEPT { \
+ return rhs op lhs; \
+ } \
+ template <typename BitType, typename SecondBitType, \
+ is_combosable_types<BitType, SecondBitType> = true> \
+ NCURSES_CPP_CONSTEXPR_INLINE multiflags<BitType, SecondBitType> operator op( \
+ flags<BitType> lhs, SecondBitType rhs) NCURSES_CPP_NOEXCEPT { \
+ return multiflags<BitType, SecondBitType>( \
+ static_cast<typename flags<BitType>::mask_type>(lhs) op static_cast< \
+ typename multiflags<BitType, SecondBitType>::second_value_type>( \
+ rhs)); \
+ } \
+ template <typename BitType, typename SecondBitType, \
+ is_combosable_types<BitType, SecondBitType> = true> \
+ NCURSES_CPP_CONSTEXPR_INLINE multiflags<BitType, SecondBitType> operator op( \
+ SecondBitType lhs, flags<BitType> rhs) NCURSES_CPP_NOEXCEPT { \
+ return rhs op lhs; \
+ }
+
+#define NPP_DEF_GLOB_OP_BOOL_FIRST(op) NPP_DEF_GLOB_OP(bool, op, BitType)
+#define NPP_DEF_GLOB_OP_BOOL_SECOND(op) NPP_DEF_GLOB_OP(bool, op, SecondBitType)
+
+#if !defined(NCURSES_CPP_HAS_SPACESHIP_OPERATOR)
+// relational operators only needed for pre C++20
+NPP_DEF_GLOB_OP_BOOL_FIRST(==)
+NPP_DEF_GLOB_OP_BOOL_FIRST(!=)
+NPP_DEF_GLOB_OP_BOOL_SECOND(==)
+NPP_DEF_GLOB_OP_BOOL_SECOND(!=)
+#endif
+
+NPP_DEF_GLOB_OP_FLAGS(&)
+NPP_DEF_GLOB_OP_FLAGS(|)
+NPP_DEF_GLOB_OP_FLAGS(^)
+
+// bitwise operators on BitType
+NPP_DEF_GLOB_BITTYPE(&)
+NPP_DEF_GLOB_BITTYPE(|)
+NPP_DEF_GLOB_BITTYPE(^)
+
+#undef NPP_DEF_GLOB_OP
+#undef NPP_DEF_GLOB_OP_FLAGS
+#undef NPP_DEF_GLOB_BITTYPE
+#undef NPP_DEF_GLOB_OP_BOOL_FIRST
+#undef NPP_DEF_GLOB_OP_BOOL_SECOND
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_UTILS_MULTIFLAGS_HPP_
diff --git a/include/ncurses/utils/preamble.hpp b/include/ncurses/utils/preamble.hpp
new file mode 100644
index 0000000..4571a75
--- /dev/null
+++ b/include/ncurses/utils/preamble.hpp
@@ -0,0 +1,8 @@
+#ifndef INCLUDE_UTILS_PREAMBLE_HPP_
+#define INCLUDE_UTILS_PREAMBLE_HPP_
+
+#include <ncurses.h>
+
+#include <ncurses/utils/macros.hpp>
+
+#endif // INCLUDE_UTILS_PREAMBLE_HPP_
diff --git a/include/ncurses/window.hpp b/include/ncurses/window.hpp
new file mode 100644
index 0000000..7d26776
--- /dev/null
+++ b/include/ncurses/window.hpp
@@ -0,0 +1,17 @@
+#ifndef INCLUDE_NCURSES_WINDOW_HPP_
+#define INCLUDE_NCURSES_WINDOW_HPP_
+
+#include <ncurses/utils/macros.hpp>
+
+namespace NCURSES_CPP_NAMESPACE {
+
+class window {
+public:
+ window(int i);
+
+private:
+};
+
+} // namespace NCURSES_CPP_NAMESPACE
+
+#endif // INCLUDE_NCURSES_WINDOW_HPP_