edn/sources/appl/init.cpp

158 lines
3.6 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)
{
2012-08-10 12:11:28 +02:00
#ifdef __TARGET_OS__Linux
#ifdef MODE_RELEASE
APPL_INFO("==> Init "PROJECT_NAME" (START) (Linux) (Release)");
#else
APPL_INFO("==> Init "PROJECT_NAME" (START) (Linux) (Debug)");
#endif
#else
#ifdef MODE_RELEASE
APPL_INFO("==> Init "PROJECT_NAME" (START) (Android) (Release)");
#else
APPL_INFO("==> Init "PROJECT_NAME" (START) (Android) (Debug)");
#endif
#endif
ewol::ChangeSize(ivec2(800, 600));
etk::InitDefaultFolder(PROJECT_NAME);
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
// init internal global value
globals::init();
// 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)");
}
etk::UString APP_Icon(void)
2012-03-29 17:48:48 +02:00
{
etk::UString bitmapFile("DATA:iconEdn.bmp");
2012-03-29 17:48:48 +02:00
return bitmapFile;
}
/**
* @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
}