ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/ncxx/application.cpp
Revision: 1.4
Committed: Wed Oct 20 05:09:28 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +0 -0 lines
State: FILE REMOVED
Log Message:
unused

File Contents

# User Rev Content
1 sf-pippijn 1.1 /* application.cc
2     * This file is part of ncursesxx library
3     * Copyright (c) 2003,2004 by Stanislav Ievlev
4     *
5     * This file is covered by the GNU Library General Public License,
6     * which should be included with libncursesxx as the file COPYING.
7     */
8     #include <stdexcept>
9    
10     #include <term.h>
11    
12     #include <ncurses/application.hh>
13    
14     using ncurses::application;
15    
16     application::application ()
17     {
18     /*
19     * init ncurses enviroment
20     * We use newterm/delscreen instead of initscr to reduce number of memory leaks
21     */
22     char const *name;
23    
24     if ((name = getenv ("TERM")) == NULL || !*name)
25     name = "unknown";
26     screen_ = newterm (const_cast<char *> (name), stdout, stdin);
27    
28     if (!screen_)
29 sf-pippijn 1.3 throw std::runtime_error ("newterm failed");
30 sf-pippijn 1.1
31     def_prog_mode ();
32 sf-pippijn 1.2 return_unless (cbreak () == OK);
33     return_unless (noecho () == OK);
34     return_unless (nonl () == OK);
35     return_unless (notimeout (stdscr, true) == OK);
36 sf-pippijn 1.1
37     if (has_colors ())
38 sf-pippijn 1.2 return_unless (start_color () == OK);
39 sf-pippijn 1.1
40     mousemask (ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr);
41     cursor_off (); /* turn off cursor, by default */
42     }
43    
44     application::~application ()
45     {
46     endwin ();
47     delscreen (screen_);
48     }
49    
50     int
51     application::width () const
52     {
53     return COLS;
54     }
55    
56     int
57     application::height () const
58     {
59     return LINES;
60     }
61    
62     void
63     application::cursor_on ()
64     {
65     /* first try to made cursor super visible, otherwise made it normal */
66     curs_set (cursor_visible ? 2 : 1);
67     }
68    
69     void
70     application::cursor_off ()
71     {
72     curs_set (0); /* turn on cursor */
73     }