1 // * this is for making emacs happy: -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright 2019,2020 Thomas E. Dickey *
4 * Copyright 1998-2007,2008 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************/
31 /****************************************************************************
32 * Author: Juergen Pfeifer, 1997 *
33 * and: Thomas E. Dickey *
34 ****************************************************************************/
37 #include "cursesapp.h"
39 MODULE_ID("$Id: cursesapp.cc,v 1.17 2020/02/02 23:34:34 tom Exp $")
42 NCursesApplication::init(bool bColors)
45 NCursesWindow::useColors();
47 if (Root_Window->colors() > 1) {
49 Root_Window->setcolor(1);
50 Root_Window->setpalette(COLOR_YELLOW,COLOR_BLUE);
51 Root_Window->setcolor(2);
52 Root_Window->setpalette(COLOR_CYAN,COLOR_BLUE);
53 Root_Window->setcolor(3);
54 Root_Window->setpalette(COLOR_BLACK,COLOR_BLUE);
55 Root_Window->setcolor(4);
56 Root_Window->setpalette(COLOR_BLACK,COLOR_CYAN);
57 Root_Window->setcolor(5);
58 Root_Window->setpalette(COLOR_BLUE,COLOR_YELLOW);
59 Root_Window->setcolor(6);
60 Root_Window->setpalette(COLOR_BLACK,COLOR_GREEN);
65 Root_Window->bkgd(' '|window_backgrounds());
68 NCursesApplication* NCursesApplication::theApp = 0;
69 NCursesWindow* NCursesApplication::titleWindow = 0;
70 NCursesApplication::SLK_Link* NCursesApplication::slk_stack = 0;
72 NCursesApplication::~NCursesApplication() THROWS(NCursesException)
74 Soft_Label_Key_Set* S;
90 int NCursesApplication::rinit(NCursesWindow& w)
96 void NCursesApplication::push(Soft_Label_Key_Set& S)
98 SLK_Link* L = new SLK_Link;
107 bool NCursesApplication::pop()
110 SLK_Link* L = slk_stack;
111 slk_stack = slk_stack->prev;
114 Soft_Label_Key_Set* xx = top();
119 return (slk_stack ? FALSE : TRUE);
122 Soft_Label_Key_Set* NCursesApplication::top() const
125 return slk_stack->SLKs;
127 return static_cast<Soft_Label_Key_Set*>(0);
130 int NCursesApplication::operator()(void)
132 bool bColors = b_Colors;
133 Soft_Label_Key_Set* S = 0;
135 int ts = titlesize();
137 NCursesWindow::ripoffline(ts,rinit);
138 Soft_Label_Key_Set::Label_Layout fmt = useSLKs();
139 if (fmt!=Soft_Label_Key_Set::None) {
140 S = new Soft_Label_Key_Set(fmt);
145 Root_Window = new NCursesWindow(::stdscr);
150 if (fmt!=Soft_Label_Key_Set::None) {
157 NCursesApplication::NCursesApplication(bool bColors)
162 THROW(new NCursesException("Application object already created."));