edn/Sources/appl/init.cpp

186 lines
5.0 KiB
C++
Raw Normal View History

/**
*******************************************************************************
* @file init.cpp
* @brief Editeur De N'ours : main fonction
* @author Edouard DUPIN
* @date 26/01/2011
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
2012-04-24 09:42:14 +02:00
#include <etk/UString.h>
#include <ewol/ewol.h>
#include <ewol/EObject.h>
#include <ewol/WidgetManager.h>
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-03-29 17:48:48 +02:00
#include <etk/File.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>
MainWindows * basicWindows = NULL;
/**
* @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
2012-08-19 16:56:59 +02:00
ewol::ChangeSize(Vector2D<int32_t>(800, 600));
etk::InitDefaultFolder(PROJECT_NAME);
ewol::SetFontFolder("Font");
2012-01-25 23:32:14 +01:00
2012-08-10 12:11:28 +02:00
#ifdef __TARGET_OS__Android
2012-03-29 10:01:00 +02:00
ewol::SetDefaultFont("freefont/FreeSerif.ttf", 19);
2012-02-17 18:25:38 +01:00
#else
ewol::SetDefaultFont("freefont/FreeSerif.ttf", 14);
2012-02-17 18:25:38 +01:00
#endif
2012-01-25 23:32:14 +01:00
// 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();
etk::UString corlorFile = "color_white.xml";
ColorizeManager::LoadFile( corlorFile.c_str() );
2012-02-19 22:33:43 +01:00
ColorizeManager::DisplayListOfColor();
2012-02-19 22:33:43 +01:00
HighlightManager::Init();
HighlightManager::loadLanguages();
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
ewol::DisplayWindows(basicWindows);
2012-01-25 23:32:14 +01:00
2012-02-24 12:45:39 +01:00
// add generic shortcut ...
// (shift, control, alt, meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data)
2012-02-27 18:15:56 +01:00
ewol::shortCut::Add("ctrl+o", ednMsgGuiOpen, "");
ewol::shortCut::Add("ctrl+n", ednMsgGuiNew, "");
2012-02-24 12:45:39 +01:00
ewol::shortCut::Add("ctrl+s", ednMsgGuiSave, "current");
ewol::shortCut::Add("ctrl+shift+s", ednMsgGuiSave, "All");
2012-02-27 18:15:56 +01:00
ewol::shortCut::Add("ctrl+q", ednMsgGuiClose, "current");
ewol::shortCut::Add("ctrl+shift+q", ednMsgGuiClose, "All");
2012-02-24 12:45:39 +01:00
ewol::shortCut::Add("ctrl+z", ednMsgGuiUndo, "");
ewol::shortCut::Add("ctrl+shift+z", ednMsgGuiRedo, "");
ewol::shortCut::Add("ctrl+w", ednMsgGuiRm, "Line");
ewol::shortCut::Add("ctrl+shift+w", ednMsgGuiRm, "Paragraph");
ewol::shortCut::Add("ctrl+x", ednMsgGuiCut, "STD");
ewol::shortCut::Add("ctrl+c", ednMsgGuiCopy, "STD");
ewol::shortCut::Add("ctrl+v", ednMsgGuiPaste, "STD");
ewol::shortCut::Add("ctrl+a", ednMsgGuiSelect, "ALL");
ewol::shortCut::Add("ctrl+shift+a", ednMsgGuiSelect, "NONE");
ewol::shortCut::Add("ctrl+l", ednMsgGuiGotoLine, "???");
2012-07-03 16:59:22 +02:00
ewol::shortCut::Add("ctrl+f", ednMsgGuiSearch, "");
2012-02-24 12:45:39 +01:00
// add files
2012-04-23 10:15:43 +02:00
APPL_INFO("show list of files : ");
2012-02-02 13:57:57 +01:00
2012-08-19 16:56:59 +02:00
for( int32_t iii=0 ; iii<ewol::CmdLine::Nb(); iii++) {
APPL_INFO("need load file : \"" << ewol::CmdLine::Get(iii) << "\"" );
etk::UString tmpppp = ewol::CmdLine::Get(iii);
2012-02-28 18:22:49 +01:00
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)");
}
2012-03-29 17:48:48 +02:00
etk::File APP_Icon(void)
{
etk::File bitmapFile("iconEdn.bmp", etk::FILE_TYPE_DATA);
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-02-02 13:57:57 +01:00
// Remove windows :
ewol::DisplayWindows(NULL);
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("Stop Search");
//Search::Kill();
2012-04-23 10:15:43 +02:00
//APPL_INFO("Stop Accel key");
2012-02-02 13:57:57 +01:00
//AccelKey::Kill();
if (NULL != basicWindows) {
delete(basicWindows);
basicWindows = NULL;
}
2012-04-23 10:15:43 +02:00
APPL_INFO("==> Un-Init Edn (END)");
2012-02-02 13:57:57 +01:00
}