]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - c++/cursesapp.cc
ncurses 6.1 - patch 20180623
[ncurses.git] / c++ / cursesapp.cc
index 82432c5c8dea300170e2694c814a4a2e91ed7a90..ddab6fdf9b9dd182e4df8ddce9e0cf3d4c00b6bf 100644 (file)
@@ -1,6 +1,6 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 
 /****************************************************************************
  *   Author: Juergen Pfeifer, 1997                                          *
 
 /****************************************************************************
  *   Author: Juergen Pfeifer, 1997                                          *
+ *      and: Thomas E. Dickey                                               *
  ****************************************************************************/
 
 #include "internal.h"
 #include "cursesapp.h"
 
  ****************************************************************************/
 
 #include "internal.h"
 #include "cursesapp.h"
 
-MODULE_ID("$Id: cursesapp.cc,v 1.10 2003/10/25 15:04:46 tom Exp $")
+MODULE_ID("$Id: cursesapp.cc,v 1.15 2008/08/16 17:15:35 tom Exp $")
 
 void
 
 void
-NCursesApplication::init(bool bColors) {
+NCursesApplication::init(bool bColors)
+{
   if (bColors)
     NCursesWindow::useColors();
   if (bColors)
     NCursesWindow::useColors();
-  
-  if (Root_Window->colors() > 1) {    
+
+  if (Root_Window->colors() > 1) {
     b_Colors = TRUE;
     Root_Window->setcolor(1);
     Root_Window->setpalette(COLOR_YELLOW,COLOR_BLUE);
     b_Colors = TRUE;
     Root_Window->setcolor(1);
     Root_Window->setpalette(COLOR_YELLOW,COLOR_BLUE);
@@ -66,24 +68,32 @@ NCursesApplication* NCursesApplication::theApp = 0;
 NCursesWindow* NCursesApplication::titleWindow = 0;
 NCursesApplication::SLK_Link* NCursesApplication::slk_stack = 0;
 
 NCursesWindow* NCursesApplication::titleWindow = 0;
 NCursesApplication::SLK_Link* NCursesApplication::slk_stack = 0;
 
-NCursesApplication::~NCursesApplication() {
+NCursesApplication::~NCursesApplication()
+{
   Soft_Label_Key_Set* S;
 
   delete titleWindow;
   Soft_Label_Key_Set* S;
 
   delete titleWindow;
+  titleWindow = 0;
+
   while( (S=top()) ) {
     pop();
     delete S;
   }
   while( (S=top()) ) {
     pop();
     delete S;
   }
+
   delete Root_Window;
   delete Root_Window;
+  Root_Window = 0;
+
   ::endwin();
 }
 
   ::endwin();
 }
 
-int NCursesApplication::rinit(NCursesWindow& w) {
+int NCursesApplication::rinit(NCursesWindow& w)
+{
   titleWindow = &w;
   return OK;
 }
 
   titleWindow = &w;
   return OK;
 }
 
-void NCursesApplication::push(Soft_Label_Key_Set& S) {
+void NCursesApplication::push(Soft_Label_Key_Set& S)
+{
   SLK_Link* L = new SLK_Link;
   assert(L != 0);
   L->prev = slk_stack;
   SLK_Link* L = new SLK_Link;
   assert(L != 0);
   L->prev = slk_stack;
@@ -93,33 +103,39 @@ void NCursesApplication::push(Soft_Label_Key_Set& S) {
     S.show();
 }
 
     S.show();
 }
 
-bool NCursesApplication::pop() {
+bool NCursesApplication::pop()
+{
   if (slk_stack) {
     SLK_Link* L = slk_stack;
     slk_stack = slk_stack->prev;
     delete L;
   if (slk_stack) {
     SLK_Link* L = slk_stack;
     slk_stack = slk_stack->prev;
     delete L;
-    if (Root_Window && top())
-      top()->show();
+    if (Root_Window) {
+      Soft_Label_Key_Set* xx = top();
+      if (xx != 0)
+        xx->show();
+    }
   }
   return (slk_stack ? FALSE : TRUE);
 }
 
   }
   return (slk_stack ? FALSE : TRUE);
 }
 
-Soft_Label_Key_Set* NCursesApplication::top() const {
+Soft_Label_Key_Set* NCursesApplication::top() const
+{
   if (slk_stack)
     return slk_stack->SLKs;
   else
   if (slk_stack)
     return slk_stack->SLKs;
   else
-    return (Soft_Label_Key_Set*)0;
+    return static_cast<Soft_Label_Key_Set*>(0);
 }
 
 }
 
-int NCursesApplication::operator()(void) {
+int NCursesApplication::operator()(void)
+{
   bool bColors = b_Colors;
   bool bColors = b_Colors;
-  Soft_Label_Key_Set* S;
+  Soft_Label_Key_Set* S = 0;
 
   int ts = titlesize();
   if (ts>0)
     NCursesWindow::ripoffline(ts,rinit);
   Soft_Label_Key_Set::Label_Layout fmt = useSLKs();
 
   int ts = titlesize();
   if (ts>0)
     NCursesWindow::ripoffline(ts,rinit);
   Soft_Label_Key_Set::Label_Layout fmt = useSLKs();
-  if (fmt!=Soft_Label_Key_Set::None) {    
+  if (fmt!=Soft_Label_Key_Set::None) {
     S = new Soft_Label_Key_Set(fmt);
     assert(S != 0);
     init_labels(*S);
     S = new Soft_Label_Key_Set(fmt);
     assert(S != 0);
     init_labels(*S);
@@ -137,8 +153,10 @@ int NCursesApplication::operator()(void) {
   return run();
 }
 
   return run();
 }
 
-NCursesApplication::NCursesApplication(bool bColors) {
-  b_Colors = bColors;
+NCursesApplication::NCursesApplication(bool bColors)
+  : b_Colors(bColors),
+    Root_Window(NULL)
+{
   if (theApp)
     THROW(new NCursesException("Application object already created."));
   else
   if (theApp)
     THROW(new NCursesException("Application object already created."));
   else