cf20462abc
* BUG: Input: Comment all NoDelay related stuff out * BUG: Window: PrintCenter() handles empty lines now * NEW: Pair: Allocate all pairs at initialisation and inhibit any change to them. Array accessors can be used to get the pair number for a given fore-/background combination * NEW: Window: Rewrite the Window class * NEW: Remove the Insert() method * NEW: Remove .Window.Attrs' Color property * NEW: BorderFrame is an optional argument to the constructor (default True) to specify if there shall be a border frame around the window setting the border apart from the content * NEW: Ask() returns the choice number to ease translation * NEW: Ask() supports a default choice in upper case * NEW: Make Read event work * NEW: Screen: Rewrite it mostly (is a static class again) * NEW: Remove Read event * NEW: Make Resize event work * NEW: Rename .Cols and .Lines to .Width resp. .Height * NEW: Declare gb.ncurses "Unfinished" * OPT: Tidy up sources * OPT: Window: Use werase() instead of wclear() to clear [EXAMPLES] * NEW: Add 'Pong' in the Games section git-svn-id: svn://localhost/gambas/trunk@5543 867c0c6c-44f3-4631-809d-bfa615b0a4ec
105 lines
1.8 KiB
C
105 lines
1.8 KiB
C
/*
|
|
* main.c - gb.ncurses main object
|
|
*
|
|
* Copyright (C) 2012/3 Tobias Boege <tobias@gambas-buch.de>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
* MA 02110-1301, USA.
|
|
*/
|
|
|
|
#define __MAIN_C
|
|
|
|
#include "c_window.h"
|
|
#include "c_key.h"
|
|
#include "c_color.h"
|
|
#include "c_screen.h"
|
|
#include "c_input.h"
|
|
#include "main.h"
|
|
|
|
GB_INTERFACE GB EXPORT;
|
|
|
|
GB_DESC *GB_CLASSES[] EXPORT = {
|
|
CScreenDesc,
|
|
CInputDesc,
|
|
CCursorDesc,
|
|
|
|
CWindowDesc,
|
|
CWindowAttrsDesc,
|
|
CCharAttrsDesc,
|
|
CBorderDesc,
|
|
|
|
CKeyDesc,
|
|
|
|
CColorDesc,
|
|
CColorInfoDesc,
|
|
CPairDesc,
|
|
|
|
NULL
|
|
};
|
|
|
|
static bool _init = FALSE;
|
|
|
|
bool MAIN_running()
|
|
{
|
|
return _init && (!isendwin() || stdscr);
|
|
}
|
|
|
|
static void MAIN_init()
|
|
{
|
|
if (_init)
|
|
return;
|
|
|
|
initscr();
|
|
keypad(stdscr, TRUE);
|
|
|
|
SCREEN_init();
|
|
COLOR_init();
|
|
|
|
refresh();
|
|
|
|
_init = TRUE;
|
|
}
|
|
|
|
static void MAIN_exit()
|
|
{
|
|
if (_init) {
|
|
SCREEN_exit();
|
|
endwin();
|
|
_init = FALSE;
|
|
}
|
|
}
|
|
|
|
static void MAIN_hook_error(int code, char *error, char *where)
|
|
{
|
|
MAIN_exit();
|
|
}
|
|
|
|
static void MAIN_hook_main(int *argc, char **argv)
|
|
{
|
|
MAIN_init();
|
|
}
|
|
|
|
int EXPORT GB_INIT()
|
|
{
|
|
GB.Hook(GB_HOOK_ERROR, (void *) MAIN_hook_error);
|
|
GB.Hook(GB_HOOK_MAIN, (void *) MAIN_hook_main);
|
|
return 0;
|
|
}
|
|
|
|
|
|
void EXPORT GB_EXIT()
|
|
{
|
|
MAIN_exit();
|
|
}
|