From 405a6e7eade91f27261d8bb4a37440b964f79e27 Mon Sep 17 00:00:00 2001 From: Alexander Zhirov Date: Tue, 6 Jan 2026 10:57:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=BC=D0=BE=D0=B4?= =?UTF-8?q?=D1=83=D0=BB=D1=8C=20window.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ncui/core/window.d | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 source/ncui/core/window.d diff --git a/source/ncui/core/window.d b/source/ncui/core/window.d new file mode 100644 index 0000000..5d31db9 --- /dev/null +++ b/source/ncui/core/window.d @@ -0,0 +1,64 @@ +module ncui.core.window; + +import deimos.ncurses; + +import ncui.core.ncwin; +import ncui.lib.checks; + +final class Window +{ +private: + NCWin _window; + bool _closed; + +public: + this(int h, int w, int y, int x) + { + _window = ncuiNotNull!newwin(h, w, y, x); + } + + int height() + { + return ncuiNotErr!getmaxy(_window); + } + + int width() + { + return ncuiNotErr!getmaxx(_window); + } + + void border() + { + ncuiNotErr!box(_window, 0, 0); + } + + void erase() + { + ncuiNotErr!werase(_window); + } + + void refresh() + { + ncuiNotErr!wrefresh(_window); + } + + @property NCWin handle() + { + return _window; + } + + void close() + { + if (_closed) + return; + if (!_window.isNull) + ncuiNotErr!delwin(_window); + _window = NCWin(null); + _closed = true; + } + + ~this() + { + close(); + } +}