edn/sources/appl/init.cpp

164 lines
3.8 KiB
C++
Raw Normal View History

/**
* @author Edouard DUPIN
2012-11-25 11:55:06 +01:00
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
2012-11-25 11:55:06 +01:00
#include <etk/types.h>
2012-04-24 09:42:14 +02:00
#include <etk/UString.h>
#include <ewol/ewol.h>
#include <ewol/eObject/EObject.h>
#include <ewol/widget/WidgetManager.h>
2012-04-24 09:42:14 +02:00
2012-04-23 10:15:43 +02:00
#include <appl/Debug.h>
2012-04-24 09:42:14 +02:00
#include <appl/global.h>
2012-11-01 10:47:36 +01:00
#include <etk/os/FSNode.h>
2012-07-13 18:12:14 +02:00
#include <etk/tool.h>
2012-02-18 00:35:15 +01:00
#include <Gui/MainWindows.h>
#include <BufferManager.h>
#include <ColorizeManager.h>
#include <HighlightManager.h>
2012-02-18 00:35:15 +01:00
#include <Gui/Search.h>
#include <unistd.h>
#include <readtags.h>
#include <CTagsManager.h>
2012-04-24 09:42:14 +02:00
#include <globalMsg.h>
2012-11-25 11:55:06 +01:00
#include <ewol/config.h>
#include <ewol/commandLine.h>
MainWindows * basicWindows = NULL;
2012-11-22 21:39:15 +01:00
/**
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
* @param std IO
* @return std IO
*/
2012-11-25 11:55:06 +01:00
int main(int argc, const char *argv[])
2012-11-22 21:39:15 +01:00
{
// only one things to do :
return ewol::Run(argc, argv);
}
/**
* @brief main application function Initialisation
*/
2012-02-02 13:57:57 +01:00
void APP_Init(void)
{
2013-01-11 23:14:15 +01:00
#ifdef MODE_RELEASE
2013-03-01 09:14:53 +01:00
const char * debugMode = "Release";
2013-01-11 23:14:15 +01:00
#else
2013-03-01 09:14:53 +01:00
const char * debugMode = "Debug";
2013-01-11 23:14:15 +01:00
#endif
2012-08-10 12:11:28 +02:00
#ifdef __TARGET_OS__Linux
2013-03-01 09:14:53 +01:00
const char * osMode = "Linux";
2013-01-11 23:14:15 +01:00
#elif defined(__TARGET_OS__Android)
2013-03-01 09:14:53 +01:00
const char * osMode = "Android";
2013-01-11 23:14:15 +01:00
#elif defined(__TARGET_OS__Windows)
2013-03-01 09:14:53 +01:00
const char * osMode = "Windows";
2013-01-11 23:14:15 +01:00
#elif defined(__TARGET_OS__IOs)
2013-03-01 09:14:53 +01:00
const char * osMode = "IOs";
2013-01-11 23:14:15 +01:00
#elif defined(__TARGET_OS__MacOs)
2013-03-01 09:14:53 +01:00
const char * osMode = "MacOs";
#else
2013-03-01 09:14:53 +01:00
const char * osMode = "Unknown";
#endif
2013-01-11 23:14:15 +01:00
APPL_INFO("==> Init "PROJECT_NAME" (START) [" << osMode << "] (" << debugMode << ")");
ewol::ChangeSize(ivec2(800, 600));
2012-08-10 12:11:28 +02:00
#ifdef __TARGET_OS__Android
2012-11-25 11:55:06 +01:00
ewol::config::FontSetDefault("FreeSerif", 19);
2012-02-17 18:25:38 +01:00
#else
2012-11-25 11:55:06 +01:00
ewol::config::FontSetDefault("FreeSerif", 14);
2012-02-17 18:25:38 +01:00
#endif
2013-01-01 21:58:39 +01:00
// set the application icon ...
ewol::SetIcon("DATA:icon.png");
// init internal global value
globals::init();
2013-01-11 23:14:15 +01:00
// set the application icon ...
ewol::SetIcon("DATA:icon.png");
// init ALL Singleton :
//(void)CTagsManager::getInstance();
BufferManager::Init();
// set color and other trucs...
2012-02-19 22:33:43 +01:00
ColorizeManager::Init();
2012-11-09 09:59:31 +01:00
ColorizeManager::LoadFile( "white" );
2012-02-19 22:33:43 +01:00
ColorizeManager::DisplayListOfColor();
2012-02-19 22:33:43 +01:00
HighlightManager::Init();
HighlightManager::loadLanguages();
cTagsManager::Init();
char cCurrentPath[FILENAME_MAX];
// get the curent program folder
if (!getcwd(cCurrentPath, FILENAME_MAX)) {
return ;
}
cCurrentPath[FILENAME_MAX - 1] = '\0';
2012-04-23 10:15:43 +02:00
//APPL_INFO("The current working directory is " << cCurrentPath);
basicWindows = new MainWindows();
2012-02-02 13:57:57 +01:00
if (NULL == basicWindows) {
2012-04-23 10:15:43 +02:00
APPL_ERROR("Can not allocate the basic windows");
2012-02-02 13:57:57 +01:00
ewol::Stop();
return;
}
// create the specific windows
2012-11-25 11:55:06 +01:00
ewol::WindowsSet(basicWindows);
2012-02-24 12:45:39 +01:00
// add files
2012-04-23 10:15:43 +02:00
APPL_INFO("show list of files : ");
bool ctagDetected = false;
2012-11-25 11:55:06 +01:00
for( int32_t iii=0 ; iii<ewol::commandLine::Size(); iii++) {
etk::UString tmpppp = ewol::commandLine::Get(iii);
if (tmpppp == "-t") {
ctagDetected = true;
} else if (true == ctagDetected) {
APPL_INFO("Load ctag file : \"" << tmpppp << "\"" );
ctagDetected = false;
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgCtagsLoadFile, tmpppp);
} else {
APPL_INFO("need load file : \"" << tmpppp << "\"" );
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgOpenFile, tmpppp);
}
}
2012-02-24 12:45:39 +01:00
2012-04-23 10:15:43 +02:00
APPL_INFO("==> Init Edn (END)");
}
/**
* @brief main application function Un-Initialisation
*/
void APP_UnInit(void)
{
2012-04-23 10:15:43 +02:00
APPL_INFO("==> Un-Init Edn (START)");
2012-12-02 20:34:00 +01:00
if (NULL != basicWindows) {
delete(basicWindows);
basicWindows = NULL;
}
2012-02-02 13:57:57 +01:00
cTagsManager::UnInit();
2012-04-23 10:15:43 +02:00
APPL_INFO("Stop Hightlight");
2012-02-19 22:33:43 +01:00
HighlightManager::UnInit();
//Kill all singleton
2012-04-23 10:15:43 +02:00
APPL_INFO("Stop BufferManager");
BufferManager::UnInit();
2012-04-23 10:15:43 +02:00
APPL_INFO("Stop ColorizeManager");
2012-02-19 22:33:43 +01:00
ColorizeManager::UnInit();
2012-04-23 10:15:43 +02:00
APPL_INFO("==> Un-Init Edn (END)");
2012-02-02 13:57:57 +01:00
}