summaryrefslogtreecommitdiff
path: root/ycurses/src/curses/curses.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ycurses/src/curses/curses.cpp')
-rw-r--r--ycurses/src/curses/curses.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/ycurses/src/curses/curses.cpp b/ycurses/src/curses/curses.cpp
new file mode 100644
index 0000000..3605e59
--- /dev/null
+++ b/ycurses/src/curses/curses.cpp
@@ -0,0 +1,86 @@
+#ifndef CURSES_CPP
+#define CURSES_CPP
+
+#include "curses.h"
+
+int curses::i_self_counter = 0;
+
+curses::curses()
+{
+ if ( ++i_self_counter == 1 )
+ {
+ initscr();
+ raw();
+ keypad(stdscr, TRUE);
+ noecho();
+ }
+}
+
+curses::~curses()
+{
+ if ( --i_self_counter == 0 )
+ {
+/*
+ Factory<attributes>::destroyAll();
+ Factory<color>::destroyAll();
+ Factory<window>::destroyAll();
+ Factory<menu>::destroyAll();
+ Factory<pwindow>::destroyAll();
+ */
+ clear();
+ endwin();
+ }
+}
+
+void
+curses::finish()
+{
+}
+
+int
+curses::get_char()
+{
+ return getch();
+}
+
+string
+curses::get_string()
+{
+ char c[1024];
+ getstr(c);
+ return string(c);
+}
+
+void
+curses::pause()
+{
+ getch();
+}
+
+void
+curses::disable()
+{
+ refresh();
+ def_prog_mode();
+ endwin();
+}
+
+void
+curses::enable()
+{
+ reset_prog_mode();
+ refresh();
+}
+
+void
+curses::clear()
+{
+ coordinate coord(LINES, COLS);
+ for ( int i = 0; i < coord.y; ++i )
+ for ( int j = 0; j < coord.x; ++j )
+ mvaddch(i, j, ' ');
+
+ refresh();
+}
+
+#endif