/* application.cc * This file is part of ncursesxx library * Copyright (c) 2003,2004 by Stanislav Ievlev * * This file is covered by the GNU Library General Public License, * which should be included with libncursesxx as the file COPYING. */ #include #include #include using ncurses::application; application::application () { /* * init ncurses enviroment * We use newterm/delscreen instead of initscr to reduce number of memory leaks */ char const *name; if ((name = getenv ("TERM")) == NULL || !*name) name = "unknown"; screen_ = newterm (const_cast (name), stdout, stdin); if (!screen_) throw std::runtime_error ("newterm failed"); def_prog_mode (); return_unless (cbreak () == OK); return_unless (noecho () == OK); return_unless (nonl () == OK); return_unless (notimeout (stdscr, true) == OK); if (has_colors ()) return_unless (start_color () == OK); mousemask (ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr); cursor_off (); /* turn off cursor, by default */ } application::~application () { endwin (); delscreen (screen_); } int application::width () const { return COLS; } int application::height () const { return LINES; } void application::cursor_on () { /* first try to made cursor super visible, otherwise made it normal */ curs_set (cursor_visible ? 2 : 1); } void application::cursor_off () { curs_set (0); /* turn on cursor */ }