[DEV] Update to the new tree of the the sub lib
This commit is contained in:
140
sources/appl/Buffer/Buffer.cpp
Normal file
140
sources/appl/Buffer/Buffer.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Buffer.c
|
||||
* @brief Editeur De N'ours : Text Buffer
|
||||
* @author Edouard DUPIN
|
||||
* @date 08/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <Buffer.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Buffer"
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Buffer::Buffer()
|
||||
{
|
||||
static int32_t fileBasicID = 0;
|
||||
m_updatePositionRequested = false;
|
||||
m_fileModify = true;
|
||||
m_haveName = false;
|
||||
etk::UString mString = "Untitle - ";
|
||||
mString += fileBasicID++;
|
||||
EWOL_DEBUG("Create buffer try name : \"" << mString << "\"");
|
||||
SetFileName(mString);
|
||||
m_haveName = false;
|
||||
EWOL_DEBUG("Create buffer with name : " << m_fileName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Buffer::Buffer(etk::FSNode &newName)
|
||||
{
|
||||
m_fileModify = false;
|
||||
EWOL_DEBUG("Create buffer try name : \"" << newName << "\"");
|
||||
SetFileName(newName);
|
||||
EWOL_DEBUG("Create buffer with name : " << m_fileName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Buffer::~Buffer(void)
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool Buffer::IsModify(void)
|
||||
{
|
||||
return m_fileModify;
|
||||
}
|
||||
|
||||
void Buffer::SetModify(bool status)
|
||||
{
|
||||
if (status != m_fileModify) {
|
||||
m_fileModify = status;
|
||||
// TODO : Remove from here
|
||||
etk::UString data = "Modify";
|
||||
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgBufferState, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool Buffer::NeedToUpdateDisplayPosition(void)
|
||||
{
|
||||
bool tmpVal = m_updatePositionRequested;
|
||||
m_updatePositionRequested = false;
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
etk::Vector2D<float> Buffer::GetBorderSize(void)
|
||||
{
|
||||
etk::Vector2D<float> tmpVal;
|
||||
tmpVal.x = 30;
|
||||
tmpVal.y = 30;
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
|
||||
etk::Vector2D<float> Buffer::GetPosition(int32_t fontId,bool& centerRequested)
|
||||
{
|
||||
centerRequested = false;
|
||||
etk::Vector2D<float> tmpVal;
|
||||
tmpVal.x = 0;
|
||||
tmpVal.y = 0;
|
||||
return tmpVal;
|
||||
}
|
149
sources/appl/Buffer/Buffer.h
Normal file
149
sources/appl/Buffer/Buffer.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Buffer.h
|
||||
* @brief Editeur De N'ours : Text Buffer (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 08/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __BUFFER_H__
|
||||
#define __BUFFER_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <etk/unicode.h>
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
|
||||
typedef struct{
|
||||
uint32_t nbTotalLine; //!< Number of line in the buffer
|
||||
uint32_t nbTotalColomn; //!< Number of line in the buffer
|
||||
uint32_t startLineDisplay; //!< First line display.
|
||||
uint32_t startColomnDisplay; //!< First Colomn displayed
|
||||
uint32_t diplayableColomn; //!< NB colomn that can be displayed
|
||||
uint32_t diplayableLine; //!< NB Line that can be displayed
|
||||
}infoStatBuffer_ts;
|
||||
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
#define TEXT_DISPLAY_TYPE OObject2DTextShader
|
||||
#else
|
||||
#define TEXT_DISPLAY_TYPE OObject2DTextColored
|
||||
#endif
|
||||
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer(void);
|
||||
Buffer(etk::FSNode &newName);
|
||||
virtual ~Buffer(void);
|
||||
|
||||
etk::FSNode GetFileName(void)
|
||||
{
|
||||
return m_fileName;
|
||||
};
|
||||
|
||||
void SetFileName(etk::FSNode &newName)
|
||||
{
|
||||
m_fileName = newName;
|
||||
m_haveName = true;
|
||||
NameChange();
|
||||
};
|
||||
|
||||
void SetFileName(etk::UString &newName)
|
||||
{
|
||||
m_fileName.SetName(newName);
|
||||
m_haveName = true;
|
||||
NameChange();
|
||||
};
|
||||
|
||||
bool HaveName(void)
|
||||
{
|
||||
return m_haveName;
|
||||
}
|
||||
|
||||
virtual void Save(void) {};
|
||||
bool IsModify(void);
|
||||
protected:
|
||||
void SetModify(bool status);
|
||||
virtual void NameChange(void) { /*APPL_DEBUG("check name change ==> no HL change possible");*/};
|
||||
public:
|
||||
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate) {};
|
||||
virtual void SetLineDisplay(uint32_t lineNumber) {};
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
virtual int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText,
|
||||
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
|
||||
|
||||
#else
|
||||
virtual int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextBold,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextItalic,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic,
|
||||
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
|
||||
#endif
|
||||
{
|
||||
return ERR_NONE;
|
||||
}
|
||||
virtual void AddChar(uniChar_t unicodeData) {};
|
||||
virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent) {};
|
||||
virtual void MouseSelectFromCursorTo(etk::Vector2D<float> pos) {};
|
||||
virtual void MouseEvent(etk::Vector2D<float> pos) {};
|
||||
virtual void MouseEventDouble(void) {};
|
||||
virtual void MouseEventTriple(void) {};
|
||||
virtual void RemoveLine(void) {};
|
||||
virtual void SelectAll(void) {};
|
||||
virtual void SelectNone(void) {};
|
||||
virtual void Undo(void) {};
|
||||
virtual void Redo(void) {};
|
||||
virtual void SetCharset(unicode::charset_te newCharset) {};
|
||||
|
||||
//virtual void SelectAll(void);
|
||||
virtual void Copy(ewol::clipBoard::clipboardListe_te clipboardID) {};
|
||||
virtual void Cut(ewol::clipBoard::clipboardListe_te clipboardID) {};
|
||||
virtual void Paste(ewol::clipBoard::clipboardListe_te clipboardID) {};
|
||||
virtual void Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp) {};
|
||||
virtual void Replace(etk::UString &data) {};
|
||||
virtual int32_t FindLine(etk::UString &data) { return 0; };
|
||||
virtual void JumpAtLine(int32_t newLine) {};
|
||||
virtual int32_t GetCurrentLine(void) { return 0; };
|
||||
|
||||
virtual int32_t GetNumberOfLine(void) { return 1; };
|
||||
|
||||
// moving with cursor change position:
|
||||
private:
|
||||
bool m_updatePositionRequested; //!< if a position xhange in the windows ...
|
||||
etk::Vector2D<float> m_maximumSize; //!< current maxSize of the buffer
|
||||
protected:
|
||||
void RequestUpdateOfThePosition(void) { m_updatePositionRequested = true; };
|
||||
void SetMaximumSize(etk::Vector2D<float> maxSize) { m_maximumSize = maxSize; };
|
||||
public:
|
||||
bool NeedToUpdateDisplayPosition(void);
|
||||
virtual etk::Vector2D<float> GetBorderSize(void); // this is to requested the minimum size for the buffer that is not consider as visible ...
|
||||
virtual etk::Vector2D<float> GetPosition(int32_t fontId, bool& centerRequested);
|
||||
etk::Vector2D<float> GetMaxSize(void) { return m_maximumSize; };
|
||||
protected:
|
||||
bool m_fileModify; //!<
|
||||
// naming
|
||||
etk::FSNode m_fileName; //!< filename of the curent buffer
|
||||
bool m_haveName; //!< to know if the file have a name or NOT
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
127
sources/appl/Buffer/BufferEmpty.cpp
Normal file
127
sources/appl/Buffer/BufferEmpty.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferEmpty.cpp
|
||||
* @brief Editeur De N'ours : Text Buffer (edit For No buffer Display)
|
||||
* @author Edouard DUPIN
|
||||
* @date 19/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <BufferEmpty.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <MainWindows.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "BufferEmpty"
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
BufferEmpty::BufferEmpty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
BufferEmpty::~BufferEmpty(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
|
||||
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
|
||||
#else
|
||||
int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextBold,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextItalic,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic,
|
||||
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
|
||||
#endif
|
||||
{
|
||||
// Get color :
|
||||
Colorize *myColor = NULL;
|
||||
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
int32_t letterHeight = OOText.GetHeight();
|
||||
#else
|
||||
int32_t letterHeight = OOTextNormal.GetHeight();
|
||||
#endif
|
||||
|
||||
etk::Vector2D<float> textPos;
|
||||
textPos.x = 20;
|
||||
textPos.y = sizeY - 20 - letterHeight;
|
||||
etk::UString tmpDisplay ;
|
||||
|
||||
myColor = ColorizeManager::Get("normal");
|
||||
tmpDisplay = "edn - Editeur De N'ours";
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
OOText.SetColor(myColor->GetFG());
|
||||
OOText.SetBold(true);
|
||||
OOText.SetItalic(false);
|
||||
OOText.Text(textPos, tmpDisplay);
|
||||
#else
|
||||
OOTextBold.SetColor(myColor->GetFG());
|
||||
OOTextBold.Text(textPos, tmpDisplay);
|
||||
#endif
|
||||
|
||||
myColor = ColorizeManager::Get("commentDoxygen");
|
||||
textPos.y = (int32_t)(textPos.y - letterHeight*1.30);
|
||||
tmpDisplay = "No Buffer Availlable to display";
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
OOText.SetBold(false);
|
||||
OOText.SetItalic(false);
|
||||
OOText.SetColor(myColor->GetFG());
|
||||
OOText.Text(textPos, tmpDisplay);
|
||||
#else
|
||||
OOTextNormal.SetColor(myColor->GetFG());
|
||||
OOTextNormal.Text(textPos, tmpDisplay);
|
||||
#endif
|
||||
|
||||
OOColored.SetColor(draw::color::white);
|
||||
OOColored.Rectangle( 0, 0, sizeX, sizeY);
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
52
sources/appl/Buffer/BufferEmpty.h
Normal file
52
sources/appl/Buffer/BufferEmpty.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferEmpty.h
|
||||
* @brief Editeur De N'ours : Text Buffer (edit For No buffer Display) (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 19/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __BUFFER_EMPTY_H__
|
||||
#define __BUFFER_EMPTY_H__
|
||||
|
||||
#include <Buffer.h>
|
||||
|
||||
class BufferEmpty : public Buffer {
|
||||
public:
|
||||
BufferEmpty(void);
|
||||
virtual ~BufferEmpty(void);
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText,
|
||||
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
|
||||
#else
|
||||
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextBold,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextItalic,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic,
|
||||
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
609
sources/appl/Buffer/BufferManager.cpp
Normal file
609
sources/appl/Buffer/BufferManager.cpp
Normal file
@@ -0,0 +1,609 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferManager.cpp
|
||||
* @brief Editeur De N'ours : Text Buffer manager (sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 08/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
#include <ewol/eObject/EObjectManager.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "classBufferManager"
|
||||
|
||||
class classBufferManager: public ewol::EObject
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
classBufferManager(void);
|
||||
~classBufferManager(void);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void)
|
||||
{
|
||||
return "ApplBufferManager";
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
private:
|
||||
// return the ID of the buffer allocated
|
||||
// create a buffer with no element
|
||||
int32_t Create(void);
|
||||
// open curent filename
|
||||
int32_t Open(etk::FSNode &myFile);
|
||||
bool Remove(int32_t BufferID);
|
||||
public:
|
||||
int32_t GetSelected(void) { return m_idSelected;};
|
||||
//void SetSelected(int32_t id) {m_idSelected = id;};
|
||||
Buffer * Get(int32_t BufferID);
|
||||
bool Exist(int32_t BufferID);
|
||||
bool Exist(etk::FSNode &myFile);
|
||||
int32_t GetId(etk::FSNode &myFile);
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t Size(void);
|
||||
uint32_t SizeOpen(void);
|
||||
int32_t WitchBuffer(int32_t iEmeElement);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
etk::Vector<Buffer*> listBuffer; //!< element List of the char Elements
|
||||
|
||||
void RemoveAll(void); //!< remove all buffer
|
||||
int32_t m_idSelected;
|
||||
Buffer * BufferNotExiste; //!< When an error arrive in get buffer we return the Error buffer (not writable)
|
||||
};
|
||||
|
||||
|
||||
// Constructeur
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
classBufferManager::classBufferManager(void)
|
||||
{
|
||||
// nothing to do ...
|
||||
BufferNotExiste = new BufferEmpty();
|
||||
m_idSelected = -1;
|
||||
RegisterMultiCast(ednMsgGuiNew);
|
||||
RegisterMultiCast(ednMsgOpenFile);
|
||||
RegisterMultiCast(ednMsgGuiClose);
|
||||
RegisterMultiCast(ednMsgGuiSave);
|
||||
RegisterMultiCast(ednMsgCodeViewSelectedId);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
classBufferManager::~classBufferManager(void)
|
||||
{
|
||||
//clean All Buffer
|
||||
APPL_INFO("~classBufferManager::RemoveAll();");
|
||||
RemoveAll();
|
||||
// clear The list of Buffer
|
||||
APPL_INFO("~classBufferManager::listBuffer.Clear();");
|
||||
listBuffer.Clear();
|
||||
APPL_INFO("~classBufferManager::delete(BufferNotExiste);");
|
||||
delete(BufferNotExiste);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void classBufferManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::EObject::OnReceiveMessage(CallerObject, eventId, data);
|
||||
|
||||
if (eventId == ednMsgBufferId) {
|
||||
// select a new buffer ID :
|
||||
if (data == "") {
|
||||
APPL_ERROR("Request select buffer ID = \"\" ");
|
||||
} else {
|
||||
int32_t newID = -1;
|
||||
sscanf(data.c_str(), "%d", &newID);
|
||||
if(true == Exist(newID)) {
|
||||
m_idSelected = newID;
|
||||
} else {
|
||||
m_idSelected = -1;
|
||||
APPL_ERROR("Request a non existant ID : " << newID << " reset to -1...");
|
||||
}
|
||||
}
|
||||
} else if (eventId == ednMsgGuiNew) {
|
||||
int32_t newOne = Create();
|
||||
if (-1 != newOne) {
|
||||
m_idSelected = newOne;
|
||||
SendMultiCast(ednMsgBufferId, m_idSelected);
|
||||
SendMultiCast(ednMsgBufferListChange);
|
||||
}
|
||||
} else if (eventId == ednMsgOpenFile) {
|
||||
if (data != "" ) {
|
||||
etk::FSNode myFile(data);
|
||||
APPL_DEBUG("request open file = \"" <<data << "\" ?= \"" << myFile << "\"");
|
||||
int32_t newOne = Open(myFile);
|
||||
if (-1 != newOne) {
|
||||
m_idSelected = newOne;
|
||||
SendMultiCast(ednMsgBufferId, m_idSelected);
|
||||
SendMultiCast(ednMsgBufferListChange);
|
||||
} else {
|
||||
// TODO : notify user that we can not open the request file...
|
||||
APPL_ERROR("Can not open the file : \"" << myFile << "\"");
|
||||
}
|
||||
}
|
||||
} else if (eventId == ednMsgGuiSave) {
|
||||
if (data == "") {
|
||||
APPL_ERROR("Null data for close file ... ");
|
||||
} else {
|
||||
if (data == "current") {
|
||||
// Check buffer existence
|
||||
if(true == Exist(m_idSelected)) {
|
||||
// If no name ==> request a Gui display ...
|
||||
if (Get(m_idSelected)->HaveName() == false) {
|
||||
SendMultiCast(ednMsgGuiSaveAs, "current");
|
||||
} else {
|
||||
Get(m_idSelected)->Save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int32_t newId;
|
||||
sscanf(data.c_str(), "%d", &newId);
|
||||
if (false == Exist(newId)) {
|
||||
APPL_ERROR("Request a save As with a non existant ID=" << newId);
|
||||
} else {
|
||||
// If no name ==> request a Gui display ...
|
||||
if (Get(newId)->HaveName() == false) {
|
||||
SendMultiCast(ednMsgGuiSaveAs, newId);
|
||||
} else {
|
||||
Get(m_idSelected)->Save();
|
||||
}
|
||||
}
|
||||
SendMultiCast(ednMsgBufferState, "saved");
|
||||
}
|
||||
}
|
||||
} else if (eventId == ednMsgGuiClose) {
|
||||
if (data == "") {
|
||||
APPL_ERROR("Null data for close file ... ");
|
||||
} else {
|
||||
if (data == "All") {
|
||||
|
||||
} else {
|
||||
int32_t closeID = -1;
|
||||
if (data == "current") {
|
||||
closeID = m_idSelected;
|
||||
APPL_DEBUG("Close specific buffer ID" << closeID);
|
||||
} else {
|
||||
// close specific buffer ...
|
||||
sscanf(data.c_str(), "%d", &closeID);
|
||||
APPL_DEBUG("Close specific buffer ID="<< closeID);
|
||||
}
|
||||
if(true == Exist(closeID)) {
|
||||
// Get the new display buffer
|
||||
if (m_idSelected == closeID) {
|
||||
// Try previous buffer
|
||||
int32_t destBuffer = -1;
|
||||
for(int32_t ii=closeID-1; ii >= 0; ii--) {
|
||||
if (true == Exist(ii) ) {
|
||||
destBuffer = ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// try next buffer
|
||||
if (-1 == destBuffer) {
|
||||
for(int32_t ii=closeID+1; ii < listBuffer.Size(); ii++) {
|
||||
if (true == Exist(ii) ) {
|
||||
destBuffer = ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// set it to the currect display
|
||||
m_idSelected = destBuffer;
|
||||
SendMultiCast(ednMsgBufferId, destBuffer);
|
||||
}
|
||||
// Remove requested buffer
|
||||
Remove(closeID);
|
||||
SendMultiCast(ednMsgBufferListChange);
|
||||
} else {
|
||||
APPL_ERROR("Request Close of a non existant ID : " << closeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (eventId == ednMsgCodeViewSelectedId) {
|
||||
//Change the selected buffer
|
||||
if (data == "") {
|
||||
APPL_ERROR("Null data for changing buffer ID file ... ");
|
||||
} else {
|
||||
int32_t newId;
|
||||
sscanf(data.c_str(), "%d", &newId);
|
||||
if (true == Exist(newId)) {
|
||||
m_idSelected = newId;
|
||||
} else {
|
||||
APPL_ERROR("code biew request the selection of an non -existant buffer ==> reset to -1");
|
||||
m_idSelected = -1;
|
||||
}
|
||||
SendMultiCast(ednMsgBufferId, m_idSelected);
|
||||
SendMultiCast(ednMsgBufferListChange);
|
||||
}
|
||||
}
|
||||
/*
|
||||
switch (id)
|
||||
{
|
||||
// Check buffer existence
|
||||
if(true == Exist(dataID)) {
|
||||
// If no name ==> request a Gui display ...
|
||||
if (Get(dataID)->HaveName() == false) {
|
||||
SendMessage(APPL_MSG__GUI_SHOW_SAVE_AS, dataID);
|
||||
} else {
|
||||
Get(dataID)->Save();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Remove all buffer opened
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void classBufferManager::RemoveAll(void)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listBuffer.Size(); i++) {
|
||||
Remove(i);
|
||||
}
|
||||
SendMultiCast(ednMsgGuiClose, "All");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a new buffer with no name and empty
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return The ID of the curent buffer where the file is loaded
|
||||
*
|
||||
*/
|
||||
int32_t classBufferManager::Create(void)
|
||||
{
|
||||
// allocate a new Buffer
|
||||
Buffer *myBuffer = new BufferText();
|
||||
// Add at the list of element
|
||||
listBuffer.PushBack(myBuffer);
|
||||
int32_t basicID = listBuffer.Size() - 1;
|
||||
return basicID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief open a file with the name set in parameters
|
||||
*
|
||||
* @param[in] filename curent filename
|
||||
*
|
||||
* @return The ID of the curent buffer where the file is loaded
|
||||
*
|
||||
* @todo : check if this file is not curently open and return the old ID
|
||||
*
|
||||
*/
|
||||
int32_t classBufferManager::Open(etk::FSNode &myFile)
|
||||
{
|
||||
if (false == Exist(myFile)) {
|
||||
// allocate a new Buffer
|
||||
Buffer *myBuffer = new BufferText(myFile);
|
||||
// Add at the list of element
|
||||
listBuffer.PushBack(myBuffer);
|
||||
return listBuffer.Size() - 1;
|
||||
} else {
|
||||
// the buffer already existed ==> we open it ...
|
||||
return GetId(myFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Buffer * classBufferManager::Get(int32_t BufferID)
|
||||
{
|
||||
// possible special case : -1;
|
||||
if (-1 >= BufferID) {
|
||||
return BufferNotExiste;
|
||||
}
|
||||
// check if the Buffer existed
|
||||
if (BufferID < listBuffer.Size()) {
|
||||
// check if the buffer already existed
|
||||
if (NULL != listBuffer[BufferID]) {
|
||||
return listBuffer[BufferID];
|
||||
} else {
|
||||
APPL_ERROR("non existing Buffer " << BufferID);
|
||||
}
|
||||
} else {
|
||||
APPL_ERROR("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
|
||||
}
|
||||
return BufferNotExiste;
|
||||
}
|
||||
|
||||
|
||||
bool classBufferManager::Exist(int32_t BufferID)
|
||||
{
|
||||
if (-1 >= BufferID) {
|
||||
return false;
|
||||
}
|
||||
// check if the Buffer existed
|
||||
if (BufferID < listBuffer.Size()) {
|
||||
// check if the buffer already existed
|
||||
if (NULL != listBuffer[BufferID]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool classBufferManager::Exist(etk::FSNode &myFile )
|
||||
{
|
||||
if (-1 == GetId(myFile)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int32_t classBufferManager::GetId(etk::FSNode &myFile)
|
||||
{
|
||||
int32_t iii;
|
||||
// check if the Buffer existed
|
||||
for (iii=0; iii < listBuffer.Size(); iii++) {
|
||||
// check if the buffer already existed
|
||||
if (NULL != listBuffer[iii]) {
|
||||
if ( listBuffer[iii]->GetFileName() == myFile) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t classBufferManager::Size(void)
|
||||
{
|
||||
return listBuffer.Size();
|
||||
}
|
||||
|
||||
// nb of opens file Now ...
|
||||
uint32_t classBufferManager::SizeOpen(void)
|
||||
{
|
||||
uint32_t jjj = 0;
|
||||
// check if the Buffer existed
|
||||
for (int32_t iii=0; iii<listBuffer.Size(); iii++) {
|
||||
// check if the buffer already existed
|
||||
if (NULL != listBuffer[iii]) {
|
||||
jjj++;
|
||||
}
|
||||
}
|
||||
return jjj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool classBufferManager::Remove(int32_t BufferID)
|
||||
{
|
||||
if (-1 >= BufferID) {
|
||||
return false;
|
||||
}
|
||||
// check if the Buffer existed
|
||||
if (BufferID < listBuffer.Size()) {
|
||||
// check if the buffer already existed
|
||||
if (NULL != listBuffer[BufferID]) {
|
||||
// TODO : Check if it saved...
|
||||
/*
|
||||
if (false == IsSaved(BufferID) ) {
|
||||
APPL_INFO("Buffer " << BufferID << " : Not Saved", BufferID);
|
||||
}
|
||||
*/
|
||||
// Delete the Buffer
|
||||
delete( listBuffer[BufferID] );
|
||||
listBuffer[BufferID] = NULL;
|
||||
/*
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
|
||||
*/
|
||||
return true;
|
||||
} else {
|
||||
APPL_INFO("non existing Buffer " << BufferID);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
APPL_INFO("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief to get the element 14 in the buffer
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
int32_t classBufferManager::WitchBuffer(int32_t iEmeElement)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listBuffer.Size(); i++) {
|
||||
if (NULL != listBuffer[i]) {
|
||||
iEmeElement--;
|
||||
// find the element :
|
||||
if (0 == iEmeElement) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Namespace part :
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static classBufferManager * localManager = NULL;
|
||||
|
||||
void BufferManager::Init(void)
|
||||
{
|
||||
if (NULL != localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> already exist, just unlink the previous ...");
|
||||
localManager = NULL;
|
||||
}
|
||||
localManager = new classBufferManager();
|
||||
|
||||
if (NULL == localManager) {
|
||||
EWOL_CRITICAL("Allocation of classBufferManager not done ...");
|
||||
}
|
||||
}
|
||||
|
||||
void BufferManager::UnInit(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return;
|
||||
}
|
||||
delete(localManager);
|
||||
localManager = NULL;
|
||||
}
|
||||
|
||||
int32_t BufferManager::GetSelected(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return -1;
|
||||
}
|
||||
return localManager->GetSelected();
|
||||
}
|
||||
|
||||
Buffer * BufferManager::Get(int32_t BufferID)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return NULL;
|
||||
}
|
||||
return localManager->Get(BufferID);
|
||||
}
|
||||
|
||||
bool BufferManager::Exist(int32_t BufferID)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return false;
|
||||
}
|
||||
return localManager->Exist(BufferID);
|
||||
}
|
||||
|
||||
bool BufferManager::Exist(etk::FSNode &myFile)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return false;
|
||||
}
|
||||
return localManager->Exist(myFile);
|
||||
}
|
||||
|
||||
int32_t BufferManager::GetId(etk::FSNode &myFile)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return -1;
|
||||
}
|
||||
return localManager->GetId(myFile);
|
||||
}
|
||||
|
||||
uint32_t BufferManager::Size(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return 0;
|
||||
}
|
||||
return localManager->Size();
|
||||
}
|
||||
|
||||
uint32_t BufferManager::SizeOpen(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return 0;
|
||||
}
|
||||
return localManager->SizeOpen();
|
||||
}
|
||||
|
||||
int32_t BufferManager::WitchBuffer(int32_t iEmeElement)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return -1;
|
||||
}
|
||||
return localManager->WitchBuffer(iEmeElement);
|
||||
}
|
||||
|
||||
|
51
sources/appl/Buffer/BufferManager.h
Normal file
51
sources/appl/Buffer/BufferManager.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferManager.h
|
||||
* @brief Editeur De N'ours : Text Buffer (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 08/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __BUFFER_MANAGER_H__
|
||||
#define __BUFFER_MANAGER_H__
|
||||
|
||||
#include <Buffer.h>
|
||||
#include <BufferText.h>
|
||||
#include <BufferEmpty.h>
|
||||
#include <appl/globalMsg.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
|
||||
namespace BufferManager
|
||||
{
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
int32_t GetSelected(void);
|
||||
Buffer * Get(int32_t BufferID);
|
||||
bool Exist(int32_t BufferID);
|
||||
bool Exist(etk::FSNode &myFile);
|
||||
int32_t GetId(etk::FSNode &myFile);
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t Size(void);
|
||||
uint32_t SizeOpen(void);
|
||||
int32_t WitchBuffer(int32_t iEmeElement);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
1308
sources/appl/Buffer/BufferText.cpp
Normal file
1308
sources/appl/Buffer/BufferText.cpp
Normal file
File diff suppressed because it is too large
Load Diff
130
sources/appl/Buffer/BufferText.h
Normal file
130
sources/appl/Buffer/BufferText.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferText.h
|
||||
* @brief Editeur De N'ours : Text Buffer (edit only ASCII text File) (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 19/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __BUFFER_TEXT_H__
|
||||
#define __BUFFER_TEXT_H__
|
||||
|
||||
#include "ColorizeManager.h"
|
||||
#include "Buffer.h"
|
||||
#include "EdnBuf.h"
|
||||
|
||||
typedef enum {
|
||||
CURSOR_DISPLAY_MODE_NORMAL = 259,
|
||||
CURSOR_DISPLAY_MODE_INSERT,
|
||||
CURSOR_DISPLAY_MODE_NOT_FOCUS,
|
||||
} cursorDisplayMode_te;
|
||||
|
||||
class CharElement
|
||||
{
|
||||
public:
|
||||
int16_t m_yOffset;
|
||||
int16_t m_xOffset;
|
||||
int16_t m_ySize;
|
||||
int32_t m_bufferPos;
|
||||
};
|
||||
|
||||
class BufferText : public Buffer {
|
||||
public:
|
||||
BufferText(void);
|
||||
BufferText(etk::FSNode &fileName);
|
||||
virtual ~BufferText(void);
|
||||
void Save(void);
|
||||
|
||||
void GetInfo(infoStatBuffer_ts &infoToUpdate);
|
||||
void SetLineDisplay(uint32_t lineNumber);
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText,
|
||||
ewol::OObject2DColored& OOColored,
|
||||
int32_t offsetX, int32_t offsetY,
|
||||
int32_t sizeX, int32_t sizeY);
|
||||
#else
|
||||
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextBold,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextItalic,
|
||||
ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic,
|
||||
ewol::OObject2DColored& OOColored,
|
||||
int32_t offsetX, int32_t offsetY,
|
||||
int32_t sizeX, int32_t sizeY);
|
||||
#endif
|
||||
void AddChar(uniChar_t unicodeData);
|
||||
void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
|
||||
void MouseSelectFromCursorTo(etk::Vector2D<float> pos);
|
||||
void MouseEvent(etk::Vector2D<float> pos);
|
||||
void MouseEventDouble(void);
|
||||
void MouseEventTriple(void);
|
||||
|
||||
void Copy(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
void Cut(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
void Paste(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
|
||||
void Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp);
|
||||
void Replace(etk::UString &data);
|
||||
int32_t FindLine(etk::UString &data);
|
||||
void JumpAtLine(int32_t newLine);
|
||||
int32_t GetCurrentLine(void);
|
||||
|
||||
void RemoveLine(void);
|
||||
void SelectAll(void);
|
||||
void SelectNone(void);
|
||||
void Undo(void);
|
||||
void Redo(void);
|
||||
void SetCharset(unicode::charset_te newCharset);
|
||||
int32_t GetNumberOfLine(void);
|
||||
protected:
|
||||
void NameChange(void);
|
||||
|
||||
private:
|
||||
int32_t GetLineNumberNumberOfElement(void);
|
||||
|
||||
// Direct buffer IO
|
||||
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
|
||||
etk::Vector2D<float> m_displaySize; //!< number of char displayable in the screan
|
||||
// Cursor :
|
||||
int32_t m_cursorPos; //!< position in the buffer of the cursor
|
||||
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
|
||||
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
|
||||
etk::Vector<CharElement> m_elmentList; //!< Elemnt position for every char displayed
|
||||
|
||||
// internal function
|
||||
void BasicInit(void);
|
||||
private:
|
||||
bool m_centerRequested;
|
||||
public:
|
||||
virtual etk::Vector2D<float> GetPosition(int32_t fontId, bool& centerRequested);
|
||||
private:
|
||||
bool TextDMoveUp(int32_t offset);
|
||||
bool TextDMoveDown(int32_t offset);
|
||||
void SetInsertPosition(int32_t newPosition, bool insertChar = false);
|
||||
|
||||
int32_t GetMousePosition(etk::Vector2D<float> pos);
|
||||
|
||||
void DrawLineNumber(ewol::TEXT_DISPLAY_TYPE* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);
|
||||
void DrawCursor(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth, clipping_ts &clip);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
1320
sources/appl/Buffer/EdnBuf/EdnBuf.cpp
Normal file
1320
sources/appl/Buffer/EdnBuf/EdnBuf.cpp
Normal file
File diff suppressed because it is too large
Load Diff
209
sources/appl/Buffer/EdnBuf/EdnBuf.h
Normal file
209
sources/appl/Buffer/EdnBuf/EdnBuf.h
Normal file
@@ -0,0 +1,209 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file EdnBuf.h
|
||||
* @brief Editeur De N'ours : Buffer for internal Data (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 23/03/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef __EDN_BUF_H__
|
||||
#define __EDN_BUF_H__
|
||||
|
||||
/* Maximum length in characters of a tab or control character expansion
|
||||
of a single buffer character */
|
||||
#define MAX_EXP_CHAR_LEN 20*4
|
||||
|
||||
class EdnBuf;
|
||||
|
||||
#include <EdnVectorBuf.h>
|
||||
#include <EdnBufHistory.h>
|
||||
#include <HighlightManager.h>
|
||||
#include <etk/unicode.h>
|
||||
|
||||
/*
|
||||
|
||||
rectStart rectStart
|
||||
start ************* *************
|
||||
********** * xxxx*xxxxxx *
|
||||
* ******** xxxx*xxxxxxxxxxx*xxxxx
|
||||
end *************** *************
|
||||
rectEnd rectEnd
|
||||
|
||||
|
||||
|
||||
*/
|
||||
typedef struct {
|
||||
bool selected; //!< True if the selection is active
|
||||
bool rectangular; //!< True if the selection is rectangular
|
||||
bool zeroWidth; //!< Width 0 selections aren't "real" selections, but they can be useful when creating rectangular selections from the keyboard.
|
||||
int32_t start; //!< Pos. of start of selection, or if rectangular start of line containing it.
|
||||
int32_t end; //!< Pos. of end of selection, or if rectangular end of line containing it.
|
||||
int32_t rectStart; //!< Indent of left edge of rect. selection
|
||||
int32_t rectEnd; //!< Indent of right edge of rect. selection
|
||||
} selection;
|
||||
|
||||
typedef struct {
|
||||
etk::Vector<colorInformation_ts> HLData;
|
||||
int32_t posHLPass1;
|
||||
int32_t posHLPass2;
|
||||
}displayHLData_ts;
|
||||
|
||||
|
||||
|
||||
class EdnBuf {
|
||||
// TODO : Set an iterator to acces at every data without knowin the system ...
|
||||
public:
|
||||
// constructer
|
||||
EdnBuf(void);
|
||||
// destructer
|
||||
~EdnBuf(void);
|
||||
// public function :
|
||||
void GetAll( etk::Vector<int8_t> &text);
|
||||
void SetAll( etk::Vector<int8_t> &text);
|
||||
void GetRange( int32_t start, int32_t end, etk::Vector<int8_t> &output);
|
||||
void GetRange( int32_t start, int32_t end, etk::UString &output);
|
||||
bool DumpIn( etk::FSNode &file);
|
||||
bool DumpFrom( etk::FSNode &file);
|
||||
// replace with operator [] ...
|
||||
int8_t operator[] (int32_t);
|
||||
int32_t Insert( int32_t pos, etk::Vector<int8_t> &insertText);
|
||||
int32_t Insert( int32_t pos, etk::UString &insertText);
|
||||
int32_t Replace( int32_t start, int32_t end, etk::Vector<int8_t> &insertText);
|
||||
int32_t Replace( int32_t start, int32_t end, etk::UString &insertText);
|
||||
void Remove( int32_t start, int32_t end);
|
||||
int32_t Indent( void);
|
||||
int32_t UnIndent( void);
|
||||
|
||||
|
||||
void GetLineText( int32_t pos, etk::Vector<int8_t> &text);
|
||||
int32_t StartOfLine( int32_t pos);
|
||||
int32_t EndOfLine( int32_t pos);
|
||||
|
||||
int32_t GetExpandedChar( int32_t &pos, int32_t indent, uniChar_t outUnicode[MAX_EXP_CHAR_LEN], uint32_t ¤tChar);
|
||||
int32_t GetExpandedChar( int32_t &pos, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN], uint32_t ¤tChar);
|
||||
int32_t ExpandCharacter( char c, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN]); // TODO : Remove
|
||||
int32_t CharWidth( char c, int32_t indent); // TODO : rework this
|
||||
int32_t CountDispChars( int32_t lineStartPos, int32_t targetPos);
|
||||
int32_t CountForwardDispChars( int32_t lineStartPos, int32_t nChars);
|
||||
int32_t CountLines( int32_t startPos, int32_t endPos);
|
||||
int32_t CountLines( void);
|
||||
int32_t CountLines( etk::Vector<int8_t> &data);
|
||||
int32_t CountForwardNLines( int32_t startPos, int32_t nLines);
|
||||
int32_t CountBackwardNLines( int32_t startPos, int32_t nLines);
|
||||
|
||||
bool SearchForward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
|
||||
bool SearchBackward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
|
||||
bool SearchForward( int32_t startPos, char searchChar, int32_t *foundPos);
|
||||
bool SearchBackward( int32_t startPos, char searchChar, int32_t *foundPos);
|
||||
bool SelectAround( int32_t startPos, int32_t &beginPos, int32_t &endPos);
|
||||
|
||||
// Buffer Size system :
|
||||
int32_t Size(void) { return m_data.Size(); };
|
||||
int32_t NumberOfLines(void) { return m_nbLine; };
|
||||
|
||||
// -----------------------------------------
|
||||
// selection remember...
|
||||
// -----------------------------------------
|
||||
public:
|
||||
bool SelectHasSelection(void);
|
||||
void Select( int32_t start, int32_t end);
|
||||
void Unselect( void);
|
||||
void RectSelect( int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd);
|
||||
bool GetSelectionPos( int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd);
|
||||
void GetSelectionText( etk::Vector<int8_t> &text);
|
||||
void GetSelectionText( etk::UString &text);
|
||||
void RemoveSelected( void);
|
||||
int32_t ReplaceSelected( etk::Vector<int8_t> &text);
|
||||
int32_t ReplaceSelected( etk::UString &text);
|
||||
private:
|
||||
// current selection of the buffer
|
||||
selection m_selectionList; //!< Selection area of the buffer
|
||||
void UpdateSelection( int32_t pos, int32_t nDeleted, int32_t nInserted);
|
||||
|
||||
// -----------------------------------------
|
||||
// History section :
|
||||
// -----------------------------------------
|
||||
public:
|
||||
int32_t Undo(void);
|
||||
int32_t Redo(void);
|
||||
private:
|
||||
bool m_isUndoProcessing;
|
||||
bool m_isRedoProcessing;
|
||||
etk::Vector<EdnBufHistory*> m_historyUndo;
|
||||
etk::Vector<EdnBufHistory*> m_historyRedo;
|
||||
|
||||
// -----------------------------------------
|
||||
// hightlight section :
|
||||
// -----------------------------------------
|
||||
private:
|
||||
Highlight * m_Highlight; //!< internal link with the Highlight system
|
||||
etk::Vector<colorInformation_ts> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
|
||||
void RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded);
|
||||
void GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos=0);
|
||||
void CleanHighLight(void);
|
||||
void FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded);
|
||||
public:
|
||||
void SetHLSystem( Highlight * newHLSystem);
|
||||
void HightlightGenerateLines(displayHLData_ts & MData, int32_t startPos, int32_t nbLines);
|
||||
colorInformation_ts * GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos);
|
||||
private:
|
||||
colorInformation_ts * GetElementColorAtPosition(int32_t pos, int32_t &starPos);
|
||||
|
||||
private:
|
||||
EdnVectorBuf m_data; //!< buffer of the data in the mode int8_t
|
||||
void CountNumberOfLines(void);
|
||||
int32_t m_nbLine; //!< Number of line in the biffer
|
||||
|
||||
// -----------------------------------------
|
||||
// Display property and charset ...
|
||||
// -----------------------------------------
|
||||
public:
|
||||
int32_t GetTabDistance(void) { return m_tabDist; } ;
|
||||
void SetTabDistance(int32_t tabDist) { m_tabDist = tabDist; };
|
||||
unicode::charset_te GetCharsetType(void) { return m_charsetType; };
|
||||
void SetCharsetType(unicode::charset_te newOne) { m_charsetType = newOne; if (unicode::EDN_CHARSET_UTF8==newOne){m_isUtf8=true;} else {m_isUtf8=false;} };
|
||||
bool GetUTF8Mode(void) { return m_isUtf8; };
|
||||
void SetUTF8Mode(bool newOne) { m_isUtf8 = newOne; m_charsetType=unicode::EDN_CHARSET_UTF8; };
|
||||
private:
|
||||
// Special mode of the buffer :
|
||||
bool m_isUtf8; //!< true if we are in UTF8 mode ==> if true the size of a char is 0, otherwise .. 1->4 ( TODO : not now)
|
||||
unicode::charset_te m_charsetType; //!< if UTF8 mode is at false : the charset type of the buffer
|
||||
// Local Tabulation policies
|
||||
int32_t m_tabDist; //!< equiv. number of characters in a tab
|
||||
bool m_useTabs; //!< True if buffer routines are allowed to use tabs for padding in rectangular operations
|
||||
|
||||
// -----------------------------------------
|
||||
// Local function :
|
||||
// -----------------------------------------
|
||||
private:
|
||||
void findRectSelBoundariesForCopy( int32_t lineStartPos, int32_t rectStart, int32_t rectEnd, int32_t *selStart, int32_t *selEnd);
|
||||
char * getSelectionText( selection &sel);
|
||||
void removeSelected( selection &sel);
|
||||
void replaceSelected( selection &sel, const char *text);
|
||||
|
||||
void eventModification( int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText);
|
||||
|
||||
|
||||
int32_t LocalInsert( int32_t pos, etk::Vector<int8_t> &insertText);
|
||||
int32_t LocalInsert( int32_t pos, etk::UString &insertText);
|
||||
|
||||
bool charMatch( char first, char second, bool caseSensitive = true);
|
||||
};
|
||||
|
||||
#endif
|
82
sources/appl/Buffer/EdnBuf/EdnBufHistory.cpp
Normal file
82
sources/appl/Buffer/EdnBuf/EdnBufHistory.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file EdnBufHistory.cpp
|
||||
* @brief Editeur De N'ours : history of buffer modification (sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 24/03/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <EdnBufHistory.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EdnBufHistory"
|
||||
|
||||
EdnBufHistory::EdnBufHistory(void)
|
||||
{
|
||||
//APPL_INFO("EdnBufHistory new");
|
||||
m_pos = 0;
|
||||
m_nInserted = 0;
|
||||
}
|
||||
|
||||
EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText)
|
||||
{
|
||||
//APPL_INFO("EdnBufHistory new + data");
|
||||
m_pos = pos;
|
||||
m_nInserted = nInserted;
|
||||
m_deletedText = deletedText;
|
||||
}
|
||||
|
||||
void EdnBufHistory::Set(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText)
|
||||
{
|
||||
//APPL_INFO("EdnBufHistory new + data");
|
||||
m_pos = pos;
|
||||
m_nInserted = nInserted;
|
||||
m_deletedText = deletedText;
|
||||
}
|
||||
|
||||
EdnBufHistory::~EdnBufHistory(void)
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
int32_t EdnBufHistory::getPos(void)
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
int32_t EdnBufHistory::getnbDeleted(void)
|
||||
{
|
||||
return m_deletedText.Size();
|
||||
}
|
||||
|
||||
int32_t EdnBufHistory::getnbInserted(void)
|
||||
{
|
||||
return m_nInserted;
|
||||
}
|
||||
|
||||
void EdnBufHistory::getData(etk::Vector<int8_t> &deletedText)
|
||||
{
|
||||
deletedText = m_deletedText;
|
||||
}
|
||||
|
49
sources/appl/Buffer/EdnBuf/EdnBufHistory.h
Normal file
49
sources/appl/Buffer/EdnBuf/EdnBufHistory.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file EdnBufHistory.h
|
||||
* @brief Editeur De N'ours : history of buffer modification (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 24/03/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EDN_BUFFER_HISTORY_H__
|
||||
#define __EDN_BUFFER_HISTORY_H__
|
||||
|
||||
|
||||
#include <etk/Vector.h>
|
||||
|
||||
class EdnBufHistory{
|
||||
public:
|
||||
EdnBufHistory(void);
|
||||
EdnBufHistory(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText);
|
||||
~EdnBufHistory(void);
|
||||
void Set(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText);
|
||||
int32_t getPos(void);
|
||||
int32_t getnbDeleted(void);
|
||||
int32_t getnbInserted(void);
|
||||
void getData(etk::Vector<int8_t> &deletedText);
|
||||
private:
|
||||
int32_t m_pos;
|
||||
int32_t m_nInserted;
|
||||
etk::Vector<int8_t> m_deletedText;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
370
sources/appl/Buffer/EdnBuf/EdnBuf_HighLight.cpp
Normal file
370
sources/appl/Buffer/EdnBuf/EdnBuf_HighLight.cpp
Normal file
@@ -0,0 +1,370 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file EdnBuf_HighLight.cpp
|
||||
* @brief Editeur De N'ours : Buffer for internal Data - section highlight (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 23/03/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <EdnBuf.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EdnBuf{HighLight}"
|
||||
|
||||
void EdnBuf::SetHLSystem(Highlight * newHLSystem)
|
||||
{
|
||||
if (m_Highlight != newHLSystem) {
|
||||
m_Highlight = newHLSystem;
|
||||
m_HLDataPass1.Clear();
|
||||
RegenerateHighLightAt(0, 0, m_data.Size());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO : Check this fuction it have too many conditionnal inside ==> can do a better algo
|
||||
void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded)
|
||||
{
|
||||
//GTimeVal timeStart;
|
||||
//g_get_current_time(&timeStart);
|
||||
|
||||
// prevent ERROR...
|
||||
if (NULL == m_Highlight) {
|
||||
return;
|
||||
}
|
||||
// prevent No data Call
|
||||
if( 0 == nbDeleted
|
||||
&& 0 == nbAdded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// normal case
|
||||
//APPL_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");");
|
||||
int32_t i;
|
||||
/*
|
||||
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
|
||||
etk::UString ploppp;
|
||||
if (NULL != m_HLDataPass1[i].patern ) {
|
||||
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
|
||||
}
|
||||
APPL_DEBUG("HighLight (previous) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
|
||||
}
|
||||
*/
|
||||
int32_t posEnd = pos + nbDeleted;
|
||||
// search position of the old element to reparse IT...
|
||||
int32_t startId;
|
||||
int32_t stopId;
|
||||
// clean data if needed
|
||||
if (0 != m_HLDataPass1.Size()) {
|
||||
// find element previous
|
||||
FindMainHighLightPosition(pos, posEnd, startId, stopId, true);
|
||||
|
||||
// Remove deprecated element
|
||||
if( -1 == startId
|
||||
&& -1 == stopId)
|
||||
{
|
||||
m_HLDataPass1.Clear();
|
||||
} else if(-1 == startId) {
|
||||
if (0 == stopId){
|
||||
m_HLDataPass1.Erase(0);
|
||||
//APPL_DEBUG("1 * Erase 0");
|
||||
} else {
|
||||
m_HLDataPass1.EraseLen(0,stopId);
|
||||
//APPL_DEBUG("2 * Erase 0->" << stopId);
|
||||
}
|
||||
} else if(-1 == stopId) {
|
||||
//APPL_DEBUG("3 * Erase " << startId+1 << "-> end");
|
||||
m_HLDataPass1.EraseLen(startId+1, m_HLDataPass1.Size() - startId);
|
||||
stopId = -1;
|
||||
} else {
|
||||
int32_t currentSize = m_HLDataPass1.Size();
|
||||
//APPL_DEBUG("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" );
|
||||
m_HLDataPass1.EraseLen(startId+1, stopId - startId);
|
||||
if (stopId == currentSize-1) {
|
||||
stopId = -1;
|
||||
}
|
||||
}
|
||||
//APPL_DEBUG("new size=" << (int32_t)m_HLDataPass1.Size()-1);
|
||||
/*
|
||||
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
|
||||
etk::UString ploppp;
|
||||
if (NULL != m_HLDataPass1[i].patern ) {
|
||||
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
|
||||
}
|
||||
APPL_DEBUG("HighLight (Middle) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
|
||||
}
|
||||
*/
|
||||
// update position after the range position :
|
||||
int32_t elemStart;
|
||||
if(-1 == startId) {
|
||||
elemStart = 0;
|
||||
} else {
|
||||
elemStart = startId+1;
|
||||
}
|
||||
for (i=elemStart; i< (int32_t)m_HLDataPass1.Size(); i++) {
|
||||
//APPL_DEBUG("move element=" << i);
|
||||
m_HLDataPass1[i].beginStart += nbAdded - nbDeleted;
|
||||
m_HLDataPass1[i].beginStop += nbAdded - nbDeleted;
|
||||
m_HLDataPass1[i].endStart += nbAdded - nbDeleted;
|
||||
m_HLDataPass1[i].endStop += nbAdded - nbDeleted;
|
||||
}
|
||||
//Regenerate Element inside range
|
||||
if( -1 == startId
|
||||
&& -1 == stopId)
|
||||
{
|
||||
//APPL_DEBUG("******* Regenerate ALL");
|
||||
GenerateHighLightAt(0, m_data.Size());
|
||||
} else if(-1 == startId) {
|
||||
//APPL_DEBUG("******* Regenerate START");
|
||||
GenerateHighLightAt(0, m_HLDataPass1[0].beginStart, 0);
|
||||
} else if(-1 == stopId) {
|
||||
//APPL_DEBUG("******* Regenerate STOP");
|
||||
GenerateHighLightAt(m_HLDataPass1[m_HLDataPass1.Size() -1].endStop, m_data.Size(), m_HLDataPass1.Size());
|
||||
} else {
|
||||
//APPL_DEBUG("******* Regenerate RANGE");
|
||||
GenerateHighLightAt(m_HLDataPass1[startId].endStop, m_HLDataPass1[startId+1].beginStart, startId+1);
|
||||
}
|
||||
} else {
|
||||
// Parse the new element ...
|
||||
GenerateHighLightAt(0, m_data.Size());
|
||||
}
|
||||
/*
|
||||
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
|
||||
etk::UString ploppp;
|
||||
if (NULL != m_HLDataPass1[i].patern ) {
|
||||
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
|
||||
}
|
||||
APPL_DEBUG("HighLight (end) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
|
||||
}
|
||||
*/
|
||||
//GTimeVal timeStop;
|
||||
//g_get_current_time(&timeStop);
|
||||
//APPL_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
|
||||
}
|
||||
|
||||
void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded)
|
||||
{
|
||||
startId = -1;
|
||||
stopId = -1;
|
||||
/* rules to start stop:
|
||||
HighLight data ----
|
||||
Remove area ****
|
||||
Start pos S
|
||||
End pos E
|
||||
|
||||
Some Case :
|
||||
----------- ------------ ------------- ----------
|
||||
S **** E
|
||||
|
||||
----------- ------------ ------------- ----------
|
||||
S ********** E
|
||||
|
||||
----------- ------------ ------------- ----------
|
||||
S **** E
|
||||
|
||||
----------- ------------ ------------- ----------
|
||||
S ********* E
|
||||
|
||||
----------- ------------ ------------- ----------
|
||||
S ********************* E
|
||||
|
||||
----------- ------------ ------------- ----------
|
||||
S ************************ E
|
||||
|
||||
----------- ------------ ------------- ----------
|
||||
S ***************** E
|
||||
|
||||
----------- ------------ ------------- ----------
|
||||
S *************** E
|
||||
|
||||
----------- ------------
|
||||
S *************** E=-1
|
||||
|
||||
------------ ------------- ----------
|
||||
S=-1 *************** E
|
||||
*/
|
||||
int32_t i;
|
||||
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
|
||||
if (m_HLDataPass1[i].endStop > startPos) {
|
||||
break;
|
||||
}
|
||||
startId = i;
|
||||
}
|
||||
// go back while the previous element is not eneded
|
||||
if (true == backPreviousNotEnded) {
|
||||
for (i=startId; i>=0; i--) {
|
||||
if (m_HLDataPass1[i].notEnded == false) {
|
||||
break;
|
||||
}
|
||||
startId = i-1;
|
||||
}
|
||||
}
|
||||
int32_t elemStart;
|
||||
if(-1 == startId) {
|
||||
elemStart = 0;
|
||||
} else {
|
||||
elemStart = startId+1;
|
||||
}
|
||||
for (i=elemStart; i< (int32_t)m_HLDataPass1.Size(); i++) {
|
||||
if (m_HLDataPass1[i].beginStart > endPos)
|
||||
{
|
||||
stopId = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (-1 != startId && startId < (int32_t)m_HLDataPass1.Size()) {
|
||||
APPL_DEBUG("==> BEGIN : start="<<m_HLDataPass1[startId].beginStart<<", stop="<<m_HLDataPass1[startId].endStop<<" id=" << startId << "/" << (int32_t)m_HLDataPass1.Size()-1);
|
||||
} else {
|
||||
APPL_DEBUG("==> BEGIN : start=???, stop=??? id=" << startId);
|
||||
}
|
||||
if (-1 != stopId && stopId < (int32_t)m_HLDataPass1.Size()) {
|
||||
APPL_DEBUG("==> END : start="<<m_HLDataPass1[stopId].beginStart<<", stop="<<m_HLDataPass1[stopId].endStop<<" id=" << stopId<< "/" << (int32_t)m_HLDataPass1.Size()-1);
|
||||
} else {
|
||||
APPL_DEBUG("==> END : start=???, stop=??? id=" << stopId);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EdnBuf::GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos)
|
||||
{
|
||||
if (NULL == m_Highlight) {
|
||||
return;
|
||||
}
|
||||
//APPL_DEBUG("area : ("<<pos<<","<<endPos<<") insert at : " << addinPos);
|
||||
m_Highlight->Parse(pos, endPos, m_HLDataPass1, addinPos, m_data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EdnBuf::CleanHighLight(void)
|
||||
{
|
||||
// Remove all element in the list...
|
||||
m_HLDataPass1.Clear();
|
||||
}
|
||||
|
||||
|
||||
colorInformation_ts *EdnBuf::GetElementColorAtPosition(int32_t pos, int32_t &starPos)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t start = etk_max(0, starPos-1);
|
||||
for (i=start; i<(int32_t)m_HLDataPass1.Size(); i++) {
|
||||
starPos = i;
|
||||
if( m_HLDataPass1[i].beginStart <= pos
|
||||
&& m_HLDataPass1[i].endStop > pos)
|
||||
{
|
||||
return &m_HLDataPass1[i];
|
||||
}
|
||||
if(m_HLDataPass1[i].beginStart > pos) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, int32_t nbLines)
|
||||
{
|
||||
MData.posHLPass1 = 0;
|
||||
MData.posHLPass2 = 0;
|
||||
if (NULL == m_Highlight) {
|
||||
return;
|
||||
}
|
||||
//GTimeVal timeStart;
|
||||
//g_get_current_time(&timeStart);
|
||||
HLStart = StartOfLine(HLStart);
|
||||
MData.HLData.Clear();
|
||||
int32_t HLStop = CountForwardNLines(HLStart, nbLines);
|
||||
int32_t startId, stopId;
|
||||
// find element previous
|
||||
FindMainHighLightPosition(HLStart, HLStop, startId, stopId, true);
|
||||
|
||||
int32_t k;
|
||||
//APPL_DEBUG("List of section between : "<< startId << " & " << stopId);
|
||||
int32_t endSearch = stopId+1;
|
||||
if (-1 == stopId) {
|
||||
endSearch = m_HLDataPass1.Size();
|
||||
}
|
||||
for (k=etk_max(startId, 0); k<endSearch; k++) {
|
||||
// empty section :
|
||||
if (0==k) {
|
||||
if (HLStart < m_HLDataPass1[k].beginStart) {
|
||||
//APPL_DEBUG(" ==> (empty section 1 ) k="<<k<<" start="<<HLStart<<" stop="<<m_HLDataPass1[k].beginStart );
|
||||
m_Highlight->Parse2(HLStart,
|
||||
m_HLDataPass1[k].beginStart,
|
||||
MData.HLData,
|
||||
m_data);
|
||||
} // else : nothing to do ...
|
||||
} else {
|
||||
//APPL_DEBUG(" ==> (empty section 2 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<m_HLDataPass1[k].beginStart );
|
||||
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
|
||||
m_HLDataPass1[k].beginStart,
|
||||
MData.HLData,
|
||||
m_data);
|
||||
}
|
||||
// under section :
|
||||
//APPL_DEBUG(" ==> (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999);
|
||||
// TODO : ...
|
||||
}
|
||||
if (endSearch == (int32_t)m_HLDataPass1.Size() ){
|
||||
//if( k < (int32_t)m_HLDataPass1.Size()) {
|
||||
if (m_HLDataPass1.Size() != 0) {
|
||||
//APPL_DEBUG(" ==> (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop );
|
||||
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
|
||||
HLStop,
|
||||
MData.HLData,
|
||||
m_data);
|
||||
} else {
|
||||
//APPL_DEBUG(" ==> (empty section 4 ) k="<<k<<" start=0 stop="<<HLStop );
|
||||
m_Highlight->Parse2(0,
|
||||
HLStop,
|
||||
MData.HLData,
|
||||
m_data);
|
||||
}
|
||||
}
|
||||
|
||||
//GTimeVal timeStop;
|
||||
//g_get_current_time(&timeStop);
|
||||
//APPL_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
|
||||
|
||||
}
|
||||
|
||||
|
||||
colorInformation_ts * EdnBuf::GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t start = etk_max(0, MData.posHLPass2-1);
|
||||
for (i=start; i<(int32_t)MData.HLData.Size(); i++) {
|
||||
MData.posHLPass2 = i;
|
||||
if( MData.HLData[i].beginStart <= pos
|
||||
&& MData.HLData[i].endStop > pos)
|
||||
{
|
||||
return &MData.HLData[i];
|
||||
}
|
||||
if(MData.HLData[i].beginStart > pos) {
|
||||
return GetElementColorAtPosition(pos, MData.posHLPass1);
|
||||
}
|
||||
}
|
||||
return GetElementColorAtPosition(pos, MData.posHLPass1);
|
||||
}
|
133
sources/appl/Buffer/EdnBuf/EdnBuf_History.cpp
Normal file
133
sources/appl/Buffer/EdnBuf/EdnBuf_History.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file EdnBuf_History.cpp
|
||||
* @brief Editeur De N'ours : Buffer for internal Data - section history (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 23/03/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <EdnBuf.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EdnBuf{History}"
|
||||
|
||||
|
||||
|
||||
|
||||
int32_t EdnBuf::Undo(void)
|
||||
{
|
||||
int32_t nbElement = m_historyUndo.Size();
|
||||
//APPL_DEBUG("EdnBuf::Undo Request id="<<nbElement);
|
||||
int32_t posDest = -1;
|
||||
if (0 == nbElement) {
|
||||
// nothing to do ...
|
||||
APPL_ERROR("EdnBuf::Undo No more History");
|
||||
return -1;
|
||||
}
|
||||
nbElement--;
|
||||
if (m_historyUndo[nbElement] == NULL) {
|
||||
APPL_ERROR("EdnBuf::Undo Find empty history ==> remove it");
|
||||
m_historyUndo.PopBack();
|
||||
return -1;
|
||||
}
|
||||
int32_t pos = m_historyUndo[nbElement]->getPos();
|
||||
int32_t nbDeleted = m_historyUndo[nbElement]->getnbDeleted();
|
||||
int32_t nbInserted = m_historyUndo[nbElement]->getnbInserted();
|
||||
etk::Vector<int8_t> deletedText;
|
||||
m_historyUndo[nbElement]->getData(deletedText);
|
||||
m_isUndoProcessing = true;
|
||||
if (0 == nbInserted) {
|
||||
// just add data at position ...
|
||||
if (0 == nbDeleted) {
|
||||
APPL_DEBUG("EdnBuf::Undo nothing to do in UNDO");
|
||||
} else {
|
||||
Insert(pos, deletedText);
|
||||
posDest = pos + nbDeleted;
|
||||
}
|
||||
} else {
|
||||
if (0 == nbDeleted) {
|
||||
// only remove data
|
||||
Remove(pos, pos+nbInserted);
|
||||
posDest = pos;
|
||||
} else {
|
||||
// replace data
|
||||
Replace(pos, pos+nbInserted, deletedText);
|
||||
posDest = pos + nbDeleted;
|
||||
}
|
||||
}
|
||||
// remove element in the list :
|
||||
delete(m_historyUndo[nbElement]);
|
||||
m_historyUndo.PopBack();
|
||||
m_isUndoProcessing = false;
|
||||
return posDest;
|
||||
}
|
||||
|
||||
int32_t EdnBuf::Redo(void)
|
||||
{
|
||||
int32_t nbElement = m_historyRedo.Size();
|
||||
//APPL_DEBUG("EdnBuf::Redo Request id="<<nbElement);
|
||||
int32_t posDest = -1;
|
||||
if (0 == nbElement) {
|
||||
// nothing to do ...
|
||||
APPL_DEBUG("EdnBuf::Redo No more History");
|
||||
return -1;
|
||||
}
|
||||
nbElement--;
|
||||
if (m_historyRedo[nbElement] == NULL) {
|
||||
APPL_ERROR("EdnBuf::Redo Find empty history ==> remove it");
|
||||
m_historyRedo.PopBack();
|
||||
return -1;
|
||||
}
|
||||
int32_t pos = m_historyRedo[nbElement]->getPos();
|
||||
int32_t nbDeleted = m_historyRedo[nbElement]->getnbDeleted();
|
||||
int32_t nbInserted = m_historyRedo[nbElement]->getnbInserted();
|
||||
etk::Vector<int8_t> deletedText;
|
||||
m_historyRedo[nbElement]->getData(deletedText);
|
||||
m_isRedoProcessing = true;
|
||||
if (0 == nbInserted) {
|
||||
// just add data at position ...
|
||||
if (0 == nbDeleted) {
|
||||
APPL_ERROR("EdnBuf::Redo nothing to do in REDO");
|
||||
} else {
|
||||
Insert(pos, deletedText);
|
||||
posDest = pos + nbDeleted;
|
||||
}
|
||||
} else {
|
||||
if (0 == nbDeleted) {
|
||||
// only remove data
|
||||
Remove(pos, pos+nbInserted);
|
||||
posDest = pos;
|
||||
} else {
|
||||
// replace data
|
||||
Replace(pos, pos+nbInserted, deletedText);
|
||||
posDest = pos + nbDeleted;
|
||||
}
|
||||
}
|
||||
// remove element in the list :
|
||||
delete(m_historyRedo[nbElement]);
|
||||
m_historyRedo.PopBack();
|
||||
m_isRedoProcessing = false;
|
||||
return posDest;
|
||||
}
|
||||
|
||||
|
310
sources/appl/Buffer/EdnBuf/EdnBuf_Selection.cpp
Normal file
310
sources/appl/Buffer/EdnBuf/EdnBuf_Selection.cpp
Normal file
@@ -0,0 +1,310 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file EdnBuf_Selection.cpp
|
||||
* @brief Editeur De N'ours : Buffer for internal Data - section selection (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 23/03/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <EdnBuf.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EdnBuf{Selection}"
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool EdnBuf::SelectHasSelection(void)
|
||||
{
|
||||
return m_selectionList.selected;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnBuf::Select(int32_t start, int32_t end)
|
||||
{
|
||||
//selection oldSelection = m_selectionList[select];
|
||||
m_selectionList.selected = start != end;
|
||||
m_selectionList.zeroWidth = (start == end) ? true : false;
|
||||
m_selectionList.rectangular = false;
|
||||
m_selectionList.start = etk_min(start, end);
|
||||
m_selectionList.end = etk_max(start, end);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnBuf::Unselect(void)
|
||||
{
|
||||
//selection oldSelection = m_selectionList[select];
|
||||
m_selectionList.selected = false;
|
||||
m_selectionList.zeroWidth = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
* @param[in,out] ---
|
||||
* @param[in,out] ---
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnBuf::RectSelect(int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd)
|
||||
{
|
||||
m_selectionList.selected = rectStart < rectEnd;
|
||||
m_selectionList.zeroWidth = (rectStart == rectEnd) ? false : true;
|
||||
m_selectionList.rectangular = true;
|
||||
m_selectionList.start = start;
|
||||
m_selectionList.end = end;
|
||||
m_selectionList.rectStart = rectStart;
|
||||
m_selectionList.rectEnd = rectEnd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool EdnBuf::GetSelectionPos(int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd)
|
||||
{
|
||||
/* Always fill in the parameters (zero-width can be requested too). */
|
||||
isRect = m_selectionList.rectangular;
|
||||
start = m_selectionList.start;
|
||||
end = m_selectionList.end;
|
||||
if (m_selectionList.rectangular) {
|
||||
rectStart = m_selectionList.rectStart;
|
||||
rectEnd = m_selectionList.rectEnd;
|
||||
}
|
||||
return m_selectionList.selected;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnBuf::GetSelectionText(etk::Vector<int8_t> &text)
|
||||
{
|
||||
int32_t start, end, rectStart, rectEnd;
|
||||
bool isRect;
|
||||
// remove output data
|
||||
text.Clear();
|
||||
|
||||
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
|
||||
|
||||
// No data selected ...
|
||||
if (false == isSelected) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Rectangular selection
|
||||
if (true == isRect) {
|
||||
//GetTextInRect(start, end, rectStart, rectEnd, text);
|
||||
// TODO : ...
|
||||
} else {
|
||||
GetRange(start, end, text);
|
||||
}
|
||||
}
|
||||
void EdnBuf::GetSelectionText(etk::UString &text)
|
||||
{
|
||||
int32_t start, end, rectStart, rectEnd;
|
||||
bool isRect;
|
||||
// remove output data
|
||||
text = "";
|
||||
|
||||
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
|
||||
|
||||
// No data selected ...
|
||||
if (false == isSelected) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Rectangular selection
|
||||
if (true == isRect) {
|
||||
//GetTextInRect(start, end, rectStart, rectEnd, text);
|
||||
// TODO : ...
|
||||
} else {
|
||||
GetRange(start, end, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnBuf::RemoveSelected(void)
|
||||
{
|
||||
int32_t start, end;
|
||||
int32_t rectStart, rectEnd;
|
||||
bool isRect;
|
||||
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
|
||||
|
||||
// No data selected ...
|
||||
if (false == isSelected) {
|
||||
return;
|
||||
}
|
||||
// Rectangular selection
|
||||
if (true == isRect) {
|
||||
//RemoveRect(start, end, rectStart, rectEnd);
|
||||
// TODO : ...
|
||||
} else {
|
||||
Remove(start, end);
|
||||
}
|
||||
Unselect();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
int32_t EdnBuf::ReplaceSelected(etk::Vector<int8_t> &text)
|
||||
{
|
||||
int32_t start, end, rectStart, rectEnd;
|
||||
bool isRect;
|
||||
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
|
||||
|
||||
// No data selected ...
|
||||
if (false == isSelected) {
|
||||
return 0;
|
||||
}
|
||||
int32_t returnSize = 0;
|
||||
// Rectangular selection
|
||||
if (true == isRect) {
|
||||
//ReplaceRect(start, end, rectStart, rectEnd, text);
|
||||
// TODO : ...
|
||||
} else {
|
||||
returnSize = Replace(start, end, text);
|
||||
}
|
||||
// Clean selection
|
||||
m_selectionList.selected = false;
|
||||
return returnSize;
|
||||
}
|
||||
int32_t EdnBuf::ReplaceSelected(etk::UString &text)
|
||||
{
|
||||
int32_t start, end, rectStart, rectEnd;
|
||||
bool isRect;
|
||||
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
|
||||
|
||||
// No data selected ...
|
||||
if (false == isSelected) {
|
||||
return 0;
|
||||
}
|
||||
int32_t returnSize = 0;
|
||||
// Rectangular selection
|
||||
if (true == isRect) {
|
||||
//ReplaceRect(start, end, rectStart, rectEnd, text);
|
||||
// TODO : ...
|
||||
} else {
|
||||
returnSize = Replace(start, end, text);
|
||||
}
|
||||
// Clean selection
|
||||
m_selectionList.selected = false;
|
||||
return returnSize;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Update an individual selection for changes in the corresponding text
|
||||
*/
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnBuf::UpdateSelection(int32_t pos, int32_t nDeleted, int32_t nInserted)
|
||||
{
|
||||
if( ( false == m_selectionList.selected
|
||||
&& false == m_selectionList.zeroWidth)
|
||||
|| pos > m_selectionList.end )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (pos+nDeleted <= m_selectionList.start) {
|
||||
m_selectionList.start += nInserted - nDeleted;
|
||||
m_selectionList.end += nInserted - nDeleted;
|
||||
} else if( pos <= m_selectionList.start
|
||||
&& pos+nDeleted >= m_selectionList.end)
|
||||
{
|
||||
m_selectionList.start = pos;
|
||||
m_selectionList.end = pos;
|
||||
m_selectionList.selected = false;
|
||||
m_selectionList.zeroWidth = false;
|
||||
} else if( pos <= m_selectionList.start
|
||||
&& pos+nDeleted < m_selectionList.end)
|
||||
{
|
||||
m_selectionList.start = pos;
|
||||
m_selectionList.end = nInserted + m_selectionList.end - nDeleted;
|
||||
} else if(pos < m_selectionList.end) {
|
||||
m_selectionList.end += nInserted - nDeleted;
|
||||
if (m_selectionList.end <= m_selectionList.start) {
|
||||
m_selectionList.selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
704
sources/appl/Buffer/EdnVectorBuf.cpp
Normal file
704
sources/appl/Buffer/EdnVectorBuf.cpp
Normal file
@@ -0,0 +1,704 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file EdnEdnVectorBuf.cpp
|
||||
* @brief Editeur De N'ours : Basic EdnVectorBuf Basic binary vector for all type of storage
|
||||
* @author Edouard DUPIN
|
||||
* @date 07/04/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <EdnVectorBuf.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EdnEdnVectorBuf"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create an empty vector
|
||||
*
|
||||
* @param[in] count Minimum request size of the Buffer
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
EdnVectorBuf::EdnVectorBuf(int32_t count)
|
||||
{
|
||||
m_data = NULL;
|
||||
m_allocated = 0;
|
||||
m_gapStart = 0;
|
||||
m_gapEnd = GAP_SIZE_MIN;
|
||||
ChangeAllocation(count+GAP_SIZE_MIN);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Re-copy constructor (copy all needed data)
|
||||
*
|
||||
* @param[in] Evb Vector that might be copy
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
EdnVectorBuf::EdnVectorBuf(const EdnVectorBuf & Evb)
|
||||
{
|
||||
m_allocated = Evb.m_allocated;
|
||||
m_data = NULL;
|
||||
m_gapStart = Evb.m_gapStart;
|
||||
m_gapEnd = Evb.m_gapEnd;
|
||||
|
||||
// allocate all same data
|
||||
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
|
||||
APPL_ASSERT(NULL!=m_data, "Error in data allocation");
|
||||
// Copy all data ...
|
||||
memcpy(m_data, Evb.m_data, m_allocated * sizeof(int8_t) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Destructor of the current Class
|
||||
*
|
||||
* @param ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
EdnVectorBuf::~EdnVectorBuf()
|
||||
{
|
||||
if (NULL!=m_data) {
|
||||
free(m_data);
|
||||
m_data = NULL;
|
||||
m_allocated = 0;
|
||||
m_gapStart = 0;
|
||||
m_gapEnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int32_t getFileSize(FILE *myFile)
|
||||
{
|
||||
if (NULL == myFile) {
|
||||
return 0;
|
||||
}
|
||||
int32_t size = 0;
|
||||
|
||||
fseek(myFile, 0, SEEK_END);
|
||||
size = ftell(myFile);
|
||||
fseek(myFile, 0, SEEK_SET);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Save in the current file open
|
||||
*
|
||||
* @param[in,out] myFile pointer on the file where data might be writed
|
||||
*
|
||||
* @return true if OK / false if an error occured
|
||||
*
|
||||
*/
|
||||
bool EdnVectorBuf::DumpIn(etk::FSNode &file)
|
||||
{
|
||||
bool ret = true;
|
||||
// write Data
|
||||
(void)file.FileWrite(m_data, sizeof(int8_t), m_gapStart);
|
||||
(void)file.FileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Load in the current file open
|
||||
*
|
||||
* @param[in,out] myFile pointer on the file where data might be read
|
||||
*
|
||||
* @return true if OK / false if an error occured
|
||||
*
|
||||
*/
|
||||
bool EdnVectorBuf::DumpFrom(etk::FSNode &file)
|
||||
{
|
||||
bool ret = true;
|
||||
uint32_t length = file.FileSize();
|
||||
// error case ...
|
||||
if (length > 2000000000) {
|
||||
return false;
|
||||
}
|
||||
// allocate the current buffer :
|
||||
ChangeAllocation(length + GAP_SIZE_MIN);
|
||||
|
||||
// insert Data
|
||||
int32_t nbReadData = file.FileRead(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length);
|
||||
APPL_INFO("load data : filesize=" << length << ", readData=" << nbReadData);
|
||||
// check ERROR
|
||||
if (nbReadData != length) {
|
||||
APPL_ERROR("load data pb : filesize=" << length << ", readData=" << nbReadData);
|
||||
ret = false;
|
||||
}
|
||||
// set the gapsize at the end ...
|
||||
m_gapStart = 0;
|
||||
m_gapEnd = GAP_SIZE_MIN;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Re-copy operator
|
||||
*
|
||||
* @param[in] Evb Vector that might be copy
|
||||
*
|
||||
* @return reference on the curent re-copy vector
|
||||
*
|
||||
*/
|
||||
EdnVectorBuf& EdnVectorBuf::operator=(const EdnVectorBuf & Evb)
|
||||
{
|
||||
if( this != &Evb ) // avoid copy to itself
|
||||
{
|
||||
if (NULL!=m_data) {
|
||||
free(m_data);
|
||||
m_data = NULL;
|
||||
}
|
||||
// Set the new value
|
||||
m_allocated = Evb.m_allocated;
|
||||
m_gapStart = Evb.m_gapStart;
|
||||
m_gapEnd = Evb.m_gapEnd;
|
||||
// allocate all same data
|
||||
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
|
||||
APPL_ASSERT(NULL!=m_data, "Error in data allocation");
|
||||
// Copy all data ...
|
||||
memcpy(m_data, Evb.m_data, m_allocated * sizeof(int8_t) );
|
||||
}
|
||||
// Return the curent pointer
|
||||
return *this;
|
||||
}
|
||||
|
||||
int8_t EdnVectorBuf::operator[] (int32_t pos)
|
||||
{
|
||||
APPL_ASSERT(0 <= pos || pos < Size(), "try to read an element non existing");
|
||||
if (pos < m_gapStart) {
|
||||
return m_data[pos];
|
||||
}
|
||||
return m_data[pos + m_gapEnd-m_gapStart];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get a current element in the vector
|
||||
*
|
||||
* @param[in] pos Desired position read
|
||||
*
|
||||
* @return Reference on the Element
|
||||
*
|
||||
*/
|
||||
int8_t& EdnVectorBuf::Get(int32_t pos)
|
||||
{
|
||||
APPL_ASSERT(0 <= pos || pos < Size(), "try to read an element non existing");
|
||||
if (pos < m_gapStart) {
|
||||
return m_data[pos];
|
||||
}
|
||||
return m_data[pos + m_gapEnd-m_gapStart];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::Get(int32_t pos, int32_t nbElement, etk::Vector<int8_t> &tmpBuffer)
|
||||
{
|
||||
tmpBuffer.Clear();
|
||||
if (pos < m_gapStart) {
|
||||
if (pos + nbElement < m_gapStart) {
|
||||
tmpBuffer.PushBack(&m_data[pos], nbElement);
|
||||
} else {
|
||||
tmpBuffer.PushBack(&m_data[pos], m_gapStart - pos);
|
||||
tmpBuffer.PushBack(&m_data[m_gapEnd], nbElement - (m_gapStart - pos) );
|
||||
}
|
||||
} else {
|
||||
tmpBuffer.PushBack(&m_data[pos+(m_gapEnd-m_gapStart)], nbElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add at the Last position of the Vector
|
||||
*
|
||||
* @param[in] item Element to add at the end of vector
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::PushBack(const int8_t& item)
|
||||
{
|
||||
Insert( Size(), item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove the last element of the vector
|
||||
*
|
||||
* @param ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::PopBack(void)
|
||||
{
|
||||
if (Size()>0) {
|
||||
Remove( Size() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Remove data in the buffer
|
||||
*
|
||||
* @param[in]
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::Remove(int32_t pos, int32_t nbRemoveElement)
|
||||
{
|
||||
if( pos > Size()
|
||||
|| pos < 0 ) {
|
||||
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
|
||||
return;
|
||||
}
|
||||
if( pos+nbRemoveElement > Size() ) {
|
||||
APPL_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="<<pos+nbRemoveElement<< " bufferSize="<<Size());
|
||||
return;
|
||||
}
|
||||
if (false == GapMove(pos) ) {
|
||||
return;
|
||||
}
|
||||
// Remove elements :
|
||||
if (m_allocated==m_gapEnd) {
|
||||
m_gapStart -= nbRemoveElement;
|
||||
} else {
|
||||
m_gapEnd += nbRemoveElement;
|
||||
}
|
||||
// Resize buffer if needed...
|
||||
GapCheckMaxSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Change the current allocation to the corect one (depend on the current size)
|
||||
*
|
||||
* @param[in] newSize Minimum number of element needed
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::Clear(void)
|
||||
{
|
||||
// Remove all element in the buffer
|
||||
Remove(0, Size() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Change the current allocation to the corect one (depend on the current size)
|
||||
*
|
||||
* @param[in] newSize Minimum number of element needed
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::ChangeAllocation(int32_t newSize)
|
||||
{
|
||||
// set the minimal size to 1
|
||||
if(newSize <= 0) {
|
||||
newSize = 1;
|
||||
}
|
||||
// set the size with the corect chose type :
|
||||
if (newSize == m_allocated) {
|
||||
return;
|
||||
}
|
||||
APPL_DEBUG("Change Allocation : " << m_allocated << " ==> " << newSize);
|
||||
// check if something is allocated :
|
||||
if (NULL == m_data) {
|
||||
// no data allocated ==> request an allocation (might be the first)
|
||||
m_data = (int8_t *)malloc( newSize * sizeof(int8_t) );
|
||||
} else {
|
||||
// move datas
|
||||
m_data = (int8_t *)realloc( m_data, newSize* sizeof(int8_t) );
|
||||
}
|
||||
// Check result with assert :
|
||||
APPL_ASSERT(NULL!=m_data, "Error in data allocation");
|
||||
// set the new allocation size
|
||||
m_allocated = newSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::Insert(int32_t pos, const int8_t& item)
|
||||
{
|
||||
if( pos > Size()
|
||||
|| pos < 0 ) {
|
||||
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
|
||||
return;
|
||||
}
|
||||
if( 0 == GapSize() ) {
|
||||
if (false == GapResize(pos, GAP_SIZE_MIN + 1) ) {
|
||||
return;
|
||||
}
|
||||
} else if( pos == m_gapStart
|
||||
&& pos == m_gapEnd-1 )
|
||||
{
|
||||
// mothing to do ...
|
||||
} else {
|
||||
if (false == GapMove(pos)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(pos == m_gapStart) {
|
||||
m_data[m_gapStart] = item;
|
||||
m_gapStart++;
|
||||
} else {
|
||||
m_data[m_gapEnd-1] = item;
|
||||
m_gapEnd--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::Insert(int32_t pos, etk::Vector<int8_t>& items)
|
||||
{
|
||||
if( pos > Size()
|
||||
|| pos < 0 ) {
|
||||
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
|
||||
return;
|
||||
}
|
||||
if( items.Size() > GapSize() ) {
|
||||
if (false == GapResize(pos, GAP_SIZE_MIN + items.Size()) ) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (false == GapMove(pos) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
int32_t i;
|
||||
for(i=0; i<items.Size(); i++) {
|
||||
m_data[m_gapStart+i] = items[i];
|
||||
}
|
||||
m_gapStart += items.Size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::Replace(int32_t pos, const int8_t& item)
|
||||
{
|
||||
if( pos > Size()
|
||||
|| pos < 0 ) {
|
||||
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
|
||||
return;
|
||||
}
|
||||
// just replace the element, not update Gap position
|
||||
if (pos < m_gapStart) {
|
||||
m_data[pos] = item;
|
||||
} else {
|
||||
m_data[pos+GapSize()] = item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::Replace(int32_t pos, int32_t nbRemoveElement, etk::Vector<int8_t>& items)
|
||||
{
|
||||
if( pos > Size()
|
||||
|| pos < 0 ) {
|
||||
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
|
||||
return;
|
||||
}
|
||||
if( pos+nbRemoveElement > Size() ) {
|
||||
APPL_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="<<pos+nbRemoveElement<< " bufferSize="<<Size());
|
||||
return;
|
||||
}
|
||||
if (false == GapMove(pos)) {
|
||||
return;
|
||||
}
|
||||
// Remove elements :
|
||||
m_gapEnd += nbRemoveElement;
|
||||
//Display();
|
||||
// insert elements
|
||||
Insert(pos, items);
|
||||
// Resize buffer if needed...
|
||||
GapCheckMaxSize();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool EdnVectorBuf::GapMove(int32_t pos)
|
||||
{
|
||||
if( pos > Size()
|
||||
|| pos < 0 ) {
|
||||
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
|
||||
return false;
|
||||
}
|
||||
int32_t gapLen = m_gapEnd - m_gapStart;
|
||||
if (pos > m_gapStart) {
|
||||
memmove(&m_data[m_gapStart], &m_data[m_gapEnd], pos - m_gapStart);
|
||||
} else {
|
||||
memmove(&m_data[pos + gapLen], &m_data[pos], m_gapStart - pos);
|
||||
}
|
||||
m_gapEnd += pos - m_gapStart;
|
||||
m_gapStart += pos - m_gapStart;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool EdnVectorBuf::GapResize(int32_t pos, int32_t newGapLen)
|
||||
{
|
||||
if( pos > Size()
|
||||
|| pos < 0 ) {
|
||||
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
|
||||
return false;
|
||||
}
|
||||
int32_t previousSize = Size();
|
||||
if (newGapLen == GapSize() ) {
|
||||
// nothing to do ...
|
||||
return true;
|
||||
} else {
|
||||
if (newGapLen > GapSize() ) {
|
||||
// reallocation
|
||||
ChangeAllocation( previousSize + newGapLen);
|
||||
}
|
||||
// move Data
|
||||
if (pos <= m_gapStart) {
|
||||
// just move the end of the gap
|
||||
memmove(&m_data[m_gapStart + newGapLen], &m_data[m_gapEnd], previousSize - m_gapStart);
|
||||
// update gap end position
|
||||
m_gapEnd = m_gapStart + newGapLen;
|
||||
if (pos < m_gapStart) {
|
||||
if (false == GapMove(pos)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// no else
|
||||
} else {
|
||||
if (false == GapMove(pos) ) {
|
||||
return false;
|
||||
}
|
||||
memmove(&m_data[m_gapStart + newGapLen], &m_data[m_gapEnd], previousSize - m_gapStart);
|
||||
}
|
||||
if (newGapLen < GapSize() ) {
|
||||
// rellocation
|
||||
ChangeAllocation(previousSize + newGapLen);
|
||||
}
|
||||
}
|
||||
// update gap position
|
||||
m_gapStart = pos;
|
||||
m_gapEnd = pos + newGapLen;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::GapCheckMaxSize(void)
|
||||
{
|
||||
if(GapSize() > GAP_SIZE_MAX) {
|
||||
int32_t currentSize = Size();
|
||||
// Change the gap Size
|
||||
if (false == GapResize(m_gapStart, GAP_SIZE_MAX) ) {
|
||||
return;
|
||||
}
|
||||
// remove deprecated elements at the end of the buffer ...
|
||||
ChangeAllocation(currentSize + GAP_SIZE_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void EdnVectorBuf::Display(void)
|
||||
{
|
||||
APPL_INFO(" Display Buffer : Size="<<Size()<<" m_allocated="<<m_allocated<<" m_gapStart="<<m_gapStart<<" m_gapEnd="<<m_gapEnd);
|
||||
for(int32_t i=0; i<m_allocated; i++) {
|
||||
if (i>= m_gapStart && i< m_gapEnd) {
|
||||
APPL_INFO( "Element " << i << " : GAP");
|
||||
} else {
|
||||
APPL_INFO( "Element " << i << " : " << m_data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void TestEdnVectorBuf(void)
|
||||
{
|
||||
EdnVectorBuf myBufferTmp;
|
||||
int32_t i;
|
||||
|
||||
//invert data
|
||||
for (i=0; i<50; i++) {
|
||||
myBufferTmp.Insert(0, 'a' + i%26);
|
||||
}
|
||||
myBufferTmp.Display();
|
||||
myBufferTmp.Clear();
|
||||
myBufferTmp.Display();
|
||||
|
||||
myBufferTmp.Remove(2, 300);
|
||||
/*
|
||||
char plop='a';
|
||||
myBufferTmp.Insert(0, plop);
|
||||
myBufferTmp.Display();
|
||||
plop='b';
|
||||
myBufferTmp.Insert(0, plop);
|
||||
myBufferTmp.Display();
|
||||
plop='c';
|
||||
myBufferTmp.Insert(0, plop);
|
||||
myBufferTmp.Display();
|
||||
plop='d';
|
||||
myBufferTmp.Insert(0, plop);
|
||||
myBufferTmp.Display();
|
||||
plop='e';
|
||||
myBufferTmp.Insert(0, plop);
|
||||
myBufferTmp.Display();
|
||||
plop='f';
|
||||
myBufferTmp.Insert(0, plop);
|
||||
myBufferTmp.Display();
|
||||
plop='g';
|
||||
myBufferTmp.Insert(0, plop);
|
||||
myBufferTmp.Display();
|
||||
plop='h';
|
||||
myBufferTmp.Insert(0, plop);
|
||||
myBufferTmp.Display();
|
||||
plop='m';
|
||||
|
||||
etk::Vector<int8_t> items;
|
||||
items.PushBack('i');
|
||||
items.PushBack('j');
|
||||
items.PushBack('k');
|
||||
items.PushBack('l');
|
||||
items.PushBack('m');
|
||||
items.PushBack('n');
|
||||
items.PushBack('o');
|
||||
items.PushBack('p');
|
||||
|
||||
|
||||
|
||||
myBufferTmp.Insert(3, items);
|
||||
myBufferTmp.Display();
|
||||
|
||||
|
||||
|
||||
plop='7';
|
||||
myBufferTmp.Insert(7, plop);
|
||||
myBufferTmp.Display();
|
||||
|
||||
myBufferTmp.Replace(8, 'z');
|
||||
myBufferTmp.Display();
|
||||
|
||||
items.Clear();
|
||||
items.PushBack('1');
|
||||
items.PushBack('2');
|
||||
items.PushBack('3');
|
||||
myBufferTmp.Replace(10, 4, items);
|
||||
myBufferTmp.Display();
|
||||
|
||||
|
||||
myBufferTmp.PushBack('a');
|
||||
myBufferTmp.PushBack('a');
|
||||
myBufferTmp.PushBack('a');
|
||||
myBufferTmp.PushBack('a');
|
||||
myBufferTmp.Display();
|
||||
|
||||
|
||||
myBufferTmp.PopBack();
|
||||
myBufferTmp.PopBack();
|
||||
myBufferTmp.PopBack();
|
||||
myBufferTmp.PopBack();
|
||||
myBufferTmp.Display();
|
||||
|
||||
myBufferTmp.Remove(2, 3);
|
||||
myBufferTmp.Display();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
342
sources/appl/Buffer/EdnVectorBuf.h
Normal file
342
sources/appl/Buffer/EdnVectorBuf.h
Normal file
@@ -0,0 +1,342 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file EdnEdnVectorBuf.h
|
||||
* @brief Editeur De N'ours : Basic EdnVectorBuf for direct data insertion (template)
|
||||
* @author Edouard DUPIN
|
||||
* @date 07/04/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EDN_VECTOR_BUF_H__
|
||||
#define __EDN_VECTOR_BUF_H__
|
||||
|
||||
#include <etk/Vector.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EdnVectorBuf"
|
||||
|
||||
// minimum gapSize when allocated
|
||||
#define GAP_SIZE_MIN (80)
|
||||
// maximum gap that is automaticly resize
|
||||
#define GAP_SIZE_MAX (GAP_SIZE_MIN*4)
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
______________________________________________________________________________________
|
||||
| |
|
||||
| |
|
||||
| <GapStart |
|
||||
| *******************************************************************|
|
||||
|****************************************** |
|
||||
| Gap Stop > |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
|____________________________________________________________________________________|
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief EdnVectorBuf classes ...
|
||||
*/
|
||||
class EdnVectorBuf
|
||||
{
|
||||
public:
|
||||
class Iterator
|
||||
{
|
||||
// Private data :
|
||||
private:
|
||||
int32_t m_current; // curent Id on the vector
|
||||
EdnVectorBuf * m_EdnVectorBuf; // Pointer on the curent element of the vectorBin
|
||||
public:
|
||||
/**
|
||||
* @brief Basic itarator constructor with no link with an EdnVector
|
||||
*/
|
||||
Iterator(void):
|
||||
m_current(-1),
|
||||
m_EdnVectorBuf(NULL)
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
/**
|
||||
* @brief Recopy constructor on a specific EdnVector.
|
||||
* @param[in] otherIterator The Iterator that might be copy
|
||||
*/
|
||||
Iterator(const Iterator & otherIterator):
|
||||
m_current(otherIterator.m_current),
|
||||
m_EdnVectorBuf(otherIterator.m_EdnVectorBuf)
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
/**
|
||||
* @brief Asignation operator.
|
||||
* @param[in] otherIterator The Iterator that might be copy
|
||||
* @return reference on the curent Iterator
|
||||
*/
|
||||
Iterator& operator=(const Iterator & otherIterator)
|
||||
{
|
||||
m_current = otherIterator.m_current;
|
||||
m_EdnVectorBuf = otherIterator.m_EdnVectorBuf;
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Basic destructor
|
||||
*/
|
||||
~Iterator(void)
|
||||
{
|
||||
m_current = -1;
|
||||
m_EdnVectorBuf = NULL;
|
||||
}
|
||||
/**
|
||||
* @brief gaet element position in the system
|
||||
*/
|
||||
int32_t Position(void)
|
||||
{
|
||||
if(0 > m_current) {
|
||||
return 0;
|
||||
} else if (m_EdnVectorBuf->Size() <= m_current) {
|
||||
return m_EdnVectorBuf->Size();
|
||||
} else {
|
||||
return m_current;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief basic boolean cast
|
||||
* @return true if the element is present in the EdnVector size
|
||||
*/
|
||||
operator bool ()
|
||||
{
|
||||
if( 0 <= m_current
|
||||
&& m_current < m_EdnVectorBuf->Size() )
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Incremental operator
|
||||
* @return Reference on the current iterator incremented
|
||||
*/
|
||||
Iterator& operator++ ()
|
||||
{
|
||||
if( NULL != m_EdnVectorBuf
|
||||
&& m_current < m_EdnVectorBuf->Size() )
|
||||
{
|
||||
m_current++;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Decremental operator
|
||||
* @return Reference on the current iterator decremented
|
||||
*/
|
||||
Iterator& operator-- ()
|
||||
{
|
||||
if (m_current >= 0) {
|
||||
m_current--;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Incremental operator
|
||||
* @return Reference on a new iterator and increment the other one
|
||||
*/
|
||||
Iterator operator++ (int32_t)
|
||||
{
|
||||
Iterator it(*this);
|
||||
++(*this);
|
||||
return it;
|
||||
}
|
||||
/**
|
||||
* @brief Decremental operator
|
||||
* @return Reference on a new iterator and decrement the other one
|
||||
*/
|
||||
Iterator operator-- (int32_t)
|
||||
{
|
||||
Iterator it(*this);
|
||||
--(*this);
|
||||
return it;
|
||||
}
|
||||
/**
|
||||
* @brief Get reference on the current Element
|
||||
* @return the reference on the current Element
|
||||
*/
|
||||
int8_t & operator-> () const
|
||||
{
|
||||
APPL_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVectorBuf->Size());
|
||||
return m_EdnVectorBuf->Get(m_current);
|
||||
}
|
||||
/**
|
||||
* @brief Get reference on the current Element
|
||||
* @return the reference on the current Element
|
||||
*/
|
||||
int8_t & operator* () const
|
||||
{
|
||||
APPL_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVectorBuf->Size());
|
||||
return m_EdnVectorBuf->Get(m_current);
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Iterator(EdnVectorBuf * Evb, int32_t pos):
|
||||
m_current(pos),
|
||||
m_EdnVectorBuf(Evb)
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
friend class EdnVectorBuf;
|
||||
};
|
||||
private:
|
||||
int8_t * m_data; //!< pointer on the curetn table of Data
|
||||
int32_t m_allocated; //!< Current allocated size
|
||||
// empty part of the buffer data
|
||||
int32_t m_gapStart; //!< points to the first character of the gap
|
||||
int32_t m_gapEnd; //!< points to the first char after the gap
|
||||
public:
|
||||
EdnVectorBuf(int32_t count = 0);
|
||||
EdnVectorBuf(const EdnVectorBuf & Evb);
|
||||
~EdnVectorBuf();
|
||||
|
||||
bool DumpIn( etk::FSNode &file);
|
||||
bool DumpFrom( etk::FSNode &file);
|
||||
|
||||
EdnVectorBuf & operator=( const EdnVectorBuf & Evb);
|
||||
int8_t operator[] (int32_t pos);
|
||||
int8_t & Get( int32_t pos);
|
||||
void Get( int32_t pos, int32_t nbElement, etk::Vector<int8_t> &tmpBuffer);
|
||||
// insert functions
|
||||
void PushBack( const int8_t& item);
|
||||
void Insert( int32_t pos, const int8_t& item);
|
||||
void Insert( int32_t pos, etk::Vector<int8_t>& items);
|
||||
// Remove and insert functions
|
||||
void Replace( int32_t pos, const int8_t& item);
|
||||
void Replace( int32_t pos, int32_t nbRemoveElement, etk::Vector<int8_t>& items);
|
||||
// Revove fonctions
|
||||
void Remove( int32_t pos, int32_t nbRemoveElement = 1);
|
||||
void PopBack( void);
|
||||
void Clear( void);
|
||||
|
||||
|
||||
void Fit(void);
|
||||
|
||||
void Display(void);
|
||||
|
||||
/**
|
||||
* @brief Get a current element in the vector (iterator system)
|
||||
* @param[in] RealElementPosition Real position in the buffer (only use in the ITERATOR)
|
||||
* @return Reference on the Element
|
||||
*/
|
||||
int8_t & GetDirect(int32_t RealElementPosition){ return m_data[RealElementPosition]; };
|
||||
/**
|
||||
* @brief Get the number of element in the vector
|
||||
* @return The number requested
|
||||
*/
|
||||
int32_t Size(void) { return m_allocated - GapSize(); };
|
||||
|
||||
Iterator Position(int32_t pos)
|
||||
{
|
||||
return Iterator(this, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get an Iterator on the start position of the Vector
|
||||
* @return The Iterator
|
||||
*/
|
||||
Iterator Begin()
|
||||
{
|
||||
return Position(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get an Iterator on the end position of the Vector
|
||||
* @return The Iterator
|
||||
*/
|
||||
Iterator End()
|
||||
{
|
||||
return Position( Size()-1 );
|
||||
}
|
||||
private:
|
||||
// TODO : Set a boolean at the return value to prevent internal error ...
|
||||
void ChangeAllocation( int32_t newSize);
|
||||
bool GapMove( int32_t pos);
|
||||
bool GapResize( int32_t pos, int32_t newGapLen);
|
||||
// get current gap Size
|
||||
int32_t GapSize( void) { return m_gapEnd - m_gapStart; };
|
||||
void GapCheckMaxSize( void);
|
||||
};
|
||||
|
||||
#undef __class__
|
||||
#define __class__ NULL
|
||||
|
||||
void TestEdnVectorBuf(void);
|
||||
|
||||
#endif
|
145
sources/appl/Colorize/Colorize.cpp
Normal file
145
sources/appl/Colorize/Colorize.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Colorise.cpp
|
||||
* @brief Editeur De N'ours : Colirising system
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <Colorize.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Colorize"
|
||||
|
||||
|
||||
Colorize::Colorize( etk::UString &newColorName)
|
||||
{
|
||||
|
||||
m_colorFG = draw::color::black;
|
||||
m_colorBG = draw::color::black;
|
||||
|
||||
italic = false;
|
||||
bold = false;
|
||||
haveFG = false;
|
||||
haveBG = false;
|
||||
SetName(newColorName);
|
||||
APPL_VERBOSE("New(Colorise)");
|
||||
}
|
||||
|
||||
Colorize::Colorize(void)
|
||||
{
|
||||
ColorName = "no_name";
|
||||
|
||||
m_colorFG = draw::color::black;
|
||||
m_colorBG = draw::color::black;
|
||||
|
||||
italic = false;
|
||||
bold = false;
|
||||
haveFG = false;
|
||||
haveBG = false;
|
||||
|
||||
APPL_VERBOSE("New(Colorise)");
|
||||
}
|
||||
|
||||
Colorize::~Colorize(void)
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
|
||||
void Colorize::SetName(const char *newColorName)
|
||||
{
|
||||
APPL_VERBOSE("color change name : \"" << ColorName << "\" ==> \"" << newColorName << "\"");
|
||||
ColorName = newColorName;
|
||||
}
|
||||
|
||||
void Colorize::SetName(etk::UString &newColorName)
|
||||
{
|
||||
APPL_VERBOSE("color change name : \"" << ColorName << "\" ==> \"" << newColorName << "\"");
|
||||
ColorName = newColorName;
|
||||
}
|
||||
|
||||
|
||||
etk::UString Colorize::GetName(void)
|
||||
{
|
||||
return ColorName;
|
||||
}
|
||||
|
||||
|
||||
void Colorize::SetFgColor(const char *myColor)
|
||||
{
|
||||
haveFG = true;
|
||||
m_colorFG = myColor;
|
||||
APPL_VERBOSE(myColor << " ==> "<< m_colorFG );
|
||||
}
|
||||
|
||||
void Colorize::SetBgColor(const char *myColor)
|
||||
{
|
||||
haveBG = true;
|
||||
m_colorBG = myColor;
|
||||
APPL_VERBOSE(myColor << " ==> "<< m_colorBG );
|
||||
}
|
||||
|
||||
bool Colorize::HaveBg(void)
|
||||
{
|
||||
return haveBG;
|
||||
}
|
||||
|
||||
|
||||
void Colorize::SetItalic(bool enable)
|
||||
{
|
||||
italic = enable;
|
||||
if (true == enable) {
|
||||
APPL_VERBOSE("color : \"" << ColorName << "\" enable italic");
|
||||
} else {
|
||||
APPL_VERBOSE("color : \"" << ColorName << "\" disable italic");
|
||||
}
|
||||
}
|
||||
|
||||
bool Colorize::GetItalic(void)
|
||||
{
|
||||
return italic;
|
||||
}
|
||||
|
||||
|
||||
void Colorize::SetBold(bool enable)
|
||||
{
|
||||
bold = enable;
|
||||
if (true == enable) {
|
||||
APPL_VERBOSE("color : \"" << ColorName << "\" enable bold");
|
||||
} else {
|
||||
APPL_VERBOSE("color : \"" << ColorName << "\" disable bold");
|
||||
}
|
||||
}
|
||||
|
||||
bool Colorize::GetBold(void)
|
||||
{
|
||||
return bold;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
69
sources/appl/Colorize/Colorize.h
Normal file
69
sources/appl/Colorize/Colorize.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Colorize.h
|
||||
* @brief Editeur De N'ours : Colirizing system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __COLORIZE_H__
|
||||
#define __COLORIZE_H__
|
||||
#include <etk/UString.h>
|
||||
|
||||
class Colorize {
|
||||
public:
|
||||
// Constructeur
|
||||
Colorize(void);
|
||||
Colorize(etk::UString &newColorName);
|
||||
~Colorize(void);
|
||||
|
||||
void SetName(etk::UString &newColorName);
|
||||
void SetName(const char *newColorName);
|
||||
etk::UString GetName(void);
|
||||
void SetFgColor(const char *myColor);
|
||||
void SetBgColor(const char *myColor);
|
||||
|
||||
draw::Color & GetFG(void) { return m_colorFG; };
|
||||
draw::Color & GetBG(void) { return m_colorBG; };
|
||||
|
||||
bool HaveBg(void);
|
||||
|
||||
void SetItalic(bool enable);
|
||||
void SetBold(bool enable);
|
||||
bool GetItalic(void);
|
||||
bool GetBold(void);
|
||||
|
||||
void Display(int32_t i) { APPL_INFO(" " << i << " : \"" << ColorName << "\"" << " fg="<< m_colorFG); };
|
||||
|
||||
private:
|
||||
etk::UString ColorName; //!< curent color Name
|
||||
draw::Color m_colorFG;
|
||||
draw::Color m_colorBG;
|
||||
|
||||
bool italic;
|
||||
bool bold;
|
||||
bool haveFG;
|
||||
bool haveBG;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
455
sources/appl/Colorize/ColorizeManager.cpp
Normal file
455
sources/appl/Colorize/ColorizeManager.cpp
Normal file
@@ -0,0 +1,455 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ColorizeManager.cpp
|
||||
* @brief Editeur De N'ours : Colorising Manager
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <tinyXML/tinyxml.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
#include <ewol/eObject/EObjectManager.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
#define PFX "ColorizeManager "
|
||||
|
||||
class classColorManager: public ewol::EObject
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
classColorManager(void);
|
||||
~classColorManager(void);
|
||||
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void)
|
||||
{
|
||||
return "ApplColorManager";
|
||||
}
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
public:
|
||||
void LoadFile(etk::UString &xmlFilename);
|
||||
void LoadFile(const char * xmlFilename);
|
||||
Colorize * Get(const char *colorName);
|
||||
Colorize * Get(etk::UString &colorName);
|
||||
draw::Color& Get(basicColor_te myColor);
|
||||
bool Exist(etk::UString &colorName);
|
||||
bool Exist(const char *colorName);
|
||||
void DisplayListOfColor(void);
|
||||
|
||||
private:
|
||||
etk::UString m_fileColor;
|
||||
etk::Vector<Colorize*> listMyColor; //!< List of ALL Color
|
||||
Colorize * errorColor;
|
||||
draw::Color basicColors[COLOR_NUMBER_MAX];
|
||||
};
|
||||
|
||||
|
||||
classColorManager::classColorManager(void)
|
||||
{
|
||||
//ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiChangeColor);
|
||||
}
|
||||
|
||||
classColorManager::~classColorManager(void)
|
||||
{
|
||||
delete(errorColor);
|
||||
|
||||
int32_t i;
|
||||
// clean all Element
|
||||
for (i=0; i< listMyColor.Size(); i++) {
|
||||
if (NULL != listMyColor[i]) {
|
||||
delete(listMyColor[i]);
|
||||
listMyColor[i] = NULL;
|
||||
}
|
||||
}
|
||||
// clear the compleate list
|
||||
listMyColor.Clear();
|
||||
}
|
||||
|
||||
void classColorManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
/*
|
||||
switch (id)
|
||||
{
|
||||
case APPL_MSG__RELOAD_COLOR_FILE:
|
||||
{
|
||||
// Reaload File
|
||||
// TODO : Check this : Pb in the recopy etk::UString element
|
||||
etk::UString plop = m_fileColor;
|
||||
LoadFile(plop);
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void classColorManager::LoadFile(etk::UString &xmlFilename)
|
||||
{
|
||||
// TODO : Remove this
|
||||
LoadFile(xmlFilename.c_str());
|
||||
}
|
||||
|
||||
// TODO : Remove this ...
|
||||
void classColorManager::LoadFile(const char * xmlFilename)
|
||||
{
|
||||
// Remove all old color :
|
||||
int32_t i;
|
||||
// clean all Element
|
||||
for (i=0; i< listMyColor.Size(); i++) {
|
||||
if (NULL != listMyColor[i]) {
|
||||
delete(listMyColor[i]);
|
||||
listMyColor[i] = NULL;
|
||||
}
|
||||
}
|
||||
// clear the compleate list
|
||||
listMyColor.Clear();
|
||||
|
||||
m_fileColor = xmlFilename;
|
||||
APPL_DEBUG("open file (COLOR) \"" << xmlFilename << "\" ? = \"" << m_fileColor << "\"");
|
||||
errorColor = new Colorize();
|
||||
errorColor->SetBgColor("#00FF00FF");
|
||||
errorColor->SetFgColor("#FF00FFFF");
|
||||
|
||||
// allocate the document in the stack
|
||||
TiXmlDocument XmlDocument;
|
||||
// open the curent File
|
||||
etk::FSNode fileName(etk::UString("DATA:color/") + xmlFilename + etk::UString(".xml"));
|
||||
if (false == fileName.Exist()) {
|
||||
APPL_ERROR("File Does not exist : " << fileName);
|
||||
return;
|
||||
}
|
||||
int32_t fileSize = fileName.FileSize();
|
||||
if (0==fileSize) {
|
||||
APPL_ERROR("This file is empty : " << fileName);
|
||||
return;
|
||||
}
|
||||
if (false == fileName.FileOpenRead()) {
|
||||
APPL_ERROR("Can not open the file : " << fileName);
|
||||
return;
|
||||
}
|
||||
// allocate data
|
||||
char * fileBuffer = new char[fileSize+5];
|
||||
if (NULL == fileBuffer) {
|
||||
APPL_ERROR("Error Memory allocation size=" << fileSize);
|
||||
return;
|
||||
}
|
||||
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
|
||||
// load data from the file :
|
||||
fileName.FileRead(fileBuffer, 1, fileSize);
|
||||
// close the file:
|
||||
fileName.FileClose();
|
||||
// load the XML from the memory
|
||||
XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
|
||||
|
||||
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnColor" );
|
||||
if (NULL == root ) {
|
||||
APPL_ERROR(PFX"(l ?) main node not find: \"EdnColor\" in \"" << xmlFilename << "\"");
|
||||
return;
|
||||
} else {
|
||||
TiXmlNode * pNode = root->FirstChild();
|
||||
while(NULL != pNode) {
|
||||
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
|
||||
// nothing to do, just proceed to next step
|
||||
} else if (!strcmp(pNode->Value(), "gui")) {
|
||||
TiXmlNode * pGuiNode = pNode->FirstChild();
|
||||
while(NULL != pGuiNode) {
|
||||
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
|
||||
// nothing to do, just proceed to next step
|
||||
} else if (!strcmp(pGuiNode->Value(), "color")) {
|
||||
//--------------------------------------------------------------------------------------------
|
||||
//<color name="basicBackground" val="#000000"/>
|
||||
//--------------------------------------------------------------------------------------------
|
||||
const char *colorName = pGuiNode->ToElement()->Attribute("name");
|
||||
int32_t id = 0;
|
||||
if (NULL == colorName) {
|
||||
APPL_ERROR("(l "<< pGuiNode->Row() <<") node with no name");
|
||||
// get next node element
|
||||
pGuiNode = pGuiNode->NextSibling();
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(colorName, "CODE_space")) {
|
||||
id = COLOR_CODE_SPACE;
|
||||
} else if (!strcmp(colorName, "CODE_tabulation")) {
|
||||
id = COLOR_CODE_TAB;
|
||||
} else if (!strcmp(colorName, "CODE_basicBackgroung")) {
|
||||
id = COLOR_CODE_BASIC_BG;
|
||||
} else if (!strcmp(colorName, "CODE_cursor")) {
|
||||
id = COLOR_CODE_CURSOR;
|
||||
} else if (!strcmp(colorName, "CODE_lineNumber")) {
|
||||
id = COLOR_CODE_LINE_NUMBER;
|
||||
} else if (!strcmp(colorName, "LIST_backgroung1")) {
|
||||
id = COLOR_LIST_BG_1;
|
||||
} else if (!strcmp(colorName, "LIST_backgroung2")) {
|
||||
id = COLOR_LIST_BG_2;
|
||||
} else if (!strcmp(colorName, "LIST_backgroungSelected")) {
|
||||
id = COLOR_LIST_BG_SELECTED;
|
||||
} else if (!strcmp(colorName, "LIST_textNormal")) {
|
||||
id = COLOR_LIST_TEXT_NORMAL;
|
||||
} else if (!strcmp(colorName, "LIST_textModify")) {
|
||||
id = COLOR_LIST_TEXT_MODIFY;
|
||||
} else {
|
||||
APPL_ERROR("(l "<<pGuiNode->Row()<<") Unknown basic gui color : \"" << colorName << "\"" );
|
||||
// get next node element
|
||||
pGuiNode = pGuiNode->NextSibling();
|
||||
continue;
|
||||
}
|
||||
const char *color = pGuiNode->ToElement()->Attribute("val");
|
||||
if (NULL != color) {
|
||||
basicColors[id] = color;
|
||||
}
|
||||
} else {
|
||||
APPL_ERROR("(l "<<pGuiNode->Row()<<") node not suported : \""<<pGuiNode->Value()<<"\" must be [color]");
|
||||
}
|
||||
// get next node element
|
||||
pGuiNode = pGuiNode->NextSibling();
|
||||
}
|
||||
} else if (!strcmp(pNode->Value(), "syntax")) {
|
||||
TiXmlNode * pGuiNode = pNode->FirstChild();
|
||||
while(NULL != pGuiNode)
|
||||
{
|
||||
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
|
||||
// nothing to do, just proceed to next step
|
||||
} else if (!strcmp(pGuiNode->Value(), "color")) {
|
||||
Colorize *myNewColor = new Colorize();
|
||||
//--------------------------------------------------------------------------------------------
|
||||
//<color name="basicBackground" FG="#000000" BG="#000000" bold="no" italic="no"/>
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// get the name of the Chaine
|
||||
const char *colorName = pGuiNode->ToElement()->Attribute("name");
|
||||
if (NULL == colorName) {
|
||||
APPL_ERROR(PFX"(l "<< pGuiNode->Row() <<") node with no name");
|
||||
// get next node element
|
||||
pGuiNode = pGuiNode->NextSibling();
|
||||
continue;
|
||||
} else {
|
||||
myNewColor->SetName(colorName);
|
||||
//APPL_INFO(PFX"Add a new color in the panel : \"%s\"", colorName);
|
||||
}
|
||||
const char *colorBG = pGuiNode->ToElement()->Attribute("BG");
|
||||
if (NULL != colorBG) {
|
||||
myNewColor->SetBgColor(colorBG);
|
||||
}
|
||||
const char *colorFG = pGuiNode->ToElement()->Attribute("FG");
|
||||
if (NULL != colorFG) {
|
||||
myNewColor->SetFgColor(colorFG);
|
||||
}
|
||||
const char *bold = pGuiNode->ToElement()->Attribute("bold");
|
||||
if (NULL != bold) {
|
||||
if(0 == strcmp(bold, "yes") ) {
|
||||
myNewColor->SetBold(true);
|
||||
}
|
||||
}
|
||||
const char *italic = pGuiNode->ToElement()->Attribute("italic");
|
||||
if (NULL != italic) {
|
||||
if(0 == strcmp(italic, "yes") ) {
|
||||
myNewColor->SetItalic(true);
|
||||
}
|
||||
}
|
||||
listMyColor.PushBack(myNewColor);
|
||||
} else {
|
||||
APPL_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [color]");
|
||||
}
|
||||
pGuiNode = pGuiNode->NextSibling();
|
||||
}
|
||||
} else {
|
||||
APPL_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [gui,syntax]");
|
||||
}
|
||||
// get next node element
|
||||
pNode = pNode->NextSibling();
|
||||
}
|
||||
}
|
||||
if (NULL != fileBuffer) {
|
||||
delete[] fileBuffer;
|
||||
}
|
||||
//SendMessage(APPL_MSG__COLOR_HAS_CHANGE);
|
||||
//SendMessage(APPL_MSG__USER_DISPLAY_CHANGE);
|
||||
}
|
||||
|
||||
// TODO : Remove this ...
|
||||
Colorize *classColorManager::Get(const char *colorName)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listMyColor.Size(); i++) {
|
||||
etk::UString elementName = listMyColor[i]->GetName();
|
||||
if (elementName == colorName) {
|
||||
return listMyColor[i];
|
||||
}
|
||||
}
|
||||
APPL_ERROR(PFX"Color does not Existed ["<< colorName<<"]" );
|
||||
// an error
|
||||
return errorColor;
|
||||
}
|
||||
|
||||
Colorize *classColorManager::Get(etk::UString &colorName)
|
||||
{
|
||||
// TODO : Remove this
|
||||
return Get(colorName.c_str());
|
||||
}
|
||||
|
||||
draw::Color & classColorManager::Get(basicColor_te myColor)
|
||||
{
|
||||
if (myColor < COLOR_NUMBER_MAX) {
|
||||
return basicColors[myColor];
|
||||
} else {
|
||||
return basicColors[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO : Remove this ...
|
||||
bool classColorManager::Exist(const char *colorName)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listMyColor.Size(); i++) {
|
||||
etk::UString elementName = listMyColor[i]->GetName();
|
||||
if (elementName == colorName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool classColorManager::Exist(etk::UString &colorName)
|
||||
{
|
||||
// TODO : Remove this
|
||||
return Exist(colorName.c_str());
|
||||
}
|
||||
|
||||
void classColorManager::DisplayListOfColor(void)
|
||||
{
|
||||
int32_t i;
|
||||
APPL_INFO(PFX"List of ALL COLOR : ");
|
||||
for (i=0; i<listMyColor.Size(); i++) {
|
||||
//etk::UString elementName = listMyColor[i]->GetName();
|
||||
//APPL_INFO(i << " : \"" << elementName.c_str() << "\"" );
|
||||
listMyColor[i]->Display(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static classColorManager * localManager = NULL;
|
||||
|
||||
|
||||
void ColorizeManager::Init(void)
|
||||
{
|
||||
if (NULL != localManager) {
|
||||
EWOL_ERROR("ColorizeManager ==> already exist, just unlink the previous ...");
|
||||
localManager = NULL;
|
||||
}
|
||||
localManager = new classColorManager();
|
||||
|
||||
if (NULL == localManager) {
|
||||
EWOL_CRITICAL("Allocation of HighlightManager not done ...");
|
||||
}
|
||||
}
|
||||
|
||||
void ColorizeManager::UnInit(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("ColorizeManager ==> request UnInit, but does not exist ...");
|
||||
return;
|
||||
}
|
||||
delete(localManager);
|
||||
localManager = NULL;
|
||||
}
|
||||
|
||||
void ColorizeManager::LoadFile(etk::UString &xmlFilename)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return;
|
||||
}
|
||||
localManager->LoadFile(xmlFilename);
|
||||
}
|
||||
|
||||
|
||||
void ColorizeManager::LoadFile(const char * xmlFilename)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return;
|
||||
}
|
||||
localManager->LoadFile(xmlFilename);
|
||||
}
|
||||
|
||||
Colorize* ColorizeManager::Get(const char *colorName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return NULL;
|
||||
}
|
||||
return localManager->Get(colorName);
|
||||
}
|
||||
|
||||
Colorize* ColorizeManager::Get(etk::UString &colorName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return NULL;
|
||||
}
|
||||
return localManager->Get(colorName);
|
||||
}
|
||||
|
||||
draw::Color errorColor;
|
||||
|
||||
draw::Color& ColorizeManager::Get(basicColor_te myColor)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return errorColor;
|
||||
}
|
||||
return localManager->Get(myColor);
|
||||
}
|
||||
|
||||
bool ColorizeManager::Exist(etk::UString &colorName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return false;
|
||||
}
|
||||
return localManager->Exist(colorName);
|
||||
}
|
||||
|
||||
bool ColorizeManager::Exist(const char *colorName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return false;
|
||||
}
|
||||
return localManager->Exist(colorName);
|
||||
}
|
||||
|
||||
void ColorizeManager::DisplayListOfColor(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return;
|
||||
}
|
||||
localManager->DisplayListOfColor();
|
||||
}
|
||||
|
||||
|
67
sources/appl/Colorize/ColorizeManager.h
Normal file
67
sources/appl/Colorize/ColorizeManager.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ColorizeManager.h
|
||||
* @brief Editeur De N'ours : Colorising Manager (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __COLORIZE_MANAGER_H__
|
||||
#define __COLORIZE_MANAGER_H__
|
||||
|
||||
#include <Colorize.h>
|
||||
#include <appl/globalMsg.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
|
||||
typedef enum {
|
||||
// BASIC color for codeViewer
|
||||
COLOR_CODE_SPACE,
|
||||
COLOR_CODE_TAB,
|
||||
COLOR_CODE_BASIC_BG,
|
||||
COLOR_CODE_CURSOR,
|
||||
COLOR_CODE_LINE_NUMBER,
|
||||
// Basic color for list viewer
|
||||
COLOR_LIST_BG_1,
|
||||
COLOR_LIST_BG_2,
|
||||
COLOR_LIST_BG_SELECTED,
|
||||
COLOR_LIST_TEXT_NORMAL,
|
||||
COLOR_LIST_TEXT_MODIFY,
|
||||
// KNOW the number of BASIC color
|
||||
COLOR_NUMBER_MAX,
|
||||
}basicColor_te;
|
||||
|
||||
|
||||
|
||||
namespace ColorizeManager
|
||||
{
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
void LoadFile(etk::UString &xmlFilename);
|
||||
void LoadFile(const char * xmlFilename);
|
||||
Colorize * Get(const char *colorName);
|
||||
Colorize * Get(etk::UString &colorName);
|
||||
draw::Color& Get(basicColor_te myColor);
|
||||
bool Exist(etk::UString &colorName);
|
||||
bool Exist(const char *colorName);
|
||||
void DisplayListOfColor(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
27
sources/appl/Debug.cpp
Normal file
27
sources/appl/Debug.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Debug.h
|
||||
* @brief Editeur De N'ours : log implementation
|
||||
* @author Edouard DUPIN
|
||||
* @date 08/06/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
const char * applLog = "edn ";
|
44
sources/appl/Debug.h
Normal file
44
sources/appl/Debug.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Debug.h
|
||||
* @brief Application log implementation
|
||||
* @author Edouard DUPIN
|
||||
* @date 10/04/2012
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __DEBUG_H__
|
||||
#define __DEBUG_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <etk/Debug.h>
|
||||
|
||||
extern const char * applLog;
|
||||
|
||||
#define APPL_CRITICAL(data) ETK_CRITICAL(applLog, data)
|
||||
#define APPL_WARNING(data) ETK_WARNING(applLog, data)
|
||||
#define APPL_ERROR(data) ETK_ERROR(applLog, data)
|
||||
#define APPL_INFO(data) ETK_INFO(applLog, data)
|
||||
#define APPL_DEBUG(data) ETK_DEBUG(applLog, data)
|
||||
#define APPL_VERBOSE(data) ETK_VERBOSE(applLog, data)
|
||||
#define APPL_ASSERT(cond, data) ETK_ASSERT(applLog, cond, data)
|
||||
#define APPL_CHECK_INOUT(cond) ETK_CHECK_INOUT(applLog, cond)
|
||||
#define APPL_TODO(cond) ETK_TODO(applLog, cond)
|
||||
|
||||
#endif
|
211
sources/appl/Gui/BufferView.cpp
Normal file
211
sources/appl/Gui/BufferView.cpp
Normal file
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferViewer.cpp
|
||||
* @brief Editeur De N'ours : main textViewer diplayer
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <BufferView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <MainWindows.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "BufferView"
|
||||
|
||||
|
||||
|
||||
static void SortElementList(etk::Vector<appl::dataBufferStruct *> &list)
|
||||
{
|
||||
etk::Vector<appl::dataBufferStruct *> tmpList = list;
|
||||
list.Clear();
|
||||
for(int32_t iii=0; iii<tmpList.Size(); iii++) {
|
||||
if (NULL != tmpList[iii]) {
|
||||
int32_t findPos = 0;
|
||||
for(int32_t jjj=0; jjj<list.Size(); jjj++) {
|
||||
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
||||
if (list[jjj]!=NULL) {
|
||||
if (tmpList[iii]->m_bufferName.GetNameFile() > list[jjj]->m_bufferName.GetNameFile()) {
|
||||
findPos = jjj+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
//EWOL_DEBUG("position="<<findPos);
|
||||
list.Insert(findPos, tmpList[iii]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BufferView::BufferView(void)
|
||||
{
|
||||
SetCanHaveFocus(true);
|
||||
RegisterMultiCast(ednMsgBufferListChange);
|
||||
RegisterMultiCast(ednMsgBufferState);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
m_selectedID = -1;
|
||||
m_selectedIdRequested = -1;
|
||||
}
|
||||
|
||||
BufferView::~BufferView(void)
|
||||
{
|
||||
RemoveAllElement();
|
||||
}
|
||||
|
||||
void BufferView::RemoveAllElement(void)
|
||||
{
|
||||
for(int32_t iii=0; iii<m_list.Size(); iii++) {
|
||||
if (NULL!=m_list[iii]) {
|
||||
delete(m_list[iii]);
|
||||
m_list[iii] = NULL;
|
||||
}
|
||||
}
|
||||
m_list.Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void BufferView::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::List::OnReceiveMessage(CallerObject, eventId, data);
|
||||
if (eventId == ednMsgBufferListChange) {
|
||||
// clean The list
|
||||
RemoveAllElement();
|
||||
// Get all the buffer name and properties:
|
||||
int32_t nbBufferOpen = BufferManager::Size();
|
||||
for (int32_t iii=0; iii<nbBufferOpen; iii++) {
|
||||
if (BufferManager::Exist(iii)) {
|
||||
bool isModify = BufferManager::Get(iii)->IsModify();
|
||||
etk::FSNode name = BufferManager::Get(iii)->GetFileName();
|
||||
appl::dataBufferStruct* tmpElement = new appl::dataBufferStruct(name, iii, isModify);
|
||||
if (NULL != tmpElement) {
|
||||
m_list.PushBack(tmpElement);
|
||||
} else {
|
||||
APPL_ERROR("Allocation error of the tmp buffer list element");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (true == globals::OrderTheBufferList() ) {
|
||||
SortElementList(m_list);
|
||||
}
|
||||
MarkToRedraw();
|
||||
}else if (eventId == ednMsgBufferId) {
|
||||
m_selectedIdRequested = BufferManager::GetSelected();
|
||||
MarkToRedraw();
|
||||
}else if (eventId == ednMsgBufferState) {
|
||||
// Update list of modify section ...
|
||||
for (int32_t iii=0; iii<m_list.Size(); iii++) {
|
||||
if (NULL!=m_list[iii]) {
|
||||
m_list[iii]->m_isModify = BufferManager::Get(m_list[iii]->m_bufferID)->IsModify();
|
||||
}
|
||||
}
|
||||
MarkToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
draw::Color BufferView::GetBasicBG(void)
|
||||
{
|
||||
return ColorizeManager::Get(COLOR_LIST_BG_1);
|
||||
}
|
||||
|
||||
uint32_t BufferView::GetNuberOfColomn(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool BufferView::GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg)
|
||||
{
|
||||
myTitle = "Buffers : ";
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t BufferView::GetNuberOfRaw(void)
|
||||
{
|
||||
return m_list.Size();
|
||||
}
|
||||
|
||||
bool BufferView::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg)
|
||||
{
|
||||
bool isModify;
|
||||
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
basicColor_te selectBG = COLOR_LIST_BG_1;
|
||||
// when requested a new display selection ==> reset the previous one ...
|
||||
if (m_selectedIdRequested != -1) {
|
||||
m_selectedID = -1;
|
||||
}
|
||||
if( raw>=0
|
||||
&& raw<m_list.Size()
|
||||
&& NULL != m_list[raw]) {
|
||||
myTextToWrite = m_list[raw]->m_bufferName.GetNameFile();
|
||||
|
||||
if (true == m_list[raw]->m_isModify) {
|
||||
selectFG = COLOR_LIST_TEXT_MODIFY;
|
||||
} else {
|
||||
selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
}
|
||||
if (raw%2==0) {
|
||||
selectBG = COLOR_LIST_BG_1;
|
||||
} else {
|
||||
selectBG = COLOR_LIST_BG_2;
|
||||
}
|
||||
// the buffer change of selection ...
|
||||
if (m_selectedIdRequested == m_list[raw]->m_bufferID) {
|
||||
m_selectedID = raw;
|
||||
// stop searching
|
||||
m_selectedIdRequested = -1;
|
||||
}
|
||||
if (m_selectedID == raw) {
|
||||
selectBG = COLOR_LIST_BG_SELECTED;
|
||||
}
|
||||
} else {
|
||||
myTextToWrite = "ERROR";
|
||||
}
|
||||
fg = ColorizeManager::Get(selectFG);
|
||||
bg = ColorizeManager::Get(selectBG);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BufferView::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y)
|
||||
{
|
||||
if (1 == IdInput && typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
|
||||
APPL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
|
||||
if( raw>=0
|
||||
&& raw<m_list.Size()
|
||||
&& NULL != m_list[raw]) {
|
||||
m_selectedID = raw;
|
||||
SendMultiCast(ednMsgBufferId, m_list[raw]->m_bufferID);
|
||||
}
|
||||
}
|
||||
MarkToRedraw();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
92
sources/appl/Gui/BufferView.h
Normal file
92
sources/appl/Gui/BufferView.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferView.h
|
||||
* @brief Editeur De N'ours : main List Buffer Viewer (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 09/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef __BUFFER_VIEW_H__
|
||||
#define __BUFFER_VIEW_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <CodeView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <appl/globalMsg.h>
|
||||
#include <ewol/widget/List.h>
|
||||
|
||||
namespace appl
|
||||
{
|
||||
class dataBufferStruct
|
||||
{
|
||||
public:
|
||||
etk::FSNode m_bufferName;
|
||||
uint32_t m_bufferID;
|
||||
bool m_isModify;
|
||||
dataBufferStruct(etk::FSNode& bufferName, int32_t bufferID, bool isModify) :
|
||||
m_bufferName(bufferName),
|
||||
m_bufferID(bufferID),
|
||||
m_isModify(isModify)
|
||||
{
|
||||
|
||||
};
|
||||
~dataBufferStruct(void) { };
|
||||
};
|
||||
};
|
||||
|
||||
class BufferView : public ewol::List
|
||||
{
|
||||
private:
|
||||
int32_t m_selectedIdRequested;
|
||||
int32_t m_selectedID;
|
||||
etk::Vector<appl::dataBufferStruct*> m_list;
|
||||
public:
|
||||
// Constructeur
|
||||
BufferView(void);
|
||||
~BufferView(void);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void) { return "ApplBufferView"; };
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
protected:
|
||||
// function call to display the list :
|
||||
virtual draw::Color GetBasicBG(void);
|
||||
virtual uint32_t GetNuberOfColomn(void);
|
||||
virtual bool GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg);
|
||||
virtual uint32_t GetNuberOfRaw(void);
|
||||
virtual bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg);
|
||||
virtual bool OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y);
|
||||
void RemoveAllElement(void);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
475
sources/appl/Gui/CodeView.cpp
Normal file
475
sources/appl/Gui/CodeView.cpp
Normal file
@@ -0,0 +1,475 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file CodeView.cpp
|
||||
* @brief Editeur De N'ours : Code Viewer Widget
|
||||
* This is an abstraction
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <CodeView.h>
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <CodeView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <ewol/ClipBoard.h>
|
||||
#include <SearchData.h>
|
||||
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "CodeView"
|
||||
|
||||
void CodeView::Init(void)
|
||||
{
|
||||
m_label = "CodeView is disable ...";
|
||||
|
||||
m_bufferID = -1;
|
||||
m_buttunOneSelected = false;
|
||||
|
||||
m_lineNumberList.Clear();
|
||||
|
||||
m_textColorFg = draw::color::black;
|
||||
|
||||
m_textColorBg = draw::color::black;
|
||||
m_textColorBg.a = 0x40;
|
||||
SetCanHaveFocus(true);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
RegisterMultiCast(ednMsgGuiCopy);
|
||||
RegisterMultiCast(ednMsgGuiPaste);
|
||||
RegisterMultiCast(ednMsgGuiCut);
|
||||
RegisterMultiCast(ednMsgGuiRedo);
|
||||
RegisterMultiCast(ednMsgGuiUndo);
|
||||
RegisterMultiCast(ednMsgGuiRm);
|
||||
RegisterMultiCast(ednMsgGuiSelect);
|
||||
RegisterMultiCast(ednMsgGuiChangeCharset);
|
||||
RegisterMultiCast(ednMsgGuiFind);
|
||||
RegisterMultiCast(ednMsgGuiReplace);
|
||||
RegisterMultiCast(ednMsgGuiGotoLine);
|
||||
SetLimitScrolling(0.2);
|
||||
|
||||
ShortCutAdd("ctrl+w", ednMsgGuiRm, "Line");
|
||||
ShortCutAdd("ctrl+shift+w", ednMsgGuiRm, "Paragraph");
|
||||
ShortCutAdd("ctrl+x", ednMsgGuiCut, "STD");
|
||||
ShortCutAdd("ctrl+c", ednMsgGuiCopy, "STD");
|
||||
ShortCutAdd("ctrl+v", ednMsgGuiPaste, "STD");
|
||||
ShortCutAdd("ctrl+a", ednMsgGuiSelect, "ALL");
|
||||
ShortCutAdd("ctrl+shift+a", ednMsgGuiSelect, "NONE");
|
||||
}
|
||||
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
CodeView::CodeView(etk::UString fontName, int32_t fontSize) :
|
||||
m_OObjectText(fontName, fontSize)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
#endif
|
||||
|
||||
CodeView::CodeView(void)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
CodeView::~CodeView(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check if the number of reference buffer is good or not ...
|
||||
* @param[in] bufferID id of the current Buffer that needed to have a reference
|
||||
* @return ---
|
||||
*/
|
||||
void CodeView::UpdateNumberOfLineReference(int32_t bufferID)
|
||||
{
|
||||
etk::Vector2D<float> tmpCoord;
|
||||
tmpCoord.x = 0;
|
||||
tmpCoord.y = 0;
|
||||
if (m_lineNumberList.Size()<=bufferID) {
|
||||
// update the number of elements :
|
||||
for (int32_t iii=m_lineNumberList.Size(); iii <= bufferID; iii++) {
|
||||
// add start line at 0 :
|
||||
m_lineNumberList.PushBack(tmpCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CodeView::CalculateMinSize(void)
|
||||
{
|
||||
m_minSize.x = 50;
|
||||
m_minSize.y = 50;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CodeView::CalculateMaxSize(void)
|
||||
{
|
||||
m_maxSize.x = 2048;
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
int32_t letterHeight = m_OObjectText.GetHeight();
|
||||
#else
|
||||
int32_t letterHeight = m_OObjectTextNormal.GetHeight();
|
||||
#endif
|
||||
m_maxSize.y = BufferManager::Get(m_bufferID)->GetNumberOfLine() * letterHeight;
|
||||
}
|
||||
|
||||
|
||||
void CodeView::OnDraw(ewol::DrawProperty& displayProp)
|
||||
{
|
||||
m_OObjectsColored.Draw();
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
m_OObjectText.Draw();
|
||||
#else
|
||||
m_OObjectTextNormal.Draw();
|
||||
m_OObjectTextBold.Draw();
|
||||
m_OObjectTextItalic.Draw();
|
||||
m_OObjectTextBoldItalic.Draw();
|
||||
#endif
|
||||
WidgetScrooled::OnDraw(displayProp);
|
||||
}
|
||||
|
||||
void CodeView::OnRegenerateDisplay(void)
|
||||
{
|
||||
if (true == NeedRedraw()) {
|
||||
int64_t startTime = ewol::GetTime();
|
||||
|
||||
// For the scrooling windows
|
||||
CalculateMaxSize();
|
||||
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
m_OObjectText.Clear();
|
||||
#else
|
||||
m_OObjectTextNormal.Clear();
|
||||
m_OObjectTextBold.Clear();
|
||||
m_OObjectTextItalic.Clear();
|
||||
m_OObjectTextBoldItalic.Clear();
|
||||
#endif
|
||||
m_OObjectsColored.Clear();
|
||||
|
||||
|
||||
if(true == BufferManager::Get(m_bufferID)->NeedToUpdateDisplayPosition() ) {
|
||||
etk::Vector2D<float> borderWidth = BufferManager::Get(m_bufferID)->GetBorderSize();
|
||||
bool centerRequested = false;
|
||||
// TODO : set it back ...
|
||||
etk::Vector2D<float> currentPosition = BufferManager::Get(m_bufferID)->GetPosition(999/*m_OObjectTextNormal.GetFontID()*/, centerRequested);
|
||||
SetScrollingPositionDynamic(borderWidth, currentPosition, centerRequested);
|
||||
} // else : nothing to do ...
|
||||
|
||||
// generate the objects :
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
BufferManager::Get(m_bufferID)->Display(m_OObjectText,
|
||||
m_OObjectsColored,
|
||||
m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
|
||||
#else
|
||||
BufferManager::Get(m_bufferID)->Display(m_OObjectTextNormal,
|
||||
m_OObjectTextBold,
|
||||
m_OObjectTextItalic,
|
||||
m_OObjectTextBoldItalic,
|
||||
m_OObjectsColored,
|
||||
m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
|
||||
#endif
|
||||
// set the current size of the windows
|
||||
SetMaxSize(BufferManager::Get(m_bufferID)->GetMaxSize());
|
||||
|
||||
int64_t stopTime = ewol::GetTime();
|
||||
APPL_DEBUG("Display Code Generation = " << stopTime - startTime << " micro-s");
|
||||
|
||||
// call the herited class...
|
||||
WidgetScrooled::OnRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData)
|
||||
{
|
||||
//APPL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
|
||||
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
|
||||
BufferManager::Get(m_bufferID)->AddChar(unicodeData);
|
||||
MarkToRedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent)
|
||||
{
|
||||
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
|
||||
BufferManager::Get(m_bufferID)->cursorMove(moveTypeEvent);
|
||||
MarkToRedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas
|
||||
* @note : need to have focus ...
|
||||
* @param[in] mode Mode of data requested
|
||||
* @return ---
|
||||
*/
|
||||
void CodeView::OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
BufferManager::Get(m_bufferID)->Paste(clipboardID);
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event on an input of this Widget
|
||||
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
|
||||
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
|
||||
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
|
||||
* @param[in] pos Absolute position of the event
|
||||
* @return true the event is used
|
||||
* @return false the event is not used
|
||||
*/
|
||||
bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::eventInputType_te typeEvent, etk::Vector2D<float> pos)
|
||||
{
|
||||
etk::Vector2D<float> relativePos = RelativePosition(pos);
|
||||
// corection for the openGl abstraction
|
||||
//relativePos.y = m_size.y - relativePos.y;
|
||||
|
||||
etk::Vector2D<float> limitedPos = relativePos;
|
||||
limitedPos.x = etk_avg(1, limitedPos.x, m_size.x-1);
|
||||
limitedPos.y = etk_avg(1, limitedPos.y, m_size.y-1);
|
||||
|
||||
if (m_bufferID < 0) {
|
||||
return false;
|
||||
}
|
||||
if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) {
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
// nothing to do ... done on upper widget ...
|
||||
return true;
|
||||
}
|
||||
if (1 == IdInput) {
|
||||
#ifndef __MODE__Touch
|
||||
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
|
||||
m_buttunOneSelected = true;
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
// TODO : Set something good
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(limitedPos);
|
||||
MarkToRedraw();
|
||||
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
||||
m_buttunOneSelected = false;
|
||||
BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_SELECTION);
|
||||
MarkToRedraw();
|
||||
} else
|
||||
#endif
|
||||
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
||||
#ifdef __MODE__Touch
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(limitedPos);
|
||||
MarkToRedraw();
|
||||
#else
|
||||
// nothing to do ...
|
||||
#endif
|
||||
} else if (ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent) {
|
||||
BufferManager::Get(m_bufferID)->MouseEventDouble();
|
||||
MarkToRedraw();
|
||||
} else if (ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
|
||||
BufferManager::Get(m_bufferID)->MouseEventTriple();
|
||||
MarkToRedraw();
|
||||
} else if (ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
|
||||
if (true == m_buttunOneSelected) {
|
||||
int xxx, yyy;
|
||||
xxx = relativePos.x;
|
||||
yyy = relativePos.y;
|
||||
if (xxx<0) {
|
||||
xxx = 0;
|
||||
}
|
||||
if (yyy<0) {
|
||||
yyy = 0;
|
||||
}
|
||||
//APPL_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
|
||||
// TODO : Set something good
|
||||
BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(limitedPos);
|
||||
MarkToRedraw();
|
||||
}
|
||||
}
|
||||
} else if (2 == IdInput) {
|
||||
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
||||
// TODO : Set something good
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(limitedPos);
|
||||
ewol::clipBoard::Request(ewol::clipBoard::CLIPBOARD_SELECTION);
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void CodeView::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::WidgetScrooled::OnReceiveMessage(CallerObject, eventId, data);
|
||||
APPL_DEBUG("Extern Event : " << CallerObject << " type : " << eventId << " data=\"" << data << "\"");
|
||||
|
||||
if(eventId == ednMsgBufferId) {
|
||||
//keep the reference of the display offset :
|
||||
if( m_bufferID >=0
|
||||
&& m_bufferID < m_lineNumberList.Size()) {
|
||||
m_lineNumberList[m_bufferID] = m_originScrooled;
|
||||
}
|
||||
int32_t bufferID = 0;
|
||||
sscanf(data.c_str(), "%d", &bufferID);
|
||||
APPL_INFO("Select a new Buffer ... " << bufferID);
|
||||
// set the new buffer ID
|
||||
m_bufferID = bufferID;
|
||||
// update the start display position...
|
||||
UpdateNumberOfLineReference(m_bufferID);
|
||||
// set back if needed the display position ...
|
||||
if( m_bufferID >=0
|
||||
&& m_bufferID < m_lineNumberList.Size()) {
|
||||
m_originScrooled = m_lineNumberList[m_bufferID];
|
||||
}
|
||||
} else if (eventId == ednMsgGuiCopy) {
|
||||
BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_STD);
|
||||
} else if (eventId == ednMsgGuiCut) {
|
||||
BufferManager::Get(m_bufferID)->Cut(ewol::clipBoard::CLIPBOARD_STD);
|
||||
} else if (eventId == ednMsgGuiPaste) {
|
||||
ewol::clipBoard::Request(ewol::clipBoard::CLIPBOARD_STD);
|
||||
} else if (eventId == ednMsgGuiUndo) {
|
||||
BufferManager::Get(m_bufferID)->Undo();
|
||||
} else if (eventId == ednMsgGuiRedo) {
|
||||
BufferManager::Get(m_bufferID)->Redo();
|
||||
} else if (eventId == ednMsgGuiRm) {
|
||||
// data : "Word" "Line" "Paragraph"
|
||||
if (data == "Word") {
|
||||
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
|
||||
} else if (data == "Line") {
|
||||
BufferManager::Get(m_bufferID)->RemoveLine();
|
||||
} else if (data == "Paragraph") {
|
||||
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
|
||||
} else {
|
||||
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
||||
}
|
||||
} else if (eventId == ednMsgGuiSelect) {
|
||||
// data : "ALL" "NONE"
|
||||
if (data == "ALL") {
|
||||
BufferManager::Get(m_bufferID)->SelectAll();
|
||||
} else if (data == "NONE") {
|
||||
BufferManager::Get(m_bufferID)->SelectNone();
|
||||
} else {
|
||||
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
||||
}
|
||||
} else if (eventId == ednMsgGuiChangeCharset) {
|
||||
// data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
|
||||
if (data == "UTF-8") {
|
||||
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_UTF8);
|
||||
} else if (data == "ISO-8859-1") {
|
||||
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_ISO_8859_1);
|
||||
} else if (data == "ISO-8859-15") {
|
||||
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_ISO_8859_15);
|
||||
} else {
|
||||
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
||||
}
|
||||
} else if (eventId == ednMsgGuiFind) {
|
||||
etk::UString myDataString;
|
||||
SearchData::GetSearch(myDataString);
|
||||
if (data == "Next") {
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
} else if (data == "Previous") {
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
}
|
||||
} else if (eventId == ednMsgGuiReplace) {
|
||||
etk::UString myDataString;
|
||||
SearchData::GetReplace(myDataString);
|
||||
if (data == "Normal") {
|
||||
BufferManager::Get(m_bufferID)->Replace(myDataString);
|
||||
} else if (data == "All") {
|
||||
|
||||
}
|
||||
} else if (eventId == ednMsgGuiGotoLine) {
|
||||
int32_t lineID = 0;
|
||||
sscanf(data.c_str(), "%d", &lineID);
|
||||
APPL_INFO("Goto line : " << lineID);
|
||||
BufferManager::Get(m_bufferID)->JumpAtLine(lineID);
|
||||
}
|
||||
// Force redraw of the widget
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
|
||||
void CodeView::OnGetFocus(void)
|
||||
{
|
||||
/*
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_bufferID);
|
||||
*/
|
||||
ewol::KeyboardShow();
|
||||
APPL_INFO("Focus - In");
|
||||
}
|
||||
|
||||
|
||||
void CodeView::OnLostFocus(void)
|
||||
{
|
||||
ewol::KeyboardHide();
|
||||
APPL_INFO("Focus - out");
|
||||
}
|
||||
|
||||
void CodeView::SetFontSize(int32_t size)
|
||||
{
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
m_OObjectText.SetSize(size);
|
||||
#else
|
||||
m_OObjectTextNormal.SetSize(size);
|
||||
m_OObjectTextBold.SetSize(size);
|
||||
m_OObjectTextItalic.SetSize(size);
|
||||
m_OObjectTextBoldItalic.SetSize(size);
|
||||
#endif
|
||||
SetScrollingSize(size*3.0*1.46); // 1.46 is a magic nmber ...
|
||||
}
|
||||
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
void CodeView::SetFontName(etk::UString fontName)
|
||||
{
|
||||
m_OObjectText.SetFont(fontName);
|
||||
}
|
||||
#else
|
||||
void CodeView::SetFontNameNormal(etk::UString fontName)
|
||||
{
|
||||
m_OObjectTextNormal.SetFont(fontName);
|
||||
}
|
||||
|
||||
void CodeView::SetFontNameBold(etk::UString fontName)
|
||||
{
|
||||
m_OObjectTextBold.SetFont(fontName);
|
||||
}
|
||||
|
||||
void CodeView::SetFontNameItalic(etk::UString fontName)
|
||||
{
|
||||
m_OObjectTextItalic.SetFont(fontName);
|
||||
}
|
||||
|
||||
void CodeView::SetFontNameBoldItalic(etk::UString fontName)
|
||||
{
|
||||
m_OObjectTextBoldItalic.SetFont(fontName);
|
||||
}
|
||||
#endif
|
||||
|
124
sources/appl/Gui/CodeView.h
Normal file
124
sources/appl/Gui/CodeView.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file CodeView.h
|
||||
* @brief Editeur De N'ours : Code Viewer Widget (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __CODE_VIEW_H__
|
||||
#define __CODE_VIEW_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <CodeView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <appl/globalMsg.h>
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/widget/WidgetScrolled.h>
|
||||
#include <ewol/ResourceManager.h>
|
||||
|
||||
class CodeView :public ewol::WidgetScrooled
|
||||
{
|
||||
public:
|
||||
void Init(void);
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
CodeView(etk::UString fontName, int32_t fontSize);
|
||||
#endif
|
||||
CodeView(void);
|
||||
virtual ~CodeView(void);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void) { return "ApplCodeView"; };
|
||||
virtual bool CalculateMinSize(void);
|
||||
private:
|
||||
etk::UString m_label;
|
||||
draw::Color m_textColorFg; //!< Text color
|
||||
draw::Color m_textColorBg; //!< Background color
|
||||
int32_t m_bufferID;
|
||||
bool m_buttunOneSelected;
|
||||
etk::Vector<etk::Vector2D<float> > m_lineNumberList;
|
||||
void UpdateNumberOfLineReference(int32_t bufferID);
|
||||
// drawing elements :
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
ewol::TEXT_DISPLAY_TYPE m_OObjectText;
|
||||
#else
|
||||
ewol::TEXT_DISPLAY_TYPE m_OObjectTextNormal;
|
||||
ewol::TEXT_DISPLAY_TYPE m_OObjectTextBold;
|
||||
ewol::TEXT_DISPLAY_TYPE m_OObjectTextItalic;
|
||||
ewol::TEXT_DISPLAY_TYPE m_OObjectTextBoldItalic;
|
||||
#endif
|
||||
ewol::OObject2DColored m_OObjectsColored;
|
||||
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
public:
|
||||
/**
|
||||
* @brief Event on an input of this Widget
|
||||
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
|
||||
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
|
||||
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
|
||||
* @param[in] pos Absolute position of the event
|
||||
* @return true the event is used
|
||||
* @return false the event is not used
|
||||
*/
|
||||
virtual bool OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::eventInputType_te typeEvent, etk::Vector2D<float> pos);
|
||||
virtual bool OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData);
|
||||
virtual bool OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent);
|
||||
/**
|
||||
* @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas
|
||||
* @note : need to have focus ...
|
||||
* @param[in] mode Mode of data requested
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
|
||||
virtual void OnGetFocus(void);
|
||||
virtual void OnLostFocus(void);
|
||||
public:
|
||||
void SetFontSize(int32_t size);
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
void SetFontName(etk::UString fontName);
|
||||
#else
|
||||
void SetFontNameNormal(etk::UString fontName);
|
||||
void SetFontNameBold(etk::UString fontName);
|
||||
void SetFontNameItalic(etk::UString fontName);
|
||||
void SetFontNameBoldItalic(etk::UString fontName);
|
||||
#endif
|
||||
private:
|
||||
void CalculateMaxSize(void);
|
||||
protected:
|
||||
virtual void OnDraw(ewol::DrawProperty& displayProp);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
442
sources/appl/Gui/MainWindows.cpp
Normal file
442
sources/appl/Gui/MainWindows.cpp
Normal file
@@ -0,0 +1,442 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MainWindows.cpp
|
||||
* @brief Editeur De N'ours : main Windows diplayer (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <MainWindows.h>
|
||||
#include <CodeView.h>
|
||||
#include <BufferView.h>
|
||||
#include <Search.h>
|
||||
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/ContextMenu.h>
|
||||
#include <ewol/widget/PopUp.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/widget/Slider.h>
|
||||
#include <ewol/widget/Menu.h>
|
||||
#include <ewol/widget/meta/FileChooser.h>
|
||||
#include <ewol/widget/meta/Parameter.h>
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
#include <ewol/ResourceManager.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
|
||||
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "AboutGui"
|
||||
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
|
||||
class ParameterAboutGui : public ewol::SizerVert
|
||||
{
|
||||
public :
|
||||
ParameterAboutGui(void)
|
||||
{
|
||||
ewol::Spacer* mySpacer = NULL;
|
||||
|
||||
mySpacer = new ewol::Spacer();
|
||||
if (NULL == mySpacer) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
mySpacer->SetExpendX(true);
|
||||
mySpacer->SetExpendY(true);
|
||||
SubWidgetAdd(mySpacer);
|
||||
}
|
||||
AddElement(" libPng");
|
||||
AddElement(" ogg-tremor");
|
||||
AddElement(" portaudio");
|
||||
AddElement(" libZip");
|
||||
AddElement(" tinyXml");
|
||||
AddElement(" freetype");
|
||||
AddElement(" agg2.4");
|
||||
AddElement(" etk (BSD)");
|
||||
AddElement(" ewol is based on");
|
||||
AddElement(" Website : https://github.com/HeeroYui/ewol");
|
||||
AddElement(" Licence : BSD like");
|
||||
AddElement(" Copyright 2010 Edouard DUPIN, all right reserved");
|
||||
AddElement(" Supported OS : Linux, Windows, Android" );
|
||||
AddElement(etk::UString(" OpenGl librairy : v") + ewol::GetVersion() );
|
||||
AddElement("Ewol", true);
|
||||
AddElement("");
|
||||
AddElement(" Website : https://github.com/HeeroYui/edn");
|
||||
AddElement(" Licence : GPL");
|
||||
AddElement(" Copyright 2010 Edouard DUPIN, all right reserved");
|
||||
AddElement(etk::UString(" Build Time : ") + etk::UString(BUILD_TIME));
|
||||
AddElement(" Source Code Editor");
|
||||
AddElement(etk::UString(" Editeur De N'ours : v") + etk::UString(APPL_VERSION_TAG_NAME));
|
||||
AddElement("Edn", true);
|
||||
|
||||
};
|
||||
|
||||
~ParameterAboutGui(void) { };
|
||||
|
||||
void AddElement(etk::UString label, bool bold=false, bool italic=false)
|
||||
{
|
||||
ewol::Label* myLabel = new ewol::Label(label);
|
||||
if (NULL == myLabel) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
myLabel->SetExpendX(true);
|
||||
SubWidgetAdd(myLabel);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
const char * l_smoothChick = "tmpEvent_smooth";
|
||||
const char * l_smoothMin = "tmpEvent_minChange";
|
||||
const char * l_smoothMax = "tmpEvent_maxChange";
|
||||
|
||||
|
||||
extern float DF_SoftEdge_min;
|
||||
extern float DF_SoftEdge_max;
|
||||
extern int32_t DF_SoftEdge;
|
||||
ewol::Slider* tmpSliderMin = NULL;
|
||||
ewol::Slider* tmpSliderMax = NULL;
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "MainWindows"
|
||||
|
||||
MainWindows::MainWindows(void)
|
||||
{
|
||||
APPL_DEBUG("CREATE WINDOWS ... ");
|
||||
ewol::SizerVert * mySizerVert = NULL;
|
||||
ewol::SizerVert * mySizerVert2 = NULL;
|
||||
ewol::SizerHori * mySizerHori = NULL;
|
||||
//ewol::Button * myButton = NULL;
|
||||
CodeView * myCodeView = NULL;
|
||||
BufferView * myBufferView = NULL;
|
||||
ewol::Menu * myMenu = NULL;
|
||||
|
||||
mySizerVert = new ewol::SizerVert();
|
||||
SetSubWidget(mySizerVert);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
myBufferView = new BufferView();
|
||||
myBufferView->SetExpendX(false);
|
||||
myBufferView->SetExpendY(true);
|
||||
myBufferView->SetFillX(true);
|
||||
myBufferView->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myBufferView);
|
||||
|
||||
mySizerVert2 = new ewol::SizerVert();
|
||||
mySizerHori->SubWidgetAdd(mySizerVert2);
|
||||
|
||||
// main buffer Area :
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
myCodeView = new CodeView("Font/freefont/FreeMono.ttf", 24);
|
||||
#else
|
||||
myCodeView = new CodeView();
|
||||
#endif
|
||||
myCodeView->SetExpendX(true);
|
||||
myCodeView->SetExpendY(true);
|
||||
myCodeView->SetFillX(true);
|
||||
myCodeView->SetFillY(true);
|
||||
#ifndef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
myCodeView->SetFontSize(11);
|
||||
myCodeView->SetFontNameNormal( "Font/freefont/FreeMono.ttf");
|
||||
myCodeView->SetFontNameBold( "Font/freefont/FreeMonoBold.ttf");
|
||||
myCodeView->SetFontNameItalic( "Font/freefont/FreeMonoOblique.ttf");
|
||||
myCodeView->SetFontNameBoldItalic("Font/freefont/FreeMonoBoldOblique.ttf");
|
||||
#endif
|
||||
mySizerVert2->SubWidgetAdd(myCodeView);
|
||||
|
||||
// search area :
|
||||
Search * mySearch = new Search();
|
||||
mySizerVert2->SubWidgetAdd(mySearch);
|
||||
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
|
||||
{
|
||||
ewol::SizerHori * mySizerHori2 = new ewol::SizerHori();
|
||||
mySizerVert2->SubWidgetAdd(mySizerHori2);
|
||||
|
||||
ewol::CheckBox* tmpCheck = new ewol::CheckBox("smooth");
|
||||
mySizerHori2->SubWidgetAdd(tmpCheck);
|
||||
tmpCheck->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_smoothChick);
|
||||
|
||||
ewol::Slider* tmpSlider = new ewol::Slider();
|
||||
mySizerHori2->SubWidgetAdd(tmpSlider);
|
||||
tmpSlider->RegisterOnEvent(this, ewolEventSliderChange, l_smoothMin);
|
||||
tmpSlider->SetExpendX(true);
|
||||
tmpSlider->SetMin(0);
|
||||
tmpSlider->SetMax(1000);
|
||||
tmpSlider->SetValue(0450);
|
||||
tmpSliderMin = tmpSlider;
|
||||
|
||||
tmpSlider = new ewol::Slider();
|
||||
mySizerHori2->SubWidgetAdd(tmpSlider);
|
||||
tmpSlider->RegisterOnEvent(this, ewolEventSliderChange, l_smoothMax);
|
||||
tmpSlider->SetExpendX(true);
|
||||
tmpSlider->SetMin(0);
|
||||
tmpSlider->SetMax(1000);
|
||||
tmpSlider->SetValue(0550);
|
||||
tmpSliderMax = tmpSlider;
|
||||
}
|
||||
#endif
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
|
||||
myMenu = new ewol::Menu();
|
||||
mySizerHori->SubWidgetAdd(myMenu);
|
||||
int32_t idMenuFile = myMenu->AddTitle("File");
|
||||
(void)myMenu->Add(idMenuFile, "New", "", ednMsgGuiNew);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuFile, "Open", "icon/Load.svg", ednMsgGuiOpen);
|
||||
(void)myMenu->Add(idMenuFile, "Close", "icon/Close.svg", ednMsgGuiClose, "current");
|
||||
(void)myMenu->Add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All");
|
||||
(void)myMenu->Add(idMenuFile, "Save", "icon/Save.svg", ednMsgGuiSave, "current");
|
||||
(void)myMenu->Add(idMenuFile, "Save As ...", "", ednMsgGuiSaveAs);
|
||||
(void)myMenu->AddSpacer();
|
||||
//(void)myMenu->Add(idMenuFile, "Exit", "", ednMsgGuiExit);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuFile, "Properties", "icon/Parameter.svg", ednMsgProperties);
|
||||
int32_t idMenuEdit = myMenu->AddTitle("Edit");
|
||||
(void)myMenu->Add(idMenuEdit, "Undo", "icon/Undo.svg", ednMsgGuiUndo);
|
||||
(void)myMenu->Add(idMenuEdit, "Redo", "icon/Redo.svg", ednMsgGuiRedo);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuEdit, "Copy", "", ednMsgGuiCopy, "STD");
|
||||
(void)myMenu->Add(idMenuEdit, "Cut", "", ednMsgGuiCut, "STD");
|
||||
(void)myMenu->Add(idMenuEdit, "Paste", "", ednMsgGuiPaste, "STD");
|
||||
(void)myMenu->Add(idMenuEdit, "Remove", "", ednMsgGuiRm);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuEdit, "Select All","", ednMsgGuiSelect, "ALL");
|
||||
(void)myMenu->Add(idMenuEdit, "Un-Select","", ednMsgGuiSelect, "NONE");
|
||||
(void)myMenu->Add(idMenuEdit, "Goto line ...","", ednMsgGuiGotoLine, "???");
|
||||
int32_t idMenuSearch = myMenu->AddTitle("Search");
|
||||
(void)myMenu->Add(idMenuSearch, "Search", "icon/Search.svg", ednMsgGuiSearch);
|
||||
(void)myMenu->Add(idMenuSearch, "Replace", "icon/Replace.svg", ednMsgGuiReplace);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuSearch, "Find (previous)","", ednMsgGuiFind, "Previous");
|
||||
(void)myMenu->Add(idMenuSearch, "Find (next)", "", ednMsgGuiFind, "Next");
|
||||
(void)myMenu->Add(idMenuSearch, "Find (all)", "", ednMsgGuiFind, "All");
|
||||
(void)myMenu->Add(idMenuSearch, "Un-Select", "", ednMsgGuiFind, "None");
|
||||
int32_t idMenuCTags = myMenu->AddTitle("C-tags");
|
||||
(void)myMenu->Add(idMenuCTags, "Load", "", ednMsgGuiCtags, "Load");
|
||||
(void)myMenu->Add(idMenuCTags, "ReLoad", "", ednMsgGuiCtags, "ReLoad");
|
||||
(void)myMenu->Add(idMenuCTags, "Jump", "", ednMsgGuiCtags, "Jump");
|
||||
(void)myMenu->Add(idMenuCTags, "Back", "", ednMsgGuiCtags, "Back");
|
||||
int32_t idMenugDisplay = myMenu->AddTitle("Display");
|
||||
(void)myMenu->Add(idMenugDisplay, "Charset UTF-8", "", ednMsgGuiChangeCharset, "UTF-8");
|
||||
(void)myMenu->Add(idMenugDisplay, "Charset ISO-8859-1", "", ednMsgGuiChangeCharset, "ISO-8859-1");
|
||||
(void)myMenu->Add(idMenugDisplay, "Charset ISO-8859-15", "", ednMsgGuiChangeCharset, "ISO-8859-15");
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenugDisplay, "Color Black", "", ednMsgGuiChangeColor, "Black");
|
||||
(void)myMenu->Add(idMenugDisplay, "Color White", "", ednMsgGuiChangeColor, "White");
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenugDisplay, "Reload OpenGl Shader", "", ednMsgGuiReloadShader);
|
||||
|
||||
m_widgetLabelFileName = new ewol::Label("FileName");
|
||||
m_widgetLabelFileName->SetExpendX(true);
|
||||
m_widgetLabelFileName->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(m_widgetLabelFileName);
|
||||
|
||||
// Generic event ...
|
||||
RegisterMultiCast(ednMsgGuiSaveAs);
|
||||
RegisterMultiCast(ednMsgProperties);
|
||||
RegisterMultiCast(ednMsgGuiOpen);
|
||||
// to update the title ...
|
||||
RegisterMultiCast(ednMsgBufferState);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
RegisterMultiCast(ednMsgGuiReloadShader);
|
||||
}
|
||||
|
||||
|
||||
MainWindows::~MainWindows(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
const char *const ednEventPopUpFileSelected = "edn-mainWindows-openSelected";
|
||||
const char *const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected";
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::Windows::OnReceiveMessage(CallerObject, eventId, data);
|
||||
|
||||
//APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
|
||||
// Open file Section ...
|
||||
if (eventId == ednMsgGuiOpen) {
|
||||
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
|
||||
tmpWidget->SetTitle("Open Files ...");
|
||||
tmpWidget->SetValidateLabel("Open");
|
||||
if (BufferManager::GetSelected()!=-1) {
|
||||
Buffer * myBuffer = BufferManager::Get(BufferManager::GetSelected());
|
||||
if (NULL!=myBuffer) {
|
||||
etk::FSNode tmpFile = myBuffer->GetFileName();
|
||||
tmpWidget->SetFolder(tmpFile.GetNameFolder());
|
||||
}
|
||||
}
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSelected);
|
||||
} else if (eventId == ednEventPopUpFileSelected) {
|
||||
APPL_DEBUG("Request opening the file : " << data);
|
||||
SendMultiCast(ednMsgOpenFile, data);
|
||||
} else if (eventId == ednMsgGuiSaveAs) {
|
||||
if (data == "") {
|
||||
APPL_ERROR("Null data for Save As file ... ");
|
||||
} else {
|
||||
m_currentSavingAsIdBuffer = -1;
|
||||
if (data == "current") {
|
||||
m_currentSavingAsIdBuffer = BufferManager::GetSelected();
|
||||
} else {
|
||||
sscanf(data.c_str(), "%d", &m_currentSavingAsIdBuffer);
|
||||
}
|
||||
|
||||
if (false == BufferManager::Exist(m_currentSavingAsIdBuffer)) {
|
||||
APPL_ERROR("Request saveAs on non existant Buffer ID=" << m_currentSavingAsIdBuffer);
|
||||
} else {
|
||||
Buffer * myBuffer = BufferManager::Get(m_currentSavingAsIdBuffer);
|
||||
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
|
||||
if (NULL == tmpWidget) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
tmpWidget->SetTitle("Save Files As...");
|
||||
tmpWidget->SetValidateLabel("Save");
|
||||
etk::UString folder = "/home/";
|
||||
etk::UString fileName = "";
|
||||
if (true == myBuffer->HaveName()) {
|
||||
etk::FSNode tmpName = myBuffer->GetFileName();
|
||||
folder = tmpName.GetNameFolder();
|
||||
fileName = tmpName.GetNameFile();
|
||||
}
|
||||
tmpWidget->SetFolder(folder);
|
||||
tmpWidget->SetFileName(fileName);
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSaveAs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (eventId == ednEventPopUpFileSaveAs) {
|
||||
// get the filename :
|
||||
etk::UString tmpData = data;
|
||||
APPL_DEBUG("Request Saving As file : " << tmpData);
|
||||
|
||||
BufferManager::Get(m_currentSavingAsIdBuffer)->SetFileName(tmpData);
|
||||
SendMultiCast(ednMsgGuiSave, m_currentSavingAsIdBuffer);
|
||||
} else if( eventId == ednMsgBufferState
|
||||
|| eventId == ednMsgBufferId) {
|
||||
// the buffer change we need to update the widget string
|
||||
Buffer* tmpBuffer = BufferManager::Get(BufferManager::GetSelected());
|
||||
if (NULL != tmpBuffer) {
|
||||
etk::FSNode compleateName = tmpBuffer->GetFileName();
|
||||
bool isModify = tmpBuffer->IsModify();
|
||||
etk::UString directName = compleateName.GetName();
|
||||
if (true == isModify) {
|
||||
directName += " *";
|
||||
}
|
||||
if (NULL == m_widgetLabelFileName) {
|
||||
return;
|
||||
}
|
||||
m_widgetLabelFileName->SetLabel(directName);
|
||||
etk::UString windowsTitle = "edn - ";
|
||||
windowsTitle += directName;
|
||||
ewol::SetTitle(windowsTitle);
|
||||
return;
|
||||
} else {
|
||||
m_widgetLabelFileName->SetLabel("");
|
||||
ewol::SetTitle("edn");
|
||||
}
|
||||
return;
|
||||
// TODO : Set the Title ....
|
||||
} else if (eventId == ednMsgProperties) {
|
||||
// Request the parameter GUI
|
||||
ewol::Parameter* tmpWidget = new ewol::Parameter();
|
||||
if (NULL == tmpWidget) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
tmpWidget->SetTitle("Properties");
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
tmpWidget->MenuAddGroup("Editor");
|
||||
ewol::Widget* tmpSubWidget = new globals::ParameterGlobalsGui();
|
||||
tmpWidget->MenuAdd("Editor", "", tmpSubWidget);
|
||||
tmpWidget->MenuAdd("Polices & Color", "", NULL);
|
||||
tmpWidget->MenuAdd("Highlight", "", NULL);
|
||||
tmpWidget->MenuAddGroup("Genral");
|
||||
tmpWidget->MenuAdd("Affichage", "", NULL);
|
||||
tmpSubWidget = new ParameterAboutGui();
|
||||
tmpWidget->MenuAdd("About", "", tmpSubWidget);
|
||||
}
|
||||
} else if (eventId == l_smoothChick) {
|
||||
if (data == "true") {
|
||||
DF_SoftEdge = 1;
|
||||
} else {
|
||||
DF_SoftEdge = 0;
|
||||
}
|
||||
} else if (eventId == l_smoothMin) {
|
||||
int32_t newVal = 0;
|
||||
sscanf(data.c_str(), "%d", &newVal);
|
||||
DF_SoftEdge_min = (float)newVal / 1000.0;
|
||||
if (DF_SoftEdge_min>DF_SoftEdge_max) {
|
||||
DF_SoftEdge_max = DF_SoftEdge_min;
|
||||
tmpSliderMax->SetValue(DF_SoftEdge_max*1000.0);
|
||||
}
|
||||
} else if (eventId == l_smoothMax) {
|
||||
int32_t newVal = 0;
|
||||
sscanf(data.c_str(), "%d", &newVal);
|
||||
DF_SoftEdge_max = (float)newVal / 1000.0;
|
||||
if (DF_SoftEdge_min>DF_SoftEdge_max) {
|
||||
DF_SoftEdge_min = DF_SoftEdge_max;
|
||||
tmpSliderMin->SetValue(DF_SoftEdge_min*1000.0);
|
||||
}
|
||||
} else if (eventId == ednMsgGuiReloadShader) {
|
||||
ewol::resource::ReLoadResources();
|
||||
ewol::ForceRedrawAll();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void MainWindows::OnObjectRemove(ewol::EObject * removeObject)
|
||||
{
|
||||
ewol::Windows::OnObjectRemove(removeObject);
|
||||
if (m_widgetLabelFileName == removeObject) {
|
||||
m_widgetLabelFileName = NULL;
|
||||
}
|
||||
}
|
73
sources/appl/Gui/MainWindows.h
Normal file
73
sources/appl/Gui/MainWindows.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MainWindows.h
|
||||
* @brief Editeur De N'ours : main Windows diplayer (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef __MAIN_WINDOWS_H__
|
||||
#define __MAIN_WINDOWS_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/globalMsg.h>
|
||||
|
||||
#include <CodeView.h>
|
||||
#include <BufferView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
|
||||
class MainWindows : public ewol::Windows
|
||||
{
|
||||
private:
|
||||
int32_t m_currentSavingAsIdBuffer;
|
||||
ewol::Label* m_widgetLabelFileName;
|
||||
public:
|
||||
// Constructeur
|
||||
MainWindows(void);
|
||||
~MainWindows(void);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void) { return "MainWindows"; };
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnObjectRemove(ewol::EObject * removeObject);
|
||||
};
|
||||
|
||||
#define EDN_CAST_MAIN_WINDOWS(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_MAIN_WINDOWS,MainWindows,curentPointer)
|
||||
|
||||
#endif
|
||||
|
||||
|
253
sources/appl/Gui/Search.cpp
Normal file
253
sources/appl/Gui/Search.cpp
Normal file
@@ -0,0 +1,253 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Search.cpp
|
||||
* @brief Editeur De N'ours : Search system
|
||||
* @author Edouard DUPIN
|
||||
* @date 03/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "appl/global.h"
|
||||
#include "Search.h"
|
||||
#include "SearchData.h"
|
||||
#include "BufferManager.h"
|
||||
#include "MainWindows.h"
|
||||
#include "appl/globalMsg.h"
|
||||
|
||||
#include <ewol/widget/ButtonImage.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Search"
|
||||
|
||||
const char* const l_eventSearchEntry = "appl-search-entry";
|
||||
const char* const l_eventSearchEntryEnter = "appl-search-entry-enter";
|
||||
const char* const l_eventReplaceEntry = "appl-replace-entry";
|
||||
const char* const l_eventReplaceEntryEnter = "appl-replace-entry-enter";
|
||||
const char* const l_eventSearchBt = "appl-search-button";
|
||||
const char* const l_eventReplaceBt = "appl-replace-button";
|
||||
const char* const l_eventCaseCb = "appl-case-sensitive-CheckBox";
|
||||
const char* const l_eventWrapCb = "appl-wrap-CheckBox";
|
||||
const char* const l_eventForwardCb = "appl-forward-CheckBox";
|
||||
const char* const l_eventHideBt = "appl-hide-button";
|
||||
|
||||
Search::Search(void) :
|
||||
m_searchEntry(NULL),
|
||||
m_replaceEntry(NULL)
|
||||
{
|
||||
m_forward = false;
|
||||
|
||||
ewol::ButtonImage * myButtonImage = NULL;
|
||||
|
||||
myButtonImage = new ewol::ButtonImage("THEME:GUI:Remove.svg");
|
||||
if (NULL == myButtonImage) {
|
||||
APPL_ERROR("Widget allocation error ==> it will missing in the display");
|
||||
} else {
|
||||
myButtonImage->SetMinSize(32,32);
|
||||
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventHideBt);
|
||||
SubWidgetAdd(myButtonImage);
|
||||
}
|
||||
|
||||
m_searchEntry = new ewol::Entry();
|
||||
if (NULL == m_searchEntry) {
|
||||
APPL_ERROR("Widget allocation error ==> it will missing in the display");
|
||||
} else {
|
||||
m_searchEntry->RegisterOnEvent(this, ewolEventEntryModify, l_eventSearchEntry);
|
||||
m_searchEntry->RegisterOnEvent(this, ewolEventEntryEnter, l_eventSearchEntryEnter);
|
||||
m_searchEntry->SetExpendX(true);
|
||||
m_searchEntry->SetFillX(true);
|
||||
SubWidgetAdd(m_searchEntry);
|
||||
}
|
||||
|
||||
myButtonImage = new ewol::ButtonImage("THEME:GUI:Search.svg");
|
||||
if (NULL == myButtonImage) {
|
||||
APPL_ERROR("Widget allocation error ==> it will missing in the display");
|
||||
} else {
|
||||
myButtonImage->SetMinSize(32,32);
|
||||
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventSearchBt);
|
||||
SubWidgetAdd(myButtonImage);
|
||||
}
|
||||
|
||||
m_replaceEntry = new ewol::Entry();
|
||||
if (NULL == m_replaceEntry) {
|
||||
APPL_ERROR("Widget allocation error ==> it will missing in the display");
|
||||
} else {
|
||||
m_replaceEntry->RegisterOnEvent(this, ewolEventEntryModify, l_eventReplaceEntry);
|
||||
m_replaceEntry->RegisterOnEvent(this, ewolEventEntryEnter, l_eventReplaceEntryEnter);
|
||||
m_replaceEntry->SetExpendX(true);
|
||||
m_replaceEntry->SetFillX(true);
|
||||
SubWidgetAdd(m_replaceEntry);
|
||||
}
|
||||
|
||||
myButtonImage = new ewol::ButtonImage("THEME:GUI:Replace.svg");
|
||||
if (NULL == myButtonImage) {
|
||||
APPL_ERROR("Widget allocation error ==> it will missing in the display");
|
||||
} else {
|
||||
myButtonImage->SetMinSize(32,32);
|
||||
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventReplaceBt);
|
||||
SubWidgetAdd(myButtonImage);
|
||||
}
|
||||
|
||||
myButtonImage = new ewol::ButtonImage("THEME:GUI:CaseSensitive.svg");
|
||||
if (NULL == myButtonImage) {
|
||||
APPL_ERROR("Widget allocation error ==> it will missing in the display");
|
||||
} else {
|
||||
myButtonImage->SetImageSelected("THEME:GUI:CaseSensitive.svg", 0xFFFFFF5F);
|
||||
myButtonImage->SetMinSize(32,32);
|
||||
myButtonImage->SetToggleMode(true);
|
||||
myButtonImage->SetValue(SearchData::GetCase());
|
||||
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventCaseCb);
|
||||
SubWidgetAdd(myButtonImage);
|
||||
}
|
||||
|
||||
myButtonImage = new ewol::ButtonImage("THEME:GUI:WrapAround.svg");
|
||||
if (NULL == myButtonImage) {
|
||||
APPL_ERROR("Widget allocation error ==> it will missing in the display");
|
||||
} else {
|
||||
myButtonImage->SetImageSelected("THEME:GUI:WrapAround.svg", 0xFFFFFF5F);
|
||||
myButtonImage->SetMinSize(32,32);
|
||||
myButtonImage->SetToggleMode(true);
|
||||
myButtonImage->SetValue(SearchData::GetWrap());
|
||||
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventWrapCb);
|
||||
SubWidgetAdd(myButtonImage);
|
||||
}
|
||||
|
||||
myButtonImage = new ewol::ButtonImage("THEME:GUI:Up.svg");
|
||||
if (NULL == myButtonImage) {
|
||||
APPL_ERROR("Widget allocation error ==> it will missing in the display");
|
||||
} else {
|
||||
myButtonImage->SetImageSelected("THEME:GUI:Down.svg");
|
||||
myButtonImage->SetMinSize(32,32);
|
||||
myButtonImage->SetToggleMode(true);
|
||||
myButtonImage->SetValue(m_forward);
|
||||
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventForwardCb);
|
||||
SubWidgetAdd(myButtonImage);
|
||||
}
|
||||
|
||||
RegisterMultiCast(ednMsgGuiSearch);
|
||||
// basicly hiden ...
|
||||
Hide();
|
||||
}
|
||||
|
||||
Search::~Search(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void Search::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::SizerHori::OnReceiveMessage(CallerObject, eventId, data);
|
||||
//APPL_INFO("Search receive message : \"" << eventId << "\" data=\"" << data << "\"");
|
||||
if ( eventId == l_eventSearchEntry) {
|
||||
SearchData::SetSearch(data);
|
||||
} else if ( eventId == l_eventSearchEntryEnter) {
|
||||
SearchData::SetSearch(data);
|
||||
if (true==m_forward) {
|
||||
SendMultiCast(ednMsgGuiFind, "Previous");
|
||||
} else {
|
||||
SendMultiCast(ednMsgGuiFind, "Next");
|
||||
}
|
||||
} else if ( eventId == l_eventReplaceEntry) {
|
||||
SearchData::SetReplace(data);
|
||||
} else if ( eventId == l_eventReplaceEntryEnter) {
|
||||
SearchData::SetReplace(data);
|
||||
SendMultiCast(ednMsgGuiReplace, "Normal");
|
||||
if (true==m_forward) {
|
||||
SendMultiCast(ednMsgGuiFind, "Previous");
|
||||
} else {
|
||||
SendMultiCast(ednMsgGuiFind, "Next");
|
||||
}
|
||||
} else if ( eventId == l_eventSearchBt) {
|
||||
if (true==m_forward) {
|
||||
SendMultiCast(ednMsgGuiFind, "Previous");
|
||||
} else {
|
||||
SendMultiCast(ednMsgGuiFind, "Next");
|
||||
}
|
||||
} else if ( eventId == l_eventReplaceBt) {
|
||||
SendMultiCast(ednMsgGuiReplace, "Normal");
|
||||
if (true==m_forward) {
|
||||
SendMultiCast(ednMsgGuiFind, "Previous");
|
||||
} else {
|
||||
SendMultiCast(ednMsgGuiFind, "Next");
|
||||
}
|
||||
} else if ( eventId == l_eventCaseCb) {
|
||||
if (data == "true") {
|
||||
SearchData::SetCase(true);
|
||||
} else {
|
||||
SearchData::SetCase(false);
|
||||
}
|
||||
} else if ( eventId == l_eventWrapCb) {
|
||||
if (data == "true") {
|
||||
SearchData::SetWrap(true);
|
||||
} else {
|
||||
SearchData::SetWrap(false);
|
||||
}
|
||||
} else if ( eventId == l_eventForwardCb) {
|
||||
if (data == "true") {
|
||||
m_forward = true;
|
||||
} else {
|
||||
m_forward = false;
|
||||
}
|
||||
} else if ( eventId == l_eventHideBt) {
|
||||
Hide();
|
||||
} else if ( eventId == ednMsgGuiSearch) {
|
||||
if (true == IsHide()) {
|
||||
Show();
|
||||
if (m_searchEntry!= NULL) {
|
||||
m_searchEntry->KeepFocus();
|
||||
}
|
||||
} else {
|
||||
if( (m_searchEntry!=NULL && true==m_searchEntry->GetFocus())
|
||||
|| (m_replaceEntry!=NULL && true==m_replaceEntry->GetFocus()) ) {
|
||||
Hide();
|
||||
} else if (m_searchEntry!= NULL) {
|
||||
m_searchEntry->KeepFocus();
|
||||
} else {
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void Search::OnObjectRemove(ewol::EObject * removeObject)
|
||||
{
|
||||
ewol::SizerHori::OnObjectRemove(removeObject);
|
||||
if (removeObject == m_searchEntry) {
|
||||
m_searchEntry = NULL;
|
||||
}
|
||||
if (removeObject == m_replaceEntry) {
|
||||
m_replaceEntry = NULL;
|
||||
}
|
||||
}
|
||||
|
69
sources/appl/Gui/Search.h
Normal file
69
sources/appl/Gui/Search.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Search.h
|
||||
* @brief Editeur De N'ours : Search system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 03/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __SEARCH_H__
|
||||
#define __SEARCH_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
|
||||
class Search : public ewol::SizerHori
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
Search(void);
|
||||
~Search(void);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void) { return "ApplSearch"; };
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnObjectRemove(ewol::EObject * removeObject);
|
||||
private:
|
||||
bool m_forward;
|
||||
ewol::Entry * m_searchEntry;
|
||||
ewol::Entry * m_replaceEntry;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
102
sources/appl/Gui/SearchData.cpp
Normal file
102
sources/appl/Gui/SearchData.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file SearchData.cpp
|
||||
* @brief Editeur De N'ours : Search Data element (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 02/02/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/global.h>
|
||||
#include <SearchData.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "SearchData"
|
||||
|
||||
|
||||
static etk::UString m_findRequest = "";
|
||||
|
||||
void SearchData::SetSearch(etk::UString &myData)
|
||||
{
|
||||
m_findRequest = myData;
|
||||
}
|
||||
void SearchData::GetSearch(etk::UString &myData)
|
||||
{
|
||||
myData = m_findRequest;
|
||||
}
|
||||
bool SearchData::IsSearchEmpty(void)
|
||||
{
|
||||
if(m_findRequest.Size() > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static etk::UString m_replaceRequest = "";
|
||||
void SearchData::SetReplace(etk::UString &myData)
|
||||
{
|
||||
m_replaceRequest = myData;
|
||||
}
|
||||
void SearchData::GetReplace(etk::UString &myData)
|
||||
{
|
||||
myData = m_replaceRequest;
|
||||
}
|
||||
bool SearchData::IsReplaceEmpty(void)
|
||||
{
|
||||
if(m_replaceRequest.Size() > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool m_case = false;
|
||||
void SearchData::SetCase(bool value)
|
||||
{
|
||||
m_case = value;
|
||||
}
|
||||
bool SearchData::GetCase(void)
|
||||
{
|
||||
return m_case;
|
||||
}
|
||||
|
||||
|
||||
static bool m_wrap = true;
|
||||
void SearchData::SetWrap(bool value)
|
||||
{
|
||||
m_wrap = value;
|
||||
}
|
||||
bool SearchData::GetWrap(void)
|
||||
{
|
||||
return m_wrap;
|
||||
}
|
||||
|
||||
|
||||
static bool m_RegExp = false;
|
||||
void SearchData::SetRegExp(bool value)
|
||||
{
|
||||
m_RegExp = value;
|
||||
}
|
||||
bool SearchData::GetRegExp(void)
|
||||
{
|
||||
return m_RegExp;
|
||||
}
|
||||
|
||||
|
49
sources/appl/Gui/SearchData.h
Normal file
49
sources/appl/Gui/SearchData.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file SearchData.h
|
||||
* @brief Editeur De N'ours : Search Data element (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 02/02/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __SEARCH_DATA_H__
|
||||
#define __SEARCH_DATA_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <appl/Debug.h>
|
||||
|
||||
namespace SearchData
|
||||
{
|
||||
void SetSearch(etk::UString &myData);
|
||||
void GetSearch(etk::UString &myData);
|
||||
bool IsSearchEmpty(void);
|
||||
void SetReplace(etk::UString &myData);
|
||||
void GetReplace(etk::UString &myData);
|
||||
bool IsReplaceEmpty(void);
|
||||
void SetCase(bool value);
|
||||
bool GetCase(void);
|
||||
void SetWrap(bool value);
|
||||
bool GetWrap(void);
|
||||
void SetRegExp(bool value);
|
||||
bool GetRegExp(void);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
155
sources/appl/Gui/TagFileList.cpp
Normal file
155
sources/appl/Gui/TagFileList.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file TagFileList.cpp
|
||||
* @brief Editeur De N'ours : Tags list display to jump (sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 16/10/2012
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <etk/tool.h>
|
||||
#include <appl/Gui/TagFileList.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "TagFileList"
|
||||
|
||||
extern const char * const applEventCtagsListSelect = "appl-event-ctags-list-select";
|
||||
extern const char * const applEventCtagsListUnSelect = "appl-event-ctags-list-un-select";
|
||||
extern const char * const applEventCtagsListValidate = "appl-event-ctags-list-validate";
|
||||
|
||||
|
||||
appl::TagFileList::TagFileList(void)
|
||||
{
|
||||
m_selectedLine = -1;
|
||||
AddEventId(applEventCtagsListSelect);
|
||||
AddEventId(applEventCtagsListValidate);
|
||||
SetMouseLimit(1);
|
||||
}
|
||||
|
||||
|
||||
appl::TagFileList::~TagFileList(void)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_list.Size(); iii++) {
|
||||
if (NULL != m_list[iii]) {
|
||||
delete(m_list[iii]);
|
||||
m_list[iii] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
draw::Color appl::TagFileList::GetBasicBG(void) {
|
||||
draw::Color bg(0x00000010);
|
||||
return bg;
|
||||
}
|
||||
|
||||
uint32_t appl::TagFileList::GetNuberOfColomn(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool appl::TagFileList::GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg) {
|
||||
myTitle = "title";
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t appl::TagFileList::GetNuberOfRaw(void) {
|
||||
return m_list.Size();
|
||||
}
|
||||
|
||||
bool appl::TagFileList::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg) {
|
||||
if (raw >= 0 && raw < m_list.Size() && NULL != m_list[raw]) {
|
||||
if (0==colomn) {
|
||||
myTextToWrite = etk::UString(m_list[raw]->fileLine);
|
||||
} else {
|
||||
myTextToWrite = m_list[raw]->filename;
|
||||
}
|
||||
} else {
|
||||
myTextToWrite = "ERROR";
|
||||
}
|
||||
fg = draw::color::black;
|
||||
if (raw % 2) {
|
||||
if (colomn%2==0) {
|
||||
bg = 0xFFFFFF00;
|
||||
} else {
|
||||
bg = 0xFFFFFF10;
|
||||
}
|
||||
} else {
|
||||
if (colomn%2==0) {
|
||||
bg = 0xBFBFBFFF;
|
||||
} else {
|
||||
bg = 0xCFCFCFFF;
|
||||
}
|
||||
}
|
||||
if (m_selectedLine == raw) {
|
||||
if (colomn%2==0) {
|
||||
bg = 0x8F8FFFFF;
|
||||
} else {
|
||||
bg = 0x7F7FFFFF;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
bool appl::TagFileList::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y)
|
||||
{
|
||||
if (typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
|
||||
EWOL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
|
||||
if (1 == IdInput) {
|
||||
int32_t previousRaw = m_selectedLine;
|
||||
if (raw > m_list.Size() ) {
|
||||
m_selectedLine = -1;
|
||||
} else {
|
||||
m_selectedLine = raw;
|
||||
}
|
||||
const char * event = applEventCtagsListValidate;
|
||||
if (previousRaw != m_selectedLine) {
|
||||
event = applEventCtagsListSelect;
|
||||
}
|
||||
if( m_selectedLine >=0
|
||||
&& m_selectedLine < m_list.Size()
|
||||
&& NULL != m_list[m_selectedLine] ) {
|
||||
GenerateEventId(event, etk::UString(m_list[raw]->fileLine)+":"+m_list[m_selectedLine]->filename);
|
||||
} else {
|
||||
GenerateEventId(applEventCtagsListUnSelect);
|
||||
}
|
||||
// need to regenerate the display of the list :
|
||||
MarkToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add a Ctags item on the curent list
|
||||
* @param[in] file Compleate file name
|
||||
* @param[in] jump line id
|
||||
* @return ---
|
||||
*/
|
||||
void appl::TagFileList::Add(etk::UString& file, int32_t line)
|
||||
{
|
||||
appl::TagListElement *tmpFile = new appl::TagListElement(file, line);
|
||||
if (NULL != tmpFile) {
|
||||
m_list.PushBack(tmpFile);
|
||||
}
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
|
84
sources/appl/Gui/TagFileList.h
Normal file
84
sources/appl/Gui/TagFileList.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file TagFileList.h
|
||||
* @brief Editeur De N'ours : Tags list display to jump (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 16/10/2012
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __APPL_CTAGS_LIST_H__
|
||||
#define __APPL_CTAGS_LIST_H__
|
||||
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <appl/Debug.h>
|
||||
#include <ewol/widget/List.h>
|
||||
|
||||
|
||||
extern const char * const applEventCtagsListSelect;
|
||||
extern const char * const applEventCtagsListValidate;
|
||||
extern const char * const applEventCtagsListUnSelect;
|
||||
|
||||
namespace appl {
|
||||
class TagListElement {
|
||||
public:
|
||||
etk::UString filename;
|
||||
int32_t fileLine;
|
||||
TagListElement(etk::UString& file, int32_t line) : filename(file), fileLine(line) {};
|
||||
~TagListElement(void) {};
|
||||
};
|
||||
class TagFileList : public ewol::List
|
||||
{
|
||||
private:
|
||||
int32_t m_selectedLine;
|
||||
etk::Vector<appl::TagListElement*> m_list;
|
||||
public:
|
||||
TagFileList(void);
|
||||
~TagFileList(void);
|
||||
// display API :
|
||||
virtual draw::Color GetBasicBG(void);
|
||||
uint32_t GetNuberOfColomn(void);
|
||||
bool GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg);
|
||||
uint32_t GetNuberOfRaw(void);
|
||||
bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg);
|
||||
bool OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void) { return "TagFileList"; };
|
||||
public:
|
||||
/**
|
||||
* @brief Add a Ctags item on the curent list
|
||||
* @param[in] file Compleate file name
|
||||
* @param[in] jump line id
|
||||
* @return ---
|
||||
*/
|
||||
void Add(etk::UString& file, int32_t line);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
229
sources/appl/Gui/TagFileSelection.cpp
Normal file
229
sources/appl/Gui/TagFileSelection.cpp
Normal file
@@ -0,0 +1,229 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file TagFileSelection.cpp
|
||||
* @brief Editeur De N'ours : Tags list selection to jump (sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 16/10/2012
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/meta/FileChooser.cpp
|
||||
* @brief ewol File chooser meta widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/12/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 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
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Gui/TagFileSelection.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/widget/Image.h>
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
#include <etk/Vector.h>
|
||||
#include <etk/tool.h>
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "TagFileSelection"
|
||||
|
||||
|
||||
extern const char * const applEventctagsSelection = "appl-event-ctags-validate";
|
||||
extern const char * const applEventctagsCancel = "appl-event-ctags-cancel";
|
||||
|
||||
|
||||
appl::TagFileSelection::TagFileSelection(void)
|
||||
{
|
||||
AddEventId(applEventctagsSelection);
|
||||
AddEventId(applEventctagsCancel);
|
||||
|
||||
ewol::Label* myWidgetTitle = NULL;
|
||||
ewol::Button* myWidgetValidate = NULL;
|
||||
ewol::Button* myWidgetCancel = NULL;
|
||||
|
||||
ewol::SizerVert * mySizerVert = NULL;
|
||||
ewol::SizerHori * mySizerHori = NULL;
|
||||
ewol::Spacer * mySpacer = NULL;
|
||||
#if defined(__TARGET_OS__Android)
|
||||
SetDisplayRatio(0.90);
|
||||
#elif defined(__TARGET_OS__Windows)
|
||||
SetDisplayRatio(0.80);
|
||||
#else
|
||||
SetDisplayRatio(0.80);
|
||||
#endif
|
||||
|
||||
mySizerVert = new ewol::SizerVert();
|
||||
if (NULL == mySizerVert) {
|
||||
EWOL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
mySizerVert->LockExpendContamination(true);
|
||||
// set it in the pop-up-system :
|
||||
SubWidgetSet(mySizerVert);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
if (NULL == mySizerHori) {
|
||||
EWOL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
mySpacer = new ewol::Spacer();
|
||||
if (NULL == mySpacer) {
|
||||
EWOL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
mySpacer->SetExpendX(true);
|
||||
mySizerHori->SubWidgetAdd(mySpacer);
|
||||
}
|
||||
myWidgetValidate = new ewol::Button("Jump");
|
||||
if (NULL == myWidgetValidate) {
|
||||
EWOL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
myWidgetValidate->SetImage("icon/Load.svg");
|
||||
myWidgetValidate->RegisterOnEvent(this, ewolEventButtonPressed, applEventctagsSelection);
|
||||
mySizerHori->SubWidgetAdd(myWidgetValidate);
|
||||
}
|
||||
myWidgetCancel = new ewol::Button("Cancel");
|
||||
if (NULL == myWidgetCancel) {
|
||||
EWOL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
myWidgetCancel->SetImage("icon/Remove.svg");
|
||||
myWidgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, applEventctagsCancel);
|
||||
mySizerHori->SubWidgetAdd(myWidgetCancel);
|
||||
}
|
||||
}
|
||||
m_listTag = new appl::TagFileList();
|
||||
if (NULL == m_listTag) {
|
||||
EWOL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
m_listTag->RegisterOnEvent(this, applEventCtagsListValidate);
|
||||
m_listTag->RegisterOnEvent(this, applEventCtagsListSelect);
|
||||
m_listTag->RegisterOnEvent(this, applEventCtagsListUnSelect);
|
||||
m_listTag->SetExpendX(true);
|
||||
m_listTag->SetExpendY(true);
|
||||
m_listTag->SetFillX(true);
|
||||
m_listTag->SetFillY(true);
|
||||
mySizerVert->SubWidgetAdd(m_listTag);
|
||||
}
|
||||
|
||||
myWidgetTitle = new ewol::Label("Ctags Jump Selection ...");
|
||||
if (NULL == myWidgetTitle) {
|
||||
EWOL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
mySizerVert->SubWidgetAdd(myWidgetTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appl::TagFileSelection::~TagFileSelection(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void appl::TagFileSelection::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
EWOL_INFO("ctags LIST ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
|
||||
if (eventId == applEventctagsSelection) {
|
||||
if (m_eventNamed!="") {
|
||||
GenerateEventId(applEventctagsSelection, m_eventNamed);
|
||||
//==> Auto remove ...
|
||||
AutoDestroy();
|
||||
}
|
||||
} else if (eventId == applEventCtagsListSelect) {
|
||||
m_eventNamed = data;
|
||||
|
||||
} else if (eventId == applEventCtagsListUnSelect) {
|
||||
m_eventNamed = "";
|
||||
} else if (eventId == applEventCtagsListValidate) {
|
||||
GenerateEventId(applEventctagsSelection, data);
|
||||
//==> Auto remove ...
|
||||
AutoDestroy();
|
||||
} else if (eventId == applEventctagsCancel) {
|
||||
GenerateEventId(applEventctagsCancel, "");
|
||||
//==> Auto remove ...
|
||||
AutoDestroy();
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add a Ctags item on the curent list
|
||||
* @param[in] file Compleate file name
|
||||
* @param[in] jump line id
|
||||
* @return ---
|
||||
*/
|
||||
void appl::TagFileSelection::AddCtagsNewItem(etk::UString file, int32_t line)
|
||||
{
|
||||
if (NULL != m_listTag) {
|
||||
m_listTag->Add(file, line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void appl::TagFileSelection::OnObjectRemove(ewol::EObject * removeObject)
|
||||
{
|
||||
// First step call parrent :
|
||||
ewol::PopUp::OnObjectRemove(m_listTag);
|
||||
// second step find if in all the elements ...
|
||||
if(removeObject == m_listTag) {
|
||||
m_listTag = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
81
sources/appl/Gui/TagFileSelection.h
Normal file
81
sources/appl/Gui/TagFileSelection.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file TagFileSelection.h
|
||||
* @brief Editeur De N'ours : Tags list selection to jump (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 16/10/2012
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __APPL_CTAGS_SELECTION_H__
|
||||
#define __APPL_CTAGS_SELECTION_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <appl/Debug.h>
|
||||
#include <ewol/widget/PopUp.h>
|
||||
#include <appl/Gui/TagFileList.h>
|
||||
|
||||
extern const char * const applEventctagsSelection;
|
||||
extern const char * const applEventctagsCancel;
|
||||
|
||||
namespace appl {
|
||||
class TagFileSelection : public ewol::PopUp
|
||||
{
|
||||
private:
|
||||
appl::TagFileList* m_listTag;
|
||||
etk::UString m_eventNamed;
|
||||
public:
|
||||
TagFileSelection(void);
|
||||
virtual ~TagFileSelection(void);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void) { return "EwolFileChooser"; };
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void OnObjectRemove(ewol::EObject * removeObject);
|
||||
/**
|
||||
* @brief Add a Ctags item on the curent list
|
||||
* @param[in] file Compleate file name
|
||||
* @param[in] jump line id
|
||||
* @return ---
|
||||
*/
|
||||
void AddCtagsNewItem(etk::UString file, int32_t line);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
332
sources/appl/Highlight/Highlight.cpp
Normal file
332
sources/appl/Highlight/Highlight.cpp
Normal file
@@ -0,0 +1,332 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Highlight.c
|
||||
* @brief Editeur De N'ours : Hightlightning Specific
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <Highlight.h>
|
||||
#include <tinyXML/tinyxml.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Highlight"
|
||||
|
||||
|
||||
void Highlight::ParseRules(TiXmlNode *child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level)
|
||||
{
|
||||
// Create the patern ...
|
||||
HighlightPattern *myPattern = new HighlightPattern();
|
||||
// parse under Element
|
||||
myPattern->ParseRules(child, level);
|
||||
// add element in the list
|
||||
mListPatern.PushBack(myPattern);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Highlight::Highlight(etk::UString &xmlFilename)
|
||||
{
|
||||
TiXmlDocument XmlDocument;
|
||||
|
||||
etk::FSNode fileName(etk::UString("DATA:") + xmlFilename);
|
||||
if (false == fileName.Exist()) {
|
||||
APPL_ERROR("File Does not exist : " << fileName);
|
||||
return;
|
||||
}
|
||||
int32_t fileSize = fileName.FileSize();
|
||||
if (0==fileSize) {
|
||||
APPL_ERROR("This file is empty : " << fileName);
|
||||
return;
|
||||
}
|
||||
if (false == fileName.FileOpenRead()) {
|
||||
APPL_ERROR("Can not open the file : " << fileName);
|
||||
return;
|
||||
}
|
||||
// allocate data
|
||||
char * fileBuffer = new char[fileSize+5];
|
||||
if (NULL == fileBuffer) {
|
||||
APPL_ERROR("Error Memory allocation size=" << fileSize);
|
||||
return;
|
||||
}
|
||||
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
|
||||
// load data from the file :
|
||||
fileName.FileRead(fileBuffer, 1, fileSize);
|
||||
// close the file:
|
||||
fileName.FileClose();
|
||||
// load the XML from the memory
|
||||
bool loadError = XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
|
||||
if (false == loadError) {
|
||||
APPL_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename << "\"");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnLang" );
|
||||
if (NULL == root) {
|
||||
APPL_ERROR( "can not load Hightlight XML: main node not find: \"EdnLang\"");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t level1 = 0;
|
||||
int32_t level2 = 0;
|
||||
TiXmlNode * child = root->FirstChild();
|
||||
while(NULL != child)
|
||||
{
|
||||
if (child->Type()==TiXmlNode::TINYXML_COMMENT) {
|
||||
// nothing to do ...
|
||||
} else if (!strcmp(child->Value(), "ext")) {
|
||||
const char *myData = child->ToElement()->GetText();
|
||||
if (NULL != myData) {
|
||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
|
||||
etk::UString * myEdnData = new etk::UString(myData);
|
||||
m_listExtentions.PushBack(myEdnData);
|
||||
}
|
||||
} else if (!strcmp(child->Value(), "pass1")) {
|
||||
// Get sub Nodes ...
|
||||
TiXmlNode *passChild = child->FirstChild();
|
||||
while (NULL != passChild) {
|
||||
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
|
||||
// nothing to do ...
|
||||
} else if (!strcmp(passChild->Value(), "rule")) {
|
||||
ParseRules(passChild, m_listHighlightPass1, level1++);
|
||||
} else {
|
||||
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
|
||||
}
|
||||
// get the next node element :
|
||||
passChild = passChild->NextSibling();
|
||||
}
|
||||
} else if (!strcmp(child->Value(), "pass2")) {
|
||||
// Get sub Nodes ...
|
||||
TiXmlNode *passChild = child->FirstChild();
|
||||
while (NULL != passChild) {
|
||||
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
|
||||
// nothing to do ...
|
||||
} else if (!strcmp(passChild->Value(), "rule")) {
|
||||
ParseRules(passChild, m_listHighlightPass2, level2++);
|
||||
} else {
|
||||
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
|
||||
}
|
||||
// get the next node element :
|
||||
passChild = passChild->NextSibling();
|
||||
}
|
||||
} else {
|
||||
APPL_ERROR("(l "<< child->Row() << ") node not suported : \""<< child->Value() << "\" must be [ext,pass1,pass2]" );
|
||||
}
|
||||
// get the next node element :
|
||||
child = child->NextSibling();
|
||||
}
|
||||
if (NULL != fileBuffer) {
|
||||
delete[] fileBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
Highlight::~Highlight(void)
|
||||
{
|
||||
int32_t i;
|
||||
// clean all Element
|
||||
for (i=0; i< m_listHighlightPass1.Size(); i++) {
|
||||
if (NULL != m_listHighlightPass1[i]) {
|
||||
delete(m_listHighlightPass1[i]);
|
||||
m_listHighlightPass1[i] = NULL;
|
||||
}
|
||||
}
|
||||
// clear the compleate list
|
||||
m_listHighlightPass1.Clear();
|
||||
|
||||
// clean all Element
|
||||
for (i=0; i< m_listExtentions.Size(); i++) {
|
||||
if (NULL != m_listExtentions[i]) {
|
||||
delete(m_listExtentions[i]);
|
||||
m_listExtentions[i] = NULL;
|
||||
}
|
||||
}
|
||||
// clear the compleate list
|
||||
m_listExtentions.Clear();
|
||||
}
|
||||
|
||||
void Highlight::ReloadColor(void)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i< m_listHighlightPass1.Size(); i++) {
|
||||
if (NULL != m_listHighlightPass1[i]) {
|
||||
m_listHighlightPass1[i]->ReloadColor();
|
||||
}
|
||||
}
|
||||
for (i=0; i< m_listHighlightPass2.Size(); i++) {
|
||||
if (NULL != m_listHighlightPass2[i]) {
|
||||
m_listHighlightPass2[i]->ReloadColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Highlight::HasExtention(etk::UString &ext)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<m_listExtentions.Size(); i++) {
|
||||
if (ext == *m_listExtentions[i] ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Highlight::FileNameCompatible(etk::FSNode &fileName)
|
||||
{
|
||||
int32_t i;
|
||||
etk::UString extention;
|
||||
if (true == fileName.FileHasExtention() ) {
|
||||
extention = "*.";
|
||||
extention += fileName.FileGetExtention();
|
||||
} else {
|
||||
extention = fileName.GetNameFile();
|
||||
}
|
||||
APPL_DEBUG(" try to find : in \"" << fileName << "\" extention:\"" << extention << "\" ");
|
||||
|
||||
for (i=0; i<m_listExtentions.Size(); i++) {
|
||||
if (extention == *m_listExtentions[i] ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Highlight::Display(void)
|
||||
{
|
||||
int32_t i;
|
||||
APPL_INFO("List of ALL Highlight : ");
|
||||
for (i=0; i< m_listExtentions.Size(); i++) {
|
||||
APPL_INFO(" Extention : " << i << " : " << *m_listExtentions[i] );
|
||||
}
|
||||
// Display all elements
|
||||
for (i=0; i< m_listHighlightPass1.Size(); i++) {
|
||||
APPL_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName() );
|
||||
//m_listHighlightPass1[i]->Display();
|
||||
}
|
||||
// Display all elements
|
||||
for (i=0; i< m_listHighlightPass2.Size(); i++) {
|
||||
APPL_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName() );
|
||||
//m_listHighlightPass2[i]->Display();
|
||||
}
|
||||
}
|
||||
// 13h 46min 22s | (l= 214) Highlight::Parse | [II] Find Pattern in the Buffer : (2457,2479)
|
||||
|
||||
|
||||
// TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas tr<74>grave... Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer...
|
||||
void Highlight::Parse(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<colorInformation_ts> &metaData,
|
||||
int32_t addingPos,
|
||||
EdnVectorBuf &buffer)
|
||||
{
|
||||
if (0 > addingPos) {
|
||||
addingPos = 0;
|
||||
}
|
||||
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.Size() << " ==> position search: (" << start << "," << stop << ")" );
|
||||
int32_t elementStart = start;
|
||||
int32_t elementStop = stop;
|
||||
colorInformation_ts resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
//try to fond the HL in ALL of we have
|
||||
for (int32_t jjj=0; jjj<m_listHighlightPass1.Size(); jjj++){
|
||||
resultFind_te ret = HLP_FIND_OK;
|
||||
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.Size() << ")" );
|
||||
// Stop the search to the end (to get the end of the pattern)
|
||||
ret = m_listHighlightPass1[jjj]->Find(elementStart, buffer.Size(), resultat, buffer);
|
||||
if (HLP_FIND_ERROR != ret) {
|
||||
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
|
||||
// Remove element in the current List where the current Element have a end inside the next...
|
||||
int32_t kkk=addingPos;
|
||||
while(kkk < metaData.Size() ) {
|
||||
if (metaData[kkk].beginStart <= resultat.endStop) {
|
||||
// Remove element
|
||||
//APPL_INFO("Erase element=" << kkk);
|
||||
metaData.EraseLen(kkk, kkk+1);
|
||||
// Increase the end of search
|
||||
if (kkk < metaData.Size()) {
|
||||
// just befor the end of the next element
|
||||
elementStop = metaData[kkk].beginStart-1;
|
||||
} else {
|
||||
// end of the buffer
|
||||
elementStop = buffer.Size();
|
||||
}
|
||||
} else {
|
||||
// Not find ==> exit the cycle :
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Add curent element in the list ...
|
||||
metaData.Insert(addingPos, resultat);
|
||||
//APPL_DEBUG("INSERT at "<< addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop );
|
||||
// Update the current research starting element: (Set position at the end of the current element
|
||||
elementStart = resultat.endStop-1;
|
||||
// increment the position of insertion:
|
||||
addingPos++;
|
||||
// We find a pattern ==> Stop search for the current element
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Go to the next element (and search again ...).
|
||||
elementStart++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief second pass of the hightlight
|
||||
*
|
||||
*/
|
||||
void Highlight::Parse2(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<colorInformation_ts> &metaData,
|
||||
EdnVectorBuf &buffer)
|
||||
{
|
||||
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " ==> position search: (" << start << "," << stop << ")" );
|
||||
int32_t elementStart = start;
|
||||
int32_t elementStop = stop;
|
||||
colorInformation_ts resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
//try to fond the HL in ALL of we have
|
||||
int32_t jjj;
|
||||
for (jjj=0; jjj<m_listHighlightPass2.Size(); jjj++){
|
||||
resultFind_te ret = HLP_FIND_OK;
|
||||
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.Size() << ")" );
|
||||
// Stop the search to the end (to get the end of the pattern)
|
||||
ret = m_listHighlightPass2[jjj]->Find(elementStart, elementStop, resultat, buffer);
|
||||
if (HLP_FIND_ERROR != ret) {
|
||||
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
|
||||
// Add curent element in the list ...
|
||||
metaData.PushBack(resultat);
|
||||
elementStart = resultat.endStop-1;
|
||||
// Exit current cycle
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Go to the next element (and search again ...).
|
||||
elementStart++;
|
||||
}
|
||||
}
|
||||
|
83
sources/appl/Highlight/Highlight.h
Normal file
83
sources/appl/Highlight/Highlight.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Highlight.h
|
||||
* @brief Editeur De N'ours : Hightlightning Specific (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __HIGHLIGHT_H__
|
||||
#define __HIGHLIGHT_H__
|
||||
|
||||
|
||||
class Highlight;
|
||||
class HighlightPattern;
|
||||
|
||||
extern "C" {
|
||||
typedef struct
|
||||
{
|
||||
int32_t beginStart;
|
||||
int32_t beginStop;
|
||||
int32_t endStart;
|
||||
int32_t endStop;
|
||||
bool notEnded;
|
||||
HighlightPattern * patern; // pointer on class :
|
||||
} colorInformation_ts;
|
||||
}
|
||||
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <HighlightPattern.h>
|
||||
#include <Colorize.h>
|
||||
#include <EdnVectorBuf.h>
|
||||
#include <tinyXML/tinyxml.h>
|
||||
|
||||
class Highlight {
|
||||
public:
|
||||
// Constructeur
|
||||
Highlight(etk::UString &xmlFilename);
|
||||
~Highlight(void);
|
||||
bool HasExtention(etk::UString &ext);
|
||||
bool FileNameCompatible(etk::FSNode &fileName);
|
||||
void Display(void);
|
||||
void ReloadColor(void);
|
||||
void Parse(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<colorInformation_ts> &metaData,
|
||||
int32_t addingPos,
|
||||
EdnVectorBuf &buffer);
|
||||
void Parse2(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<colorInformation_ts> &metaData,
|
||||
EdnVectorBuf &buffer);
|
||||
private:
|
||||
void ParseRules(TiXmlNode *child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level);
|
||||
etk::UString m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
|
||||
etk::Vector<etk::UString*> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
|
||||
etk::Vector<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer)
|
||||
etk::Vector<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) )
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
221
sources/appl/Highlight/HighlightManager.cpp
Normal file
221
sources/appl/Highlight/HighlightManager.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file HighlightManager.cpp
|
||||
* @brief Editeur De N'ours : Hightlining Manager
|
||||
* @author Edouard DUPIN
|
||||
* @date 16/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <HighlightManager.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
#include <ewol/eObject/EObjectManager.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "HighlightManager"
|
||||
|
||||
class localClassHighlightManager: public ewol::EObject
|
||||
{
|
||||
private:
|
||||
etk::Vector<Highlight*> listHighlight; //!< List of ALL hightlight modules
|
||||
public:
|
||||
// Constructeur
|
||||
localClassHighlightManager(void) {
|
||||
//ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferColor);
|
||||
};
|
||||
~localClassHighlightManager(void) {
|
||||
int32_t i;
|
||||
// clean all Element
|
||||
for (i=0; i< listHighlight.Size(); i++) {
|
||||
if (NULL != listHighlight[i]) {
|
||||
delete(listHighlight[i]);
|
||||
listHighlight[i] = NULL;
|
||||
}
|
||||
}
|
||||
// clear the compleate list
|
||||
listHighlight.Clear();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void)
|
||||
{
|
||||
return "ApplHighlightManager";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
/*
|
||||
switch (id)
|
||||
{
|
||||
case APPL_MSG__COLOR_HAS_CHANGE:
|
||||
APPL_INFO("UPDATE the color pointer on the HL");
|
||||
for (int32_t i=0; i<listHighlight.Size(); i++) {
|
||||
if (NULL != listHighlight[i]) {
|
||||
listHighlight[i]->ReloadColor();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Highlight* Get(etk::FSNode &fileName)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listHighlight.Size(); i++) {
|
||||
if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
|
||||
return listHighlight[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool Exist(etk::FSNode &fileName)
|
||||
{
|
||||
if (NULL != Get(fileName) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void loadLanguages(void)
|
||||
{
|
||||
etk::UString xmlFilename = "languages/c/highlight.xml";
|
||||
Highlight *myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/boo/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/makefile/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/asm/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/xml/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/php/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/bash/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/matlab/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/java/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/lua/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/in/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "languages/glsl/highlight.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
//myHightline->Display();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#define EDN_CAST_HIGHLIGHT_MANAGER(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_HIGHLIGHT_MANAGER,localClassHighlightManager,curentPointer)
|
||||
|
||||
static localClassHighlightManager * localManager = NULL;
|
||||
|
||||
|
||||
|
||||
void HighlightManager::Init(void)
|
||||
{
|
||||
if (NULL != localManager) {
|
||||
APPL_ERROR("HighlightManager ==> already exist, just unlink the previous ...");
|
||||
localManager = NULL;
|
||||
}
|
||||
localManager = new localClassHighlightManager();
|
||||
|
||||
if (NULL == localManager) {
|
||||
APPL_CRITICAL("Allocation of HighlightManager not done ...");
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightManager::UnInit(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
APPL_ERROR("HighlightManager ==> request UnInit, but does not exist ...");
|
||||
return;
|
||||
}
|
||||
delete(localManager);
|
||||
localManager = NULL;
|
||||
}
|
||||
|
||||
void HighlightManager::loadLanguages(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return;
|
||||
}
|
||||
localManager->loadLanguages();
|
||||
}
|
||||
|
||||
Highlight* HighlightManager::Get(etk::FSNode &fileName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return NULL;
|
||||
}
|
||||
return localManager->Get(fileName);
|
||||
}
|
||||
|
||||
bool HighlightManager::Exist(etk::FSNode &fileName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return false;
|
||||
}
|
||||
return localManager->Exist(fileName);
|
||||
}
|
||||
|
||||
|
||||
|
45
sources/appl/Highlight/HighlightManager.h
Normal file
45
sources/appl/Highlight/HighlightManager.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file HighlightManager.h
|
||||
* @brief Editeur De N'ours : Hightlining Manager (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __HIGHLIGHT_MANAGER_H__
|
||||
#define __HIGHLIGHT_MANAGER_H__
|
||||
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <appl/globalMsg.h>
|
||||
#include <Highlight.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
|
||||
namespace HighlightManager{
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
void loadLanguages(void);
|
||||
Highlight* Get(etk::FSNode &fileName);
|
||||
bool Exist(etk::FSNode &fileName);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
249
sources/appl/Highlight/HighlightPattern.cpp
Normal file
249
sources/appl/Highlight/HighlightPattern.cpp
Normal file
@@ -0,0 +1,249 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file HighlightPattern.cpp
|
||||
* @brief Editeur De N'ours : Hightlight Patern (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <HighlightPattern.h>
|
||||
#include <ColorizeManager.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "HighlightPattern"
|
||||
|
||||
|
||||
|
||||
HighlightPattern::HighlightPattern(void)
|
||||
{
|
||||
m_haveStopPatern = false;
|
||||
m_multiline = false;
|
||||
m_color = ColorizeManager::Get("normal");
|
||||
m_regExpStart = new etk::RegExp<EdnVectorBuf>();
|
||||
m_regExpStop = new etk::RegExp<EdnVectorBuf>();
|
||||
m_escapeChar = 0;
|
||||
}
|
||||
|
||||
HighlightPattern::~HighlightPattern(void)
|
||||
{
|
||||
delete(m_regExpStart);
|
||||
delete(m_regExpStop);
|
||||
}
|
||||
|
||||
void HighlightPattern::SetPaternStart(etk::UString ®Exp)
|
||||
{
|
||||
m_regExpStart->SetRegExp(regExp);
|
||||
}
|
||||
|
||||
void HighlightPattern::SetPaternStop(etk::UString ®Exp)
|
||||
{
|
||||
if (regExp.Size() != 0) {
|
||||
m_regExpStop->SetRegExp(regExp);
|
||||
m_haveStopPatern = true;
|
||||
} else {
|
||||
m_haveStopPatern = false;
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightPattern::SetEscapeChar(etk::UString &EscapeChar)
|
||||
{
|
||||
if (EscapeChar.Size()>0) {
|
||||
m_escapeChar = EscapeChar[0];
|
||||
} else {
|
||||
m_escapeChar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HighlightPattern::SetColor(etk::UString &colorName)
|
||||
{
|
||||
m_colorName = colorName;
|
||||
m_color = ColorizeManager::Get(m_colorName);
|
||||
}
|
||||
|
||||
bool HighlightPattern::IsEnable(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void HighlightPattern::ReloadColor(void)
|
||||
{
|
||||
m_color = ColorizeManager::Get(m_colorName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out]
|
||||
*
|
||||
* @eturn
|
||||
*
|
||||
*/
|
||||
void HighlightPattern::Display(void)
|
||||
{
|
||||
/*
|
||||
APPL_INFO("patern : \"" << m_paternName << "\" level=" << m_level );
|
||||
APPL_INFO(" ==> colorName \"" << m_colorName << "\"");
|
||||
APPL_INFO(" ==> regExpStart \"" << m_regExpStart->GetRegExp() << "\"");
|
||||
APPL_INFO(" ==> regExpStop \"" << m_regExpStop->GetRegExp() << "\"");
|
||||
if (true == m_haveStopPatern) {
|
||||
APPL_INFO(" ==> stop pattern: YES");
|
||||
} else {
|
||||
APPL_INFO(" ==> stop pattern: NO");
|
||||
}
|
||||
if (true == m_multiline) {
|
||||
APPL_INFO(" ==> multiline pattern: YES");
|
||||
} else {
|
||||
APPL_INFO(" ==> multiline pattern: NO");
|
||||
}
|
||||
*/
|
||||
// Display all elements
|
||||
for (int32_t i=0; i< m_subPatern.Size(); i++) {
|
||||
APPL_INFO(" " << i << " SubPattern : " << m_subPatern[i]->GetName() );
|
||||
m_subPatern[i]->Display();
|
||||
}
|
||||
}
|
||||
void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
|
||||
{
|
||||
//--------------------------------------------------------------------------------------------
|
||||
/*
|
||||
<rule name="my preprocesseur">
|
||||
<color>preprocesseur</color>
|
||||
<start>#</start>
|
||||
<end>$</end>
|
||||
<multiline>yes</multiline>
|
||||
</rule>
|
||||
*/
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// process attribute
|
||||
const char *highLightName = child->ToElement()->Attribute("name");
|
||||
etk::UString myEdnDataTmp = "???";
|
||||
if (NULL != highLightName) {
|
||||
myEdnDataTmp = highLightName;
|
||||
}
|
||||
SetName(myEdnDataTmp);
|
||||
SetLevel(level);
|
||||
|
||||
TiXmlElement *xChild = child->FirstChildElement("color");
|
||||
if (NULL != xChild) {
|
||||
const char *myData = xChild->GetText();
|
||||
if (myData) {
|
||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||
etk::UString myEdnData = myData;
|
||||
SetColor(myEdnData);
|
||||
}
|
||||
}
|
||||
xChild = child->FirstChildElement("start");
|
||||
if (NULL != xChild) {
|
||||
const char *myData = xChild->GetText();
|
||||
if (myData) {
|
||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||
etk::UString myEdnData = myData;
|
||||
SetPaternStart(myEdnData);
|
||||
}
|
||||
}
|
||||
xChild = child->FirstChildElement("end");
|
||||
if (NULL != xChild) {
|
||||
const char *myData = xChild->GetText();
|
||||
if (myData) {
|
||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||
etk::UString myEdnData = myData;
|
||||
SetPaternStop(myEdnData);
|
||||
}
|
||||
}
|
||||
xChild = child->FirstChildElement("EscapeChar");
|
||||
if (NULL != xChild) {
|
||||
const char *myData = xChild->GetText();
|
||||
if (myData) {
|
||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||
etk::UString myEdnData = myData;
|
||||
SetEscapeChar(myEdnData);
|
||||
}
|
||||
}
|
||||
xChild = child->FirstChildElement("rule");
|
||||
if (NULL != xChild) {
|
||||
/*
|
||||
// Create the patern ...
|
||||
HighlightPattern *myPattern = new HighlightPattern();
|
||||
// parse under Element
|
||||
myPattern->ParseRules(ruleChild, level+1);
|
||||
// add element in the list
|
||||
m_subPatern.PushBack(myPattern);
|
||||
//ParseRules(passChild, m_listHighlightPass1, level1++);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Find Element only in the specify start characters and find the end with the range done
|
||||
*
|
||||
* @param[in] start First character to search data (if recognise it start here)
|
||||
* @param[in] stop End of the possibility whe search can continue
|
||||
* @param[out] resultat Position where find data
|
||||
* @param[in] buffer : Where to search data
|
||||
*
|
||||
* @return HLP_FIND_OK We find a compleate pattern
|
||||
* @return HLP_FIND_OK_NO_END Xe find a partial pattern (missing end)
|
||||
* @return HLP_FIND_ERROR Not find the pattern
|
||||
*/
|
||||
resultFind_te HighlightPattern::Find(int32_t start, int32_t stop, colorInformation_ts &resultat, EdnVectorBuf &buffer)
|
||||
{
|
||||
//APPL_DEBUG(" try to find the element");
|
||||
resultat.beginStart = -1;
|
||||
resultat.beginStop = -1;
|
||||
resultat.endStart = -1;
|
||||
resultat.endStop = -1;
|
||||
resultat.notEnded = false;
|
||||
resultat.patern = this;
|
||||
|
||||
// when we have only one element :
|
||||
if (false == m_haveStopPatern) {
|
||||
if (true == m_regExpStart->ProcessOneElement(buffer, start, stop)) {
|
||||
resultat.beginStart = m_regExpStart->Start();
|
||||
resultat.beginStop = m_regExpStart->Stop();
|
||||
resultat.endStart = m_regExpStart->Start();
|
||||
resultat.endStop = m_regExpStart->Stop();
|
||||
return HLP_FIND_OK;
|
||||
}
|
||||
//APPL_DEBUG("NOT find hightlightpatern ...");
|
||||
} else {
|
||||
// try while we find the first element
|
||||
if (true == m_regExpStart->ProcessOneElement(buffer, start, stop, m_escapeChar)) {
|
||||
resultat.beginStart = m_regExpStart->Start();
|
||||
resultat.beginStop = m_regExpStart->Stop();
|
||||
if (true == m_regExpStop->Process(buffer, resultat.beginStop, stop, m_escapeChar)) {
|
||||
resultat.endStart = m_regExpStop->Start();
|
||||
resultat.endStop = m_regExpStop->Stop();
|
||||
return HLP_FIND_OK;
|
||||
} else {
|
||||
resultat.endStart = stop+1;
|
||||
resultat.endStop = stop+1;
|
||||
resultat.notEnded = true;
|
||||
return HLP_FIND_OK_NO_END;
|
||||
}
|
||||
}
|
||||
//APPL_DEBUG("NOT find start hightlightpatern ...");
|
||||
}
|
||||
return HLP_FIND_ERROR;
|
||||
}
|
90
sources/appl/Highlight/HighlightPattern.h
Normal file
90
sources/appl/Highlight/HighlightPattern.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file HighlightPattern.h
|
||||
* @brief Editeur De N'ours : Hightlight Patern (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <Highlight.h>
|
||||
|
||||
#ifndef __HIGHLIGHT_PATTERN_H__
|
||||
#define __HIGHLIGHT_PATTERN_H__
|
||||
|
||||
class HighlightPattern;
|
||||
|
||||
|
||||
#include <etk/RegExp.h>
|
||||
#include <Colorize.h>
|
||||
#include <etk/Vector.h>
|
||||
#include <tinyXML/tinyxml.h>
|
||||
#include <EdnVectorBuf.h>
|
||||
|
||||
typedef enum {
|
||||
HLP_FIND_ERROR,
|
||||
HLP_FIND_OK,
|
||||
HLP_FIND_OK_NO_END,
|
||||
}resultFind_te;
|
||||
|
||||
class HighlightPattern;
|
||||
|
||||
class HighlightPattern {
|
||||
public:
|
||||
// Constructeur
|
||||
HighlightPattern(void);
|
||||
~HighlightPattern(void);
|
||||
|
||||
void SetName(etk::UString &name) { m_paternName = name;};
|
||||
etk::UString GetName(void) { return m_paternName;};
|
||||
|
||||
void SetPaternStart(etk::UString ®Exp);
|
||||
void SetPaternStop(etk::UString ®Exp);
|
||||
void SetColor(etk::UString &colorName);
|
||||
void SetEscapeChar(etk::UString &EscapeChar);
|
||||
void SetMultiline(bool enable) { m_multiline = enable; };
|
||||
|
||||
void SetLevel(int32_t newLevel) { m_level = newLevel; };
|
||||
int32_t GetLevel(void) { return m_level; };
|
||||
|
||||
bool IsEnable(void);
|
||||
void Display(void);
|
||||
resultFind_te Find(int32_t start, int32_t stop, colorInformation_ts &resultat, EdnVectorBuf &buffer);
|
||||
Colorize * GetColor(void) { return m_color; };
|
||||
void ParseRules(TiXmlNode *child, int32_t level);
|
||||
|
||||
void ReloadColor(void);
|
||||
|
||||
private:
|
||||
int32_t m_level; //!< Level of the pattern ==> this is to overwrite next pattern when we create an higher ....
|
||||
etk::UString m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
|
||||
etk::UString m_colorName; //!< Current color name
|
||||
Colorize * m_color; //!< Link to the color manager
|
||||
etk::RegExp<EdnVectorBuf> * m_regExpStart; //!< Start of Regular expression
|
||||
etk::RegExp<EdnVectorBuf> * m_regExpStop; //!< Stop of Regular Expression
|
||||
bool m_haveStopPatern; //!< Stop patern presence
|
||||
bool m_multiline; //!< The patern is multiline
|
||||
uniChar_t m_escapeChar; //!< Escape char to prevent exeit of patern ....
|
||||
etk::Vector<HighlightPattern *> m_subPatern; //!< Under patern of this one
|
||||
// etk::Vector<HighlightPattern *> m_subColor; //!< Under Color in the start RegExp ...
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
313
sources/appl/ctags/CTagsManager.cpp
Normal file
313
sources/appl/ctags/CTagsManager.cpp
Normal file
@@ -0,0 +1,313 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file CTagsManager.cpp
|
||||
* @brief Editeur De N'ours : Ctags manager : acces to the ctags file (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 15/07/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <CTagsManager.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
#include <ewol/widget/meta/FileChooser.h>
|
||||
#include <appl/Gui/TagFileSelection.h>
|
||||
|
||||
// TODO : The line ID is no more stored in the file system (FSNode) ...
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "CTagsManager"
|
||||
|
||||
class CTagsManager: public ewol::EObject
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
CTagsManager(void);
|
||||
~CTagsManager(void);
|
||||
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void)
|
||||
{
|
||||
return "CTagsManager";
|
||||
};
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
|
||||
int32_t m_currentSelectedID;
|
||||
void LoadTagFile(void);
|
||||
int32_t MultipleJump(void);
|
||||
void JumpTo(void);
|
||||
void PrintTag(const tagEntry *entry);
|
||||
etk::UString GetFolder(etk::UString &inputString);
|
||||
etk::UString m_tagFolderBase;
|
||||
etk::UString m_tagFilename;
|
||||
tagFile * m_ctagFile;
|
||||
// history system
|
||||
int32_t m_historyPos;
|
||||
etk::Vector<etk::FSNode*> m_historyList;
|
||||
void RegisterHistory(void);
|
||||
};
|
||||
|
||||
static CTagsManager* s_elementPointer = NULL;
|
||||
void cTagsManager::Init(void)
|
||||
{
|
||||
if (NULL != s_elementPointer) {
|
||||
s_elementPointer = NULL;
|
||||
EWOL_WARNING("Ctags manager already instanciate ... ==> restart IT (can have memory leek ...)");
|
||||
}
|
||||
s_elementPointer = new CTagsManager();
|
||||
if (NULL == s_elementPointer) {
|
||||
EWOL_ERROR("Ctags manager error to instanciate ...");
|
||||
}
|
||||
}
|
||||
void cTagsManager::UnInit(void)
|
||||
{
|
||||
if (NULL != s_elementPointer) {
|
||||
delete(s_elementPointer);
|
||||
s_elementPointer = NULL;
|
||||
} else {
|
||||
EWOL_ERROR("Ctags manager not instanciate ... ==> can not remove it ...");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
CTagsManager::CTagsManager(void)
|
||||
{
|
||||
m_tagFilename = "";
|
||||
m_tagFolderBase = "";
|
||||
m_ctagFile = NULL;
|
||||
m_historyPos = 0;
|
||||
RegisterMultiCast(ednMsgGuiCtags);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
RegisterMultiCast(ednMsgCtagsLoadFile);
|
||||
EWOL_INFO("Ctags manager (INIT)");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
CTagsManager::~CTagsManager(void)
|
||||
{
|
||||
EWOL_INFO("Ctags manager (Un-INIT)");
|
||||
if(0 != m_historyList.Size()) {
|
||||
for (int32_t iii=0; iii< m_historyList.Size(); iii++) {
|
||||
delete(m_historyList[iii]);
|
||||
}
|
||||
m_historyList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
const char * ednEventPopUpCtagsLoadFile = "edn-event-load-ctags";
|
||||
|
||||
void CTagsManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
//EWOL_INFO("ctags manager event ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
|
||||
if (eventId == ednMsgBufferId) {
|
||||
//m_currentSelectedID = dataID;
|
||||
} else if( eventId == ednEventPopUpCtagsLoadFile
|
||||
|| eventId == ednMsgCtagsLoadFile) {
|
||||
// open the new one :
|
||||
etk::FSNode tmpFilename = data;
|
||||
m_tagFilename = tmpFilename.GetNameFile();
|
||||
m_tagFolderBase = tmpFilename.GetNameFolder();
|
||||
APPL_DEBUG("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " ");
|
||||
LoadTagFile();
|
||||
} else if (eventId == ednMsgGuiCtags) {
|
||||
if (data == "Load") {
|
||||
APPL_INFO("Request opening ctag file");
|
||||
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
|
||||
if (NULL == tmpWidget) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
tmpWidget->SetTitle("Open Exuberant Ctags File");
|
||||
tmpWidget->SetValidateLabel("Open");
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpCtagsLoadFile);
|
||||
}
|
||||
} else if (data == "ReLoad") {
|
||||
APPL_INFO("Request re-load ctag file");
|
||||
LoadTagFile();
|
||||
} else if (data == "Jump") {
|
||||
JumpTo();
|
||||
} else if (data == "Back") {
|
||||
if (m_historyList.Size() > 0) {
|
||||
int32_t id = m_historyList.Size()-1;
|
||||
SendMultiCast(ednMsgOpenFile, m_historyList[id]->GetName() );
|
||||
SendMultiCast(ednMsgGuiGotoLine, 0);// TODO : m_historyList[id]->GetLineNumber());
|
||||
// Remove element ....
|
||||
delete(m_historyList[id]);
|
||||
m_historyList[id]=NULL;
|
||||
m_historyList.PopBack();
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
} else if (eventId == applEventctagsSelection) {
|
||||
// save the current file in the history
|
||||
RegisterHistory();
|
||||
// parse the input data
|
||||
char tmp[4096];
|
||||
int32_t lineID;
|
||||
sscanf(data.c_str(), "%d:%s", &lineID, tmp);
|
||||
// generate envents
|
||||
SendMultiCast(ednMsgOpenFile, tmp);
|
||||
SendMultiCast(ednMsgGuiGotoLine, lineID - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CTagsManager::LoadTagFile(void)
|
||||
{
|
||||
tagFileInfo info;
|
||||
|
||||
// close previous tag file
|
||||
if (NULL != m_ctagFile) {
|
||||
tagsClose(m_ctagFile);
|
||||
m_ctagFile = NULL;
|
||||
}
|
||||
if (m_tagFilename == "") {
|
||||
return;
|
||||
}
|
||||
// load (open) the tag file :
|
||||
APPL_INFO("try to open tag file : " << m_tagFilename);
|
||||
m_ctagFile = tagsOpen(m_tagFilename.c_str(), &info);
|
||||
if (NULL != m_ctagFile) {
|
||||
APPL_INFO("open exuberant Ctags file is OK ...");
|
||||
} else {
|
||||
APPL_INFO("Error to open ctags file ...");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CTagsManager::RegisterHistory(void)
|
||||
{
|
||||
APPL_INFO("save curent filename and position : ");
|
||||
int32_t currentSelected = BufferManager::GetSelected();
|
||||
Buffer* tmpBuf = BufferManager::Get(currentSelected);
|
||||
if (NULL != tmpBuf) {
|
||||
etk::FSNode * bufferFilename = new etk::FSNode();
|
||||
*bufferFilename = tmpBuf->GetFileName();
|
||||
// TODO : bufferFilename->SetLineNumber(tmpBuf->GetCurrentLine());
|
||||
m_historyList.PushBack(bufferFilename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CTagsManager::JumpTo(void)
|
||||
{
|
||||
if (NULL != m_ctagFile) {
|
||||
// get the middle button of the clipboard ==> represent the current selection ...
|
||||
etk::UString data = ewol::clipBoard::Get(ewol::clipBoard::CLIPBOARD_SELECTION);
|
||||
APPL_DEBUG("clipboard data : \"" << data << "\"");
|
||||
if (data.Size() == 0) {
|
||||
APPL_INFO("No current selection");
|
||||
}
|
||||
tagEntry entry;
|
||||
APPL_INFO("try to find the tag : " << data);
|
||||
if (tagsFind (m_ctagFile, &entry, data.c_str(), 0) == TagSuccess) {
|
||||
tagEntry entrySave = entry;
|
||||
int32_t numberOfTags = 0;
|
||||
|
||||
// For all tags : Save in an internal Structure :
|
||||
etk::UString tmpFile(m_tagFolderBase + "/" + entry.file);
|
||||
etk::FSNode myfile(tmpFile);
|
||||
int32_t lineID = entry.address.lineNumber;
|
||||
PrintTag(&entry);
|
||||
|
||||
if (tagsFindNext (m_ctagFile, &entry) == TagSuccess) {
|
||||
APPL_INFO("Multiple file destination ...");
|
||||
appl::TagFileSelection* tmpWidget = new appl::TagFileSelection();
|
||||
if (NULL == tmpWidget) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
tmpWidget->AddCtagsNewItem(myfile.GetName(), lineID);
|
||||
do {
|
||||
tmpFile = m_tagFolderBase + "/" + entry.file;
|
||||
myfile = tmpFile;
|
||||
lineID = entry.address.lineNumber;
|
||||
PrintTag(&entry);
|
||||
tmpWidget->AddCtagsNewItem(myfile.GetName(), lineID);
|
||||
} while (tagsFindNext (m_ctagFile, &entry) == TagSuccess);
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
tmpWidget->RegisterOnEvent(this, applEventctagsSelection);
|
||||
}
|
||||
} else {
|
||||
RegisterHistory();
|
||||
APPL_INFO(" OPEN the TAG file Destination : " << tmpFile );
|
||||
SendMultiCast(ednMsgOpenFile, myfile.GetName());
|
||||
SendMultiCast(ednMsgGuiGotoLine, lineID - 1);
|
||||
}
|
||||
} else {
|
||||
APPL_INFO("no tag find ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CTagsManager::PrintTag(const tagEntry *entry)
|
||||
{
|
||||
#if 1
|
||||
APPL_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file
|
||||
<< "\" at line="<< (int32_t)entry->address.lineNumber);
|
||||
#else
|
||||
int i;
|
||||
APPL_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file
|
||||
<< "\" pattern=\"" << entry->address.pattern
|
||||
<< "\" at line="<< (int32_t)entry->address.lineNumber);
|
||||
|
||||
APPL_INFO("Extention field : ");
|
||||
if (entry->kind != NULL && entry->kind [0] != '\0') {
|
||||
APPL_INFO(" kind : " << entry->kind);
|
||||
}
|
||||
if (entry->fileScope) {
|
||||
APPL_INFO(" file : ");
|
||||
}
|
||||
for (i = 0 ; i < entry->fields.count ; ++i) {
|
||||
APPL_INFO(" " << entry->fields.list[i].key << ":" << entry->fields.list[i].value );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
43
sources/appl/ctags/CTagsManager.h
Normal file
43
sources/appl/ctags/CTagsManager.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file CTagsManager.h
|
||||
* @brief Editeur De N'ours : Ctags manager : acces to the ctags file (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 15/07/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __C_TAGS_MANAGER_H__
|
||||
#define __C_TAGS_MANAGER_H__
|
||||
|
||||
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include "appl/globalMsg.h"
|
||||
#include "readtags.h"
|
||||
|
||||
#define MAX_REG_EXP_SEARCH (1024)
|
||||
|
||||
namespace cTagsManager
|
||||
{
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
959
sources/appl/ctags/readtags.cpp
Normal file
959
sources/appl/ctags/readtags.cpp
Normal file
@@ -0,0 +1,959 @@
|
||||
/*
|
||||
* $Id: readtags.c 592 2007-07-31 03:30:41Z dhiebert $
|
||||
*
|
||||
* Copyright (c) 1996-2003, Darren Hiebert
|
||||
*
|
||||
* This source code is released into the public domain.
|
||||
*
|
||||
* This module contains functions for reading tag files.
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h> /* to declare off_t */
|
||||
|
||||
#include "readtags.h"
|
||||
|
||||
/*
|
||||
* MACROS
|
||||
*/
|
||||
#define TAB '\t'
|
||||
|
||||
|
||||
/*
|
||||
* DATA DECLARATIONS
|
||||
*/
|
||||
typedef struct {
|
||||
size_t size;
|
||||
char *buffer;
|
||||
} vstring;
|
||||
|
||||
/* Information about current tag file */
|
||||
struct sTagFile {
|
||||
/* has the file been opened and this structure initialized? */
|
||||
short initialized;
|
||||
/* format of tag file */
|
||||
short format;
|
||||
/* how is the tag file sorted? */
|
||||
sortType sortMethod;
|
||||
/* pointer to file structure */
|
||||
FILE* fp;
|
||||
/* file position of first character of `line' */
|
||||
off_t pos;
|
||||
/* size of tag file in seekable positions */
|
||||
off_t size;
|
||||
/* last line read */
|
||||
vstring line;
|
||||
/* name of tag in last line read */
|
||||
vstring name;
|
||||
/* defines tag search state */
|
||||
struct {
|
||||
/* file position of last match for tag */
|
||||
off_t pos;
|
||||
/* name of tag last searched for */
|
||||
char *name;
|
||||
/* length of name for partial matches */
|
||||
size_t nameLength;
|
||||
/* peforming partial match */
|
||||
short partial;
|
||||
/* ignoring case */
|
||||
short ignorecase;
|
||||
} search;
|
||||
/* miscellaneous extension fields */
|
||||
struct {
|
||||
/* number of entries in `list' */
|
||||
unsigned short max;
|
||||
/* list of key value pairs */
|
||||
tagExtensionField *list;
|
||||
} fields;
|
||||
/* buffers to be freed at close */
|
||||
struct {
|
||||
/* name of program author */
|
||||
char *author;
|
||||
/* name of program */
|
||||
char *name;
|
||||
/* URL of distribution */
|
||||
char *url;
|
||||
/* program version */
|
||||
char *version;
|
||||
} program;
|
||||
};
|
||||
|
||||
/*
|
||||
* DATA DEFINITIONS
|
||||
*/
|
||||
const char *const EmptyString = "";
|
||||
const char *const PseudoTagPrefix = "!_";
|
||||
|
||||
/*
|
||||
* FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Compare two strings, ignoring case.
|
||||
* Return 0 for match, < 0 for smaller, > 0 for bigger
|
||||
* Make sure case is folded to uppercase in comparison (like for 'sort -f')
|
||||
* This makes a difference when one of the chars lies between upper and lower
|
||||
* ie. one of the chars [ \ ] ^ _ ` for ascii. (The '_' in particular !)
|
||||
*/
|
||||
static int struppercmp (const char *s1, const char *s2)
|
||||
{
|
||||
int result;
|
||||
do
|
||||
{
|
||||
result = toupper ((int) *s1) - toupper ((int) *s2);
|
||||
} while (result == 0 && *s1++ != '\0' && *s2++ != '\0');
|
||||
return result;
|
||||
}
|
||||
|
||||
static int strnuppercmp (const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
int result;
|
||||
do
|
||||
{
|
||||
result = toupper ((int) *s1) - toupper ((int) *s2);
|
||||
} while (result == 0 && --n > 0 && *s1++ != '\0' && *s2++ != '\0');
|
||||
return result;
|
||||
}
|
||||
|
||||
static int growString (vstring *s)
|
||||
{
|
||||
int result = 0;
|
||||
size_t newLength;
|
||||
char *newLine;
|
||||
if (s->size == 0)
|
||||
{
|
||||
newLength = 128;
|
||||
newLine = (char*) malloc (newLength);
|
||||
*newLine = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
newLength = 2 * s->size;
|
||||
newLine = (char*) realloc (s->buffer, newLength);
|
||||
}
|
||||
if (newLine == NULL)
|
||||
perror ("string too large");
|
||||
else
|
||||
{
|
||||
s->buffer = newLine;
|
||||
s->size = newLength;
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Copy name of tag out of tag line */
|
||||
static void copyName (tagFile *const file)
|
||||
{
|
||||
size_t length;
|
||||
const char *end = strchr (file->line.buffer, '\t');
|
||||
if (end == NULL)
|
||||
{
|
||||
end = strchr (file->line.buffer, '\n');
|
||||
if (end == NULL)
|
||||
end = strchr (file->line.buffer, '\r');
|
||||
}
|
||||
if (end != NULL)
|
||||
length = end - file->line.buffer;
|
||||
else
|
||||
length = strlen (file->line.buffer);
|
||||
while (length >= file->name.size)
|
||||
growString (&file->name);
|
||||
strncpy (file->name.buffer, file->line.buffer, length);
|
||||
file->name.buffer [length] = '\0';
|
||||
}
|
||||
|
||||
static int readTagLineRaw (tagFile *const file)
|
||||
{
|
||||
int result = 1;
|
||||
int reReadLine;
|
||||
|
||||
/* If reading the line places any character other than a null or a
|
||||
* newline at the last character position in the buffer (one less than
|
||||
* the buffer size), then we must resize the buffer and reattempt to read
|
||||
* the line.
|
||||
*/
|
||||
do
|
||||
{
|
||||
char *const pLastChar = file->line.buffer + file->line.size - 2;
|
||||
char *line;
|
||||
|
||||
file->pos = ftell (file->fp);
|
||||
reReadLine = 0;
|
||||
*pLastChar = '\0';
|
||||
line = fgets (file->line.buffer, (int) file->line.size, file->fp);
|
||||
if (line == NULL)
|
||||
{
|
||||
/* read error */
|
||||
if (! feof (file->fp))
|
||||
perror ("readTagLine");
|
||||
result = 0;
|
||||
}
|
||||
else if (*pLastChar != '\0' &&
|
||||
*pLastChar != '\n' && *pLastChar != '\r')
|
||||
{
|
||||
/* buffer overflow */
|
||||
growString (&file->line);
|
||||
fseek (file->fp, file->pos, SEEK_SET);
|
||||
reReadLine = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t i = strlen (file->line.buffer);
|
||||
while (i > 0 &&
|
||||
(file->line.buffer [i - 1] == '\n' || file->line.buffer [i - 1] == '\r'))
|
||||
{
|
||||
file->line.buffer [i - 1] = '\0';
|
||||
--i;
|
||||
}
|
||||
}
|
||||
} while (reReadLine && result);
|
||||
if (result)
|
||||
copyName (file);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int readTagLine (tagFile *const file)
|
||||
{
|
||||
int result;
|
||||
do
|
||||
{
|
||||
result = readTagLineRaw (file);
|
||||
} while (result && *file->name.buffer == '\0');
|
||||
return result;
|
||||
}
|
||||
|
||||
static tagResult growFields (tagFile *const file)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
unsigned short newCount = (unsigned short) 2 * file->fields.max;
|
||||
tagExtensionField *newFields = (tagExtensionField*)
|
||||
realloc (file->fields.list, newCount * sizeof (tagExtensionField));
|
||||
if (newFields == NULL)
|
||||
perror ("too many extension fields");
|
||||
else
|
||||
{
|
||||
file->fields.list = newFields;
|
||||
file->fields.max = newCount;
|
||||
result = TagSuccess;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void parseExtensionFields (tagFile *const file, tagEntry *const entry,
|
||||
char *const string)
|
||||
{
|
||||
char *p = string;
|
||||
while (p != NULL && *p != '\0')
|
||||
{
|
||||
while (*p == TAB)
|
||||
*p++ = '\0';
|
||||
if (*p != '\0')
|
||||
{
|
||||
char *colon;
|
||||
char *field = p;
|
||||
p = strchr (p, TAB);
|
||||
if (p != NULL)
|
||||
*p++ = '\0';
|
||||
colon = strchr (field, ':');
|
||||
if (colon == NULL)
|
||||
entry->kind = field;
|
||||
else
|
||||
{
|
||||
const char *key = field;
|
||||
const char *value = colon + 1;
|
||||
*colon = '\0';
|
||||
if (strcmp (key, "kind") == 0)
|
||||
entry->kind = value;
|
||||
else if (strcmp (key, "file") == 0)
|
||||
entry->fileScope = 1;
|
||||
else if (strcmp (key, "line") == 0)
|
||||
entry->address.lineNumber = atol (value);
|
||||
else
|
||||
{
|
||||
if (entry->fields.count == file->fields.max)
|
||||
growFields (file);
|
||||
file->fields.list [entry->fields.count].key = key;
|
||||
file->fields.list [entry->fields.count].value = value;
|
||||
++entry->fields.count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void parseTagLine (tagFile *file, tagEntry *const entry)
|
||||
{
|
||||
int i;
|
||||
char *p = file->line.buffer;
|
||||
char *tab = strchr (p, TAB);
|
||||
|
||||
entry->fields.list = NULL;
|
||||
entry->fields.count = 0;
|
||||
entry->kind = NULL;
|
||||
entry->fileScope = 0;
|
||||
|
||||
entry->name = p;
|
||||
if (tab != NULL)
|
||||
{
|
||||
*tab = '\0';
|
||||
p = tab + 1;
|
||||
entry->file = p;
|
||||
tab = strchr (p, TAB);
|
||||
if (tab != NULL)
|
||||
{
|
||||
int fieldsPresent;
|
||||
*tab = '\0';
|
||||
p = tab + 1;
|
||||
if (*p == '/' || *p == '?')
|
||||
{
|
||||
/* parse pattern */
|
||||
int delimiter = *(unsigned char*) p;
|
||||
entry->address.lineNumber = 0;
|
||||
entry->address.pattern = p;
|
||||
do
|
||||
{
|
||||
p = strchr (p + 1, delimiter);
|
||||
} while (p != NULL && *(p - 1) == '\\');
|
||||
if (p == NULL)
|
||||
{
|
||||
/* invalid pattern */
|
||||
}
|
||||
else
|
||||
++p;
|
||||
}
|
||||
else if (isdigit ((int) *(unsigned char*) p))
|
||||
{
|
||||
/* parse line number */
|
||||
entry->address.pattern = p;
|
||||
entry->address.lineNumber = atol (p);
|
||||
while (isdigit ((int) *(unsigned char*) p))
|
||||
++p;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid pattern */
|
||||
}
|
||||
fieldsPresent = (strncmp (p, ";\"", 2) == 0);
|
||||
*p = '\0';
|
||||
if (fieldsPresent)
|
||||
parseExtensionFields (file, entry, p + 2);
|
||||
}
|
||||
}
|
||||
if (entry->fields.count > 0)
|
||||
entry->fields.list = file->fields.list;
|
||||
for (i = entry->fields.count ; i < file->fields.max ; ++i)
|
||||
{
|
||||
file->fields.list [i].key = NULL;
|
||||
file->fields.list [i].value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static char *duplicate (const char *str)
|
||||
{
|
||||
char *result = NULL;
|
||||
if (str != NULL)
|
||||
{
|
||||
result = strdup (str);
|
||||
if (result == NULL)
|
||||
perror (NULL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void readPseudoTags (tagFile *const file, tagFileInfo *const info)
|
||||
{
|
||||
fpos_t startOfLine;
|
||||
const size_t prefixLength = strlen (PseudoTagPrefix);
|
||||
if (info != NULL)
|
||||
{
|
||||
info->file.format = 1;
|
||||
info->file.sort = TAG_UNSORTED;
|
||||
info->program.author = NULL;
|
||||
info->program.name = NULL;
|
||||
info->program.url = NULL;
|
||||
info->program.version = NULL;
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
fgetpos (file->fp, &startOfLine);
|
||||
if (! readTagLine (file))
|
||||
break;
|
||||
if (strncmp (file->line.buffer, PseudoTagPrefix, prefixLength) != 0)
|
||||
break;
|
||||
else
|
||||
{
|
||||
tagEntry entry;
|
||||
const char *key, *value;
|
||||
parseTagLine (file, &entry);
|
||||
key = entry.name + prefixLength;
|
||||
value = entry.file;
|
||||
if (strcmp (key, "TAG_FILE_SORTED") == 0)
|
||||
file->sortMethod = (sortType) atoi (value);
|
||||
else if (strcmp (key, "TAG_FILE_FORMAT") == 0)
|
||||
file->format = (short) atoi (value);
|
||||
else if (strcmp (key, "TAG_PROGRAM_AUTHOR") == 0)
|
||||
file->program.author = duplicate (value);
|
||||
else if (strcmp (key, "TAG_PROGRAM_NAME") == 0)
|
||||
file->program.name = duplicate (value);
|
||||
else if (strcmp (key, "TAG_PROGRAM_URL") == 0)
|
||||
file->program.url = duplicate (value);
|
||||
else if (strcmp (key, "TAG_PROGRAM_VERSION") == 0)
|
||||
file->program.version = duplicate (value);
|
||||
if (info != NULL)
|
||||
{
|
||||
info->file.format = file->format;
|
||||
info->file.sort = file->sortMethod;
|
||||
info->program.author = file->program.author;
|
||||
info->program.name = file->program.name;
|
||||
info->program.url = file->program.url;
|
||||
info->program.version = file->program.version;
|
||||
}
|
||||
}
|
||||
}
|
||||
fsetpos (file->fp, &startOfLine);
|
||||
}
|
||||
|
||||
static void gotoFirstLogicalTag (tagFile *const file)
|
||||
{
|
||||
fpos_t startOfLine;
|
||||
const size_t prefixLength = strlen (PseudoTagPrefix);
|
||||
rewind (file->fp);
|
||||
while (1)
|
||||
{
|
||||
fgetpos (file->fp, &startOfLine);
|
||||
if (! readTagLine (file))
|
||||
break;
|
||||
if (strncmp (file->line.buffer, PseudoTagPrefix, prefixLength) != 0)
|
||||
break;
|
||||
}
|
||||
fsetpos (file->fp, &startOfLine);
|
||||
}
|
||||
|
||||
static tagFile *initialize (const char *const filePath, tagFileInfo *const info)
|
||||
{
|
||||
tagFile *result = (tagFile*) calloc ((size_t) 1, sizeof (tagFile));
|
||||
if (result != NULL)
|
||||
{
|
||||
growString (&result->line);
|
||||
growString (&result->name);
|
||||
result->fields.max = 20;
|
||||
result->fields.list = (tagExtensionField*) calloc (
|
||||
result->fields.max, sizeof (tagExtensionField));
|
||||
result->fp = fopen (filePath, "r");
|
||||
if (result->fp == NULL)
|
||||
{
|
||||
free (result);
|
||||
result = NULL;
|
||||
info->status.error_number = errno;
|
||||
}
|
||||
else
|
||||
{
|
||||
fseek (result->fp, 0, SEEK_END);
|
||||
result->size = ftell (result->fp);
|
||||
rewind (result->fp);
|
||||
readPseudoTags (result, info);
|
||||
info->status.opened = 1;
|
||||
result->initialized = 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void terminate (tagFile *const file)
|
||||
{
|
||||
fclose (file->fp);
|
||||
|
||||
free (file->line.buffer);
|
||||
free (file->name.buffer);
|
||||
free (file->fields.list);
|
||||
|
||||
if (file->program.author != NULL)
|
||||
free (file->program.author);
|
||||
if (file->program.name != NULL)
|
||||
free (file->program.name);
|
||||
if (file->program.url != NULL)
|
||||
free (file->program.url);
|
||||
if (file->program.version != NULL)
|
||||
free (file->program.version);
|
||||
if (file->search.name != NULL)
|
||||
free (file->search.name);
|
||||
|
||||
memset (file, 0, sizeof (tagFile));
|
||||
|
||||
free (file);
|
||||
}
|
||||
|
||||
static tagResult readNext (tagFile *const file, tagEntry *const entry)
|
||||
{
|
||||
tagResult result;
|
||||
if (file == NULL || ! file->initialized)
|
||||
result = TagFailure;
|
||||
else if (! readTagLine (file))
|
||||
result = TagFailure;
|
||||
else
|
||||
{
|
||||
if (entry != NULL)
|
||||
parseTagLine (file, entry);
|
||||
result = TagSuccess;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static const char *readFieldValue (
|
||||
const tagEntry *const entry, const char *const key)
|
||||
{
|
||||
const char *result = NULL;
|
||||
int i;
|
||||
if (strcmp (key, "kind") == 0)
|
||||
result = entry->kind;
|
||||
else if (strcmp (key, "file") == 0)
|
||||
result = EmptyString;
|
||||
else for (i = 0 ; i < entry->fields.count && result == NULL ; ++i)
|
||||
if (strcmp (entry->fields.list [i].key, key) == 0)
|
||||
result = entry->fields.list [i].value;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int readTagLineSeek (tagFile *const file, const off_t pos)
|
||||
{
|
||||
int result = 0;
|
||||
if (fseek (file->fp, pos, SEEK_SET) == 0)
|
||||
{
|
||||
result = readTagLine (file); /* read probable partial line */
|
||||
if (pos > 0 && result)
|
||||
result = readTagLine (file); /* read complete line */
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int nameComparison (tagFile *const file)
|
||||
{
|
||||
int result;
|
||||
if (file->search.ignorecase)
|
||||
{
|
||||
if (file->search.partial)
|
||||
result = strnuppercmp (file->search.name, file->name.buffer,
|
||||
file->search.nameLength);
|
||||
else
|
||||
result = struppercmp (file->search.name, file->name.buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (file->search.partial)
|
||||
result = strncmp (file->search.name, file->name.buffer,
|
||||
file->search.nameLength);
|
||||
else
|
||||
result = strcmp (file->search.name, file->name.buffer);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void findFirstNonMatchBefore (tagFile *const file)
|
||||
{
|
||||
#define JUMP_BACK 512
|
||||
int more_lines;
|
||||
int comp;
|
||||
off_t start = file->pos;
|
||||
off_t pos = start;
|
||||
do
|
||||
{
|
||||
if (pos < (off_t) JUMP_BACK)
|
||||
pos = 0;
|
||||
else
|
||||
pos = pos - JUMP_BACK;
|
||||
more_lines = readTagLineSeek (file, pos);
|
||||
comp = nameComparison (file);
|
||||
} while (more_lines && comp == 0 && pos > 0 && pos < start);
|
||||
}
|
||||
|
||||
static tagResult findFirstMatchBefore (tagFile *const file)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
int more_lines;
|
||||
off_t start = file->pos;
|
||||
findFirstNonMatchBefore (file);
|
||||
do
|
||||
{
|
||||
more_lines = readTagLine (file);
|
||||
if (nameComparison (file) == 0)
|
||||
result = TagSuccess;
|
||||
} while (more_lines && result != TagSuccess && file->pos < start);
|
||||
return result;
|
||||
}
|
||||
|
||||
static tagResult findBinary (tagFile *const file)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
off_t lower_limit = 0;
|
||||
off_t upper_limit = file->size;
|
||||
off_t last_pos = 0;
|
||||
off_t pos = upper_limit / 2;
|
||||
while (result != TagSuccess)
|
||||
{
|
||||
if (! readTagLineSeek (file, pos))
|
||||
{
|
||||
/* in case we fell off end of file */
|
||||
result = findFirstMatchBefore (file);
|
||||
break;
|
||||
}
|
||||
else if (pos == last_pos)
|
||||
{
|
||||
/* prevent infinite loop if we backed up to beginning of file */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int comp = nameComparison (file);
|
||||
last_pos = pos;
|
||||
if (comp < 0)
|
||||
{
|
||||
upper_limit = pos;
|
||||
pos = lower_limit + ((upper_limit - lower_limit) / 2);
|
||||
}
|
||||
else if (comp > 0)
|
||||
{
|
||||
lower_limit = pos;
|
||||
pos = lower_limit + ((upper_limit - lower_limit) / 2);
|
||||
}
|
||||
else if (pos == 0)
|
||||
result = TagSuccess;
|
||||
else
|
||||
result = findFirstMatchBefore (file);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static tagResult findSequential (tagFile *const file)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
if (file->initialized)
|
||||
{
|
||||
while (result == TagFailure && readTagLine (file))
|
||||
{
|
||||
if (nameComparison (file) == 0)
|
||||
result = TagSuccess;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static tagResult find (tagFile *const file, tagEntry *const entry,
|
||||
const char *const name, const int options)
|
||||
{
|
||||
tagResult result;
|
||||
if (file->search.name != NULL)
|
||||
free (file->search.name);
|
||||
file->search.name = duplicate (name);
|
||||
file->search.nameLength = strlen (name);
|
||||
file->search.partial = (options & TAG_PARTIALMATCH) != 0;
|
||||
file->search.ignorecase = (options & TAG_IGNORECASE) != 0;
|
||||
fseek (file->fp, 0, SEEK_END);
|
||||
file->size = ftell (file->fp);
|
||||
rewind (file->fp);
|
||||
if ((file->sortMethod == TAG_SORTED && !file->search.ignorecase) ||
|
||||
(file->sortMethod == TAG_FOLDSORTED && file->search.ignorecase))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf ("<performing binary search>\n");
|
||||
#endif
|
||||
result = findBinary (file);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf ("<performing sequential search>\n");
|
||||
#endif
|
||||
result = findSequential (file);
|
||||
}
|
||||
|
||||
if (result != TagSuccess)
|
||||
file->search.pos = file->size;
|
||||
else
|
||||
{
|
||||
file->search.pos = file->pos;
|
||||
if (entry != NULL)
|
||||
parseTagLine (file, entry);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static tagResult findNext (tagFile *const file, tagEntry *const entry)
|
||||
{
|
||||
tagResult result;
|
||||
if ((file->sortMethod == TAG_SORTED && !file->search.ignorecase) ||
|
||||
(file->sortMethod == TAG_FOLDSORTED && file->search.ignorecase))
|
||||
{
|
||||
result = tagsNext (file, entry);
|
||||
if (result == TagSuccess && nameComparison (file) != 0)
|
||||
result = TagFailure;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = findSequential (file);
|
||||
if (result == TagSuccess && entry != NULL)
|
||||
parseTagLine (file, entry);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* EXTERNAL INTERFACE
|
||||
*/
|
||||
|
||||
extern tagFile *tagsOpen (const char *const filePath, tagFileInfo *const info)
|
||||
{
|
||||
return initialize (filePath, info);
|
||||
}
|
||||
|
||||
extern tagResult tagsSetSortType (tagFile *const file, const sortType type)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
if (file != NULL && file->initialized)
|
||||
{
|
||||
file->sortMethod = type;
|
||||
result = TagSuccess;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
extern tagResult tagsFirst (tagFile *const file, tagEntry *const entry)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
if (file != NULL && file->initialized)
|
||||
{
|
||||
gotoFirstLogicalTag (file);
|
||||
result = readNext (file, entry);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
extern tagResult tagsNext (tagFile *const file, tagEntry *const entry)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
if (file != NULL && file->initialized)
|
||||
result = readNext (file, entry);
|
||||
return result;
|
||||
}
|
||||
|
||||
extern const char *tagsField (const tagEntry *const entry, const char *const key)
|
||||
{
|
||||
const char *result = NULL;
|
||||
if (entry != NULL)
|
||||
result = readFieldValue (entry, key);
|
||||
return result;
|
||||
}
|
||||
|
||||
extern tagResult tagsFind (tagFile *const file, tagEntry *const entry,
|
||||
const char *const name, const int options)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
if (file != NULL && file->initialized)
|
||||
result = find (file, entry, name, options);
|
||||
return result;
|
||||
}
|
||||
|
||||
extern tagResult tagsFindNext (tagFile *const file, tagEntry *const entry)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
if (file != NULL && file->initialized)
|
||||
result = findNext (file, entry);
|
||||
return result;
|
||||
}
|
||||
|
||||
extern tagResult tagsClose (tagFile *const file)
|
||||
{
|
||||
tagResult result = TagFailure;
|
||||
if (file != NULL && file->initialized)
|
||||
{
|
||||
terminate (file);
|
||||
result = TagSuccess;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* TEST FRAMEWORK
|
||||
*/
|
||||
|
||||
#ifdef READTAGS_MAIN
|
||||
|
||||
static const char *TagFileName = "tags";
|
||||
static const char *ProgramName;
|
||||
static int extensionFields;
|
||||
static int SortOverride;
|
||||
static sortType SortMethod;
|
||||
|
||||
static void printTag (const tagEntry *entry)
|
||||
{
|
||||
int i;
|
||||
int first = 1;
|
||||
const char* separator = ";\"";
|
||||
const char* const empty = "";
|
||||
/* "sep" returns a value only the first time it is evaluated */
|
||||
#define sep (first ? (first = 0, separator) : empty)
|
||||
printf ("%s\t%s\t%s",
|
||||
entry->name, entry->file, entry->address.pattern);
|
||||
if (extensionFields)
|
||||
{
|
||||
if (entry->kind != NULL && entry->kind [0] != '\0')
|
||||
printf ("%s\tkind:%s", sep, entry->kind);
|
||||
if (entry->fileScope)
|
||||
printf ("%s\tfile:", sep);
|
||||
#if 0
|
||||
if (entry->address.lineNumber > 0)
|
||||
printf ("%s\tline:%lu", sep, entry->address.lineNumber);
|
||||
#endif
|
||||
for (i = 0 ; i < entry->fields.count ; ++i)
|
||||
printf ("%s\t%s:%s", sep, entry->fields.list [i].key,
|
||||
entry->fields.list [i].value);
|
||||
}
|
||||
putchar ('\n');
|
||||
#undef sep
|
||||
}
|
||||
|
||||
static void findTag (const char *const name, const int options)
|
||||
{
|
||||
tagFileInfo info;
|
||||
tagEntry entry;
|
||||
tagFile *const file = tagsOpen (TagFileName, &info);
|
||||
if (file == NULL)
|
||||
{
|
||||
fprintf (stderr, "%s: cannot open tag file: %s: %s\n",
|
||||
ProgramName, strerror (info.status.error_number), name);
|
||||
exit (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SortOverride)
|
||||
tagsSetSortType (file, SortMethod);
|
||||
if (tagsFind (file, &entry, name, options) == TagSuccess)
|
||||
{
|
||||
do
|
||||
{
|
||||
printTag (&entry);
|
||||
} while (tagsFindNext (file, &entry) == TagSuccess);
|
||||
}
|
||||
tagsClose (file);
|
||||
}
|
||||
}
|
||||
|
||||
static void listTags (void)
|
||||
{
|
||||
tagFileInfo info;
|
||||
tagEntry entry;
|
||||
tagFile *const file = tagsOpen (TagFileName, &info);
|
||||
if (file == NULL)
|
||||
{
|
||||
fprintf (stderr, "%s: cannot open tag file: %s: %s\n",
|
||||
ProgramName, strerror (info.status.error_number), TagFileName);
|
||||
exit (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (tagsNext (file, &entry) == TagSuccess)
|
||||
printTag (&entry);
|
||||
tagsClose (file);
|
||||
}
|
||||
}
|
||||
|
||||
const char *const Usage =
|
||||
"Find tag file entries matching specified names.\n\n"
|
||||
"Usage: %s [-ilp] [-s[0|1]] [-t file] [name(s)]\n\n"
|
||||
"Options:\n"
|
||||
" -e Include extension fields in output.\n"
|
||||
" -i Perform case-insensitive matching.\n"
|
||||
" -l List all tags.\n"
|
||||
" -p Perform partial matching.\n"
|
||||
" -s[0|1|2] Override sort detection of tag file.\n"
|
||||
" -t file Use specified tag file (default: \"tags\").\n"
|
||||
"Note that options are acted upon as encountered, so order is significant.\n";
|
||||
|
||||
extern int main (int argc, char **argv)
|
||||
{
|
||||
int options = 0;
|
||||
int actionSupplied = 0;
|
||||
int i;
|
||||
ProgramName = argv [0];
|
||||
if (argc == 1)
|
||||
{
|
||||
fprintf (stderr, Usage, ProgramName);
|
||||
exit (1);
|
||||
}
|
||||
for (i = 1 ; i < argc ; ++i)
|
||||
{
|
||||
const char *const arg = argv [i];
|
||||
if (arg [0] != '-')
|
||||
{
|
||||
findTag (arg, options);
|
||||
actionSupplied = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t j;
|
||||
for (j = 1 ; arg [j] != '\0' ; ++j)
|
||||
{
|
||||
switch (arg [j])
|
||||
{
|
||||
case 'e': extensionFields = 1; break;
|
||||
case 'i': options |= TAG_IGNORECASE; break;
|
||||
case 'p': options |= TAG_PARTIALMATCH; break;
|
||||
case 'l': listTags (); actionSupplied = 1; break;
|
||||
|
||||
case 't':
|
||||
if (arg [j+1] != '\0')
|
||||
{
|
||||
TagFileName = arg + j + 1;
|
||||
j += strlen (TagFileName);
|
||||
}
|
||||
else if (i + 1 < argc)
|
||||
TagFileName = argv [++i];
|
||||
else
|
||||
{
|
||||
fprintf (stderr, Usage, ProgramName);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
SortOverride = 1;
|
||||
++j;
|
||||
if (arg [j] == '\0')
|
||||
SortMethod = TAG_SORTED;
|
||||
else if (strchr ("012", arg[j]) != NULL)
|
||||
SortMethod = (sortType) (arg[j] - '0');
|
||||
else
|
||||
{
|
||||
fprintf (stderr, Usage, ProgramName);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "%s: unknown option: %c\n",
|
||||
ProgramName, arg[j]);
|
||||
exit (1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! actionSupplied)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: no action specified: specify tag name(s) or -l option\n",
|
||||
ProgramName);
|
||||
exit (1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* vi:set tabstop=4 shiftwidth=4: */
|
252
sources/appl/ctags/readtags.h
Normal file
252
sources/appl/ctags/readtags.h
Normal file
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* $Id: readtags.h 443 2006-05-30 04:37:13Z darren $
|
||||
*
|
||||
* Copyright (c) 1996-2003, Darren Hiebert
|
||||
*
|
||||
* This source code is released for the public domain.
|
||||
*
|
||||
* This file defines the public interface for looking up tag entries in tag
|
||||
* files.
|
||||
*
|
||||
* The functions defined in this interface are intended to provide tag file
|
||||
* support to a software tool. The tag lookups provided are sufficiently fast
|
||||
* enough to permit opening a sorted tag file, searching for a matching tag,
|
||||
* then closing the tag file each time a tag is looked up (search times are
|
||||
* on the order of hundreths of a second, even for huge tag files). This is
|
||||
* the recommended use of this library for most tool applications. Adhering
|
||||
* to this approach permits a user to regenerate a tag file at will without
|
||||
* the tool needing to detect and resynchronize with changes to the tag file.
|
||||
* Even for an unsorted 24MB tag file, tag searches take about one second.
|
||||
*/
|
||||
#ifndef READTAGS_H
|
||||
#define READTAGS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/* Options for tagsSetSortType() */
|
||||
typedef enum {
|
||||
TAG_UNSORTED, TAG_SORTED, TAG_FOLDSORTED
|
||||
} sortType ;
|
||||
|
||||
/* Options for tagsFind() */
|
||||
#define TAG_FULLMATCH 0x0
|
||||
#define TAG_PARTIALMATCH 0x1
|
||||
|
||||
#define TAG_OBSERVECASE 0x0
|
||||
#define TAG_IGNORECASE 0x2
|
||||
|
||||
/*
|
||||
* DATA DECLARATIONS
|
||||
*/
|
||||
|
||||
typedef enum { TagFailure = 0, TagSuccess = 1 } tagResult;
|
||||
|
||||
struct sTagFile;
|
||||
|
||||
typedef struct sTagFile tagFile;
|
||||
|
||||
/* This structure contains information about the tag file. */
|
||||
typedef struct {
|
||||
|
||||
struct {
|
||||
/* was the tag file successfully opened? */
|
||||
int opened;
|
||||
|
||||
/* errno value when 'opened' is false */
|
||||
int error_number;
|
||||
} status;
|
||||
|
||||
/* information about the structure of the tag file */
|
||||
struct {
|
||||
/* format of tag file (1 = original, 2 = extended) */
|
||||
short format;
|
||||
|
||||
/* how is the tag file sorted? */
|
||||
sortType sort;
|
||||
} file;
|
||||
|
||||
|
||||
/* information about the program which created this tag file */
|
||||
struct {
|
||||
/* name of author of generating program (may be null) */
|
||||
const char *author;
|
||||
|
||||
/* name of program (may be null) */
|
||||
const char *name;
|
||||
|
||||
/* URL of distribution (may be null) */
|
||||
const char *url;
|
||||
|
||||
/* program version (may be null) */
|
||||
const char *version;
|
||||
} program;
|
||||
|
||||
} tagFileInfo;
|
||||
|
||||
/* This structure contains information about an extension field for a tag.
|
||||
* These exist at the end of the tag in the form "key:value").
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/* the key of the extension field */
|
||||
const char *key;
|
||||
|
||||
/* the value of the extension field (may be an empty string) */
|
||||
const char *value;
|
||||
|
||||
} tagExtensionField;
|
||||
|
||||
/* This structure contains information about a specific tag. */
|
||||
typedef struct {
|
||||
|
||||
/* name of tag */
|
||||
const char *name;
|
||||
|
||||
/* path of source file containing definition of tag */
|
||||
const char *file;
|
||||
|
||||
/* address for locating tag in source file */
|
||||
struct {
|
||||
/* pattern for locating source line
|
||||
* (may be NULL if not present) */
|
||||
const char *pattern;
|
||||
|
||||
/* line number in source file of tag definition
|
||||
* (may be zero if not known) */
|
||||
unsigned long lineNumber;
|
||||
} address;
|
||||
|
||||
/* kind of tag (may by name, character, or NULL if not known) */
|
||||
const char *kind;
|
||||
|
||||
/* is tag of file-limited scope? */
|
||||
short fileScope;
|
||||
|
||||
/* miscellaneous extension fields */
|
||||
struct {
|
||||
/* number of entries in `list' */
|
||||
unsigned short count;
|
||||
|
||||
/* list of key value pairs */
|
||||
tagExtensionField *list;
|
||||
} fields;
|
||||
|
||||
} tagEntry;
|
||||
|
||||
|
||||
/*
|
||||
* FUNCTION PROTOTYPES
|
||||
*/
|
||||
|
||||
/*
|
||||
* This function must be called before calling other functions in this
|
||||
* library. It is passed the path to the tag file to read and a (possibly
|
||||
* null) pointer to a structure which, if not null, will be populated with
|
||||
* information about the tag file. If successful, the function will return a
|
||||
* handle which must be supplied to other calls to read information from the
|
||||
* tag file, and info.status.opened will be set to true. If unsuccessful,
|
||||
* info.status.opened will be set to false and info.status.error_number will
|
||||
* be set to the errno value representing the system error preventing the tag
|
||||
* file from being successfully opened.
|
||||
*/
|
||||
extern tagFile *tagsOpen (const char *const filePath, tagFileInfo *const info);
|
||||
|
||||
/*
|
||||
* This function allows the client to override the normal automatic detection
|
||||
* of how a tag file is sorted. Permissible values for `type' are
|
||||
* TAG_UNSORTED, TAG_SORTED, TAG_FOLDSORTED. Tag files in the new extended
|
||||
* format contain a key indicating whether or not they are sorted. However,
|
||||
* tag files in the original format do not contain such a key even when
|
||||
* sorted, preventing this library from taking advantage of fast binary
|
||||
* lookups. If the client knows that such an unmarked tag file is indeed
|
||||
* sorted (or not), it can override the automatic detection. Note that
|
||||
* incorrect lookup results will result if a tag file is marked as sorted when
|
||||
* it actually is not. The function will return TagSuccess if called on an
|
||||
* open tag file or TagFailure if not.
|
||||
*/
|
||||
extern tagResult tagsSetSortType (tagFile *const file, const sortType type);
|
||||
|
||||
/*
|
||||
* Reads the first tag in the file, if any. It is passed the handle to an
|
||||
* opened tag file and a (possibly null) pointer to a structure which, if not
|
||||
* null, will be populated with information about the first tag file entry.
|
||||
* The function will return TagSuccess another tag entry is found, or
|
||||
* TagFailure if not (i.e. it reached end of file).
|
||||
*/
|
||||
extern tagResult tagsFirst (tagFile *const file, tagEntry *const entry);
|
||||
|
||||
/*
|
||||
* Step to the next tag in the file, if any. It is passed the handle to an
|
||||
* opened tag file and a (possibly null) pointer to a structure which, if not
|
||||
* null, will be populated with information about the next tag file entry. The
|
||||
* function will return TagSuccess another tag entry is found, or TagFailure
|
||||
* if not (i.e. it reached end of file). It will always read the first tag in
|
||||
* the file immediately after calling tagsOpen().
|
||||
*/
|
||||
extern tagResult tagsNext (tagFile *const file, tagEntry *const entry);
|
||||
|
||||
/*
|
||||
* Retrieve the value associated with the extension field for a specified key.
|
||||
* It is passed a pointer to a structure already populated with values by a
|
||||
* previous call to tagsNext(), tagsFind(), or tagsFindNext(), and a string
|
||||
* containing the key of the desired extension field. If no such field of the
|
||||
* specified key exists, the function will return null.
|
||||
*/
|
||||
extern const char *tagsField (const tagEntry *const entry, const char *const key);
|
||||
|
||||
/*
|
||||
* Find the first tag matching `name'. The structure pointed to by `entry'
|
||||
* will be populated with information about the tag file entry. If a tag file
|
||||
* is sorted using the C locale, a binary search algorithm is used to search
|
||||
* the tag file, resulting in very fast tag lookups, even in huge tag files.
|
||||
* Various options controlling the matches can be combined by bit-wise or-ing
|
||||
* certain values together. The available values are:
|
||||
*
|
||||
* TAG_PARTIALMATCH
|
||||
* Tags whose leading characters match `name' will qualify.
|
||||
*
|
||||
* TAG_FULLMATCH
|
||||
* Only tags whose full lengths match `name' will qualify.
|
||||
*
|
||||
* TAG_IGNORECASE
|
||||
* Matching will be performed in a case-insenstive manner. Note that
|
||||
* this disables binary searches of the tag file.
|
||||
*
|
||||
* TAG_OBSERVECASE
|
||||
* Matching will be performed in a case-senstive manner. Note that
|
||||
* this enables binary searches of the tag file.
|
||||
*
|
||||
* The function will return TagSuccess if a tag matching the name is found, or
|
||||
* TagFailure if not.
|
||||
*/
|
||||
extern tagResult tagsFind (tagFile *const file, tagEntry *const entry, const char *const name, const int options);
|
||||
|
||||
/*
|
||||
* Find the next tag matching the name and options supplied to the most recent
|
||||
* call to tagsFind() for the same tag file. The structure pointed to by
|
||||
* `entry' will be populated with information about the tag file entry. The
|
||||
* function will return TagSuccess if another tag matching the name is found,
|
||||
* or TagFailure if not.
|
||||
*/
|
||||
extern tagResult tagsFindNext (tagFile *const file, tagEntry *const entry);
|
||||
|
||||
/*
|
||||
* Call tagsTerminate() at completion of reading the tag file, which will
|
||||
* close the file and free any internal memory allocated. The function will
|
||||
* return TagFailure is no file is currently open, TagSuccess otherwise.
|
||||
*/
|
||||
extern tagResult tagsClose (tagFile *const file);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* vi:set tabstop=4 shiftwidth=4: */
|
245
sources/appl/global.cpp
Normal file
245
sources/appl/global.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tools_Globals.cpp
|
||||
* @brief Editeur De N'ours : Globals Values
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/global.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <appl/globalMsg.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
#include <ewol/ResourceManager.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "globals"
|
||||
|
||||
|
||||
|
||||
|
||||
erreurCode_te globals::init(void)
|
||||
{
|
||||
erreurCode_te ret = ERR_NONE;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------
|
||||
static bool displayEOL = false;
|
||||
bool globals::IsSetDisplayEndOfLine(void)
|
||||
{
|
||||
return displayEOL;
|
||||
}
|
||||
|
||||
void globals::SetDisplayEndOfLine(bool newVal)
|
||||
{
|
||||
APPL_INFO("Set EndOfLine " << newVal);
|
||||
displayEOL = newVal;
|
||||
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
static bool displaySpaceChar = true;
|
||||
bool globals::IsSetDisplaySpaceChar(void)
|
||||
{
|
||||
return displaySpaceChar;
|
||||
}
|
||||
|
||||
void globals::SetDisplaySpaceChar(bool newVal)
|
||||
{
|
||||
APPL_INFO("Set SpaceChar " << newVal);
|
||||
displaySpaceChar = newVal;
|
||||
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
|
||||
}
|
||||
// -----------------------------------------------------------
|
||||
static bool displayTabChar = true;
|
||||
bool globals::IsSetDisplayTabChar(void)
|
||||
{
|
||||
return displayTabChar;
|
||||
}
|
||||
|
||||
void globals::SetDisplayTabChar(bool newVal)
|
||||
{
|
||||
APPL_INFO("Set SpaceChar " << newVal);
|
||||
displayTabChar = newVal;
|
||||
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
static bool AutoIndent = true;
|
||||
bool globals::IsSetAutoIndent(void)
|
||||
{
|
||||
return AutoIndent;
|
||||
}
|
||||
|
||||
void globals::SetAutoIndent(bool newVal)
|
||||
{
|
||||
APPL_INFO("Set AutoIndent " << newVal);
|
||||
AutoIndent = newVal;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
|
||||
bool globals::OrderTheBufferList(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
|
||||
int32_t globals::getNbColoneBorder(void)
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
int32_t globals::getNbLineBorder(void)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
static const char * const l_changeIndentation = "edn-event-change-indentation";
|
||||
static const char * const l_changeSpace = "edn-event-change-spaces";
|
||||
static const char * const l_changeTabulation = "edn-event-change-tabulation";
|
||||
static const char * const l_changeEndOfLine = "edn-event-change-endOfLine";
|
||||
static const char * const l_changeRounded = "edn-event-change-rounded";
|
||||
|
||||
globals::ParameterGlobalsGui::ParameterGlobalsGui(void)
|
||||
{
|
||||
ewol::CheckBox* myCheckbox = NULL;
|
||||
ewol::Spacer* mySpacer = NULL;
|
||||
|
||||
mySpacer = new ewol::Spacer();
|
||||
if (NULL == mySpacer) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
mySpacer->SetExpendX(true);
|
||||
mySpacer->SetExpendY(true);
|
||||
SubWidgetAdd(mySpacer);
|
||||
}
|
||||
myCheckbox = new ewol::CheckBox("Automatic Indentation");
|
||||
if (NULL == myCheckbox) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
myCheckbox->SetExpendX(true);
|
||||
myCheckbox->SetValue(IsSetAutoIndent());
|
||||
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeIndentation);
|
||||
SubWidgetAdd(myCheckbox);
|
||||
}
|
||||
myCheckbox = new ewol::CheckBox("Display space char (' ')");
|
||||
if (NULL == myCheckbox) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
myCheckbox->SetExpendX(true);
|
||||
myCheckbox->SetValue(IsSetDisplaySpaceChar());
|
||||
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeSpace);
|
||||
SubWidgetAdd(myCheckbox);
|
||||
}
|
||||
myCheckbox = new ewol::CheckBox("Display tabulation char ('\\t')");
|
||||
if (NULL == myCheckbox) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
myCheckbox->SetExpendX(true);
|
||||
myCheckbox->SetValue(IsSetDisplayTabChar());
|
||||
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeTabulation);
|
||||
SubWidgetAdd(myCheckbox);
|
||||
}
|
||||
myCheckbox = new ewol::CheckBox("Display end of line ('\\n')");
|
||||
if (NULL == myCheckbox) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
myCheckbox->SetExpendX(true);
|
||||
myCheckbox->SetValue(IsSetDisplayEndOfLine());
|
||||
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeEndOfLine);
|
||||
SubWidgetAdd(myCheckbox);
|
||||
}
|
||||
myCheckbox = new ewol::CheckBox("switch Rounded/default");
|
||||
if (NULL == myCheckbox) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
myCheckbox->SetExpendX(true);
|
||||
myCheckbox->SetValue(IsSetDisplayEndOfLine());
|
||||
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeRounded);
|
||||
SubWidgetAdd(myCheckbox);
|
||||
}
|
||||
}
|
||||
|
||||
globals::ParameterGlobalsGui::~ParameterGlobalsGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void globals::ParameterGlobalsGui::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::SizerVert::OnReceiveMessage(CallerObject, eventId, data);
|
||||
|
||||
if (eventId == l_changeEndOfLine) {
|
||||
if (data == "true") {
|
||||
SetDisplayEndOfLine(true);
|
||||
} else {
|
||||
SetDisplayEndOfLine(false);
|
||||
}
|
||||
} else if (eventId == l_changeIndentation) {
|
||||
if (data == "true") {
|
||||
SetAutoIndent(true);
|
||||
} else {
|
||||
SetAutoIndent(false);
|
||||
}
|
||||
} else if (eventId == l_changeSpace) {
|
||||
if (data == "true") {
|
||||
SetDisplaySpaceChar(true);
|
||||
} else {
|
||||
SetDisplaySpaceChar(false);
|
||||
}
|
||||
} else if (eventId == l_changeTabulation) {
|
||||
if (data == "true") {
|
||||
SetDisplayTabChar(true);
|
||||
} else {
|
||||
SetDisplayTabChar(false);
|
||||
}
|
||||
} else if (eventId == l_changeRounded) {
|
||||
if (data == "true") {
|
||||
etk::theme::SetName("GUI", "rounded");;
|
||||
} else {
|
||||
etk::theme::SetName("GUI", "default");;
|
||||
}
|
||||
// Reload shaders and graphic system ...
|
||||
ewol::resource::ReLoadResources();
|
||||
}
|
||||
|
||||
}
|
||||
|
75
sources/appl/global.h
Normal file
75
sources/appl/global.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file appl/global.h
|
||||
* @brief Editeur De N'ours : Globals Values (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/12/2010
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __TOOLS_GLOBALS_H__
|
||||
#define __TOOLS_GLOBALS_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
|
||||
|
||||
namespace globals
|
||||
{
|
||||
erreurCode_te init(void);
|
||||
int32_t getNbColoneBorder(void);
|
||||
int32_t getNbLineBorder(void);
|
||||
|
||||
bool IsSetDisplayEndOfLine(void);
|
||||
void SetDisplayEndOfLine(bool newVal);
|
||||
|
||||
bool IsSetDisplaySpaceChar(void);
|
||||
void SetDisplaySpaceChar(bool newVal);
|
||||
|
||||
bool IsSetDisplayTabChar(void);
|
||||
void SetDisplayTabChar(bool newVal);
|
||||
|
||||
bool IsSetAutoIndent(void);
|
||||
void SetAutoIndent(bool newVal);
|
||||
|
||||
void init2(void);
|
||||
|
||||
bool OrderTheBufferList(void);
|
||||
|
||||
class ParameterGlobalsGui : public ewol::SizerVert
|
||||
{
|
||||
public :
|
||||
ParameterGlobalsGui(void);
|
||||
~ParameterGlobalsGui(void);
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
76
sources/appl/globalMsg.cpp
Normal file
76
sources/appl/globalMsg.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MsgBroadcast.cpp
|
||||
* @brief Editeur De N'ours : message beetween thread and GUI elements ... (Souces)
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/02/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/globalMsg.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Event of the gui request something :
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
extern const char* const ednMsgGuiNew = "edn-Msg-Gui-New";
|
||||
extern const char* const ednMsgGuiOpen = "edn-Msg-Gui-Open";
|
||||
extern const char* const ednMsgGuiClose = "edn-Msg-Gui-Close";
|
||||
extern const char* const ednMsgGuiSave = "edn-Msg-Gui-Save";
|
||||
extern const char* const ednMsgGuiSaveAs = "edn-Msg-Gui-SaveAs";
|
||||
extern const char* const ednMsgProperties = "edn-Msg-Gui-Properties";
|
||||
|
||||
extern const char* const ednMsgGuiUndo = "edn-Msg-Gui-Undo";
|
||||
extern const char* const ednMsgGuiRedo = "edn-Msg-Gui-Redo";
|
||||
extern const char* const ednMsgGuiCopy = "edn-Msg-Gui-Copy";
|
||||
extern const char* const ednMsgGuiCut = "edn-Msg-Gui-Cut";
|
||||
extern const char* const ednMsgGuiPaste = "edn-Msg-Gui-Paste";
|
||||
extern const char* const ednMsgGuiRm = "edn-Msg-Gui-Rm";
|
||||
extern const char* const ednMsgGuiSelect = "edn-Msg-Gui-Select";
|
||||
extern const char* const ednMsgGuiGotoLine = "edn-Msg-Gui-GotoLine";
|
||||
|
||||
extern const char* const ednMsgGuiSearch = "edn-Msg-Gui-Search";
|
||||
extern const char* const ednMsgGuiReplace = "edn-Msg-Gui-Replace";
|
||||
extern const char* const ednMsgGuiFind = "edn-Msg-Gui-Find";
|
||||
|
||||
extern const char* const ednMsgGuiChangeColor = "edn-Msg-Gui-ChangeColor";
|
||||
extern const char* const ednMsgGuiChangeCharset = "edn-Msg-Gui-ChangeCharset";
|
||||
extern const char* const ednMsgGuiShowSpaces = "edn-Msg-Gui-ShowSpaces";
|
||||
extern const char* const ednMsgGuiShowEndOfLine = "edn-Msg-Gui-ShowEndOfLine";
|
||||
|
||||
extern const char* const ednMsgGuiCtags = "edn-Msg-Gui-CTags";
|
||||
extern const char* const ednMsgCtagsLoadFile = "edn-Msg-CTags-direct-load";
|
||||
|
||||
extern const char* const ednMsgGuiReloadShader = "edn-Msg-Gui-ReloadOpenGlShader";
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Event internal :
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
extern const char* const ednMsgBufferState = "edn-Msg-Buffer-State";
|
||||
extern const char* const ednMsgBufferName = "edn-Msg-Buffer-Name";
|
||||
extern const char* const ednMsgBufferId = "edn-Msg-Buffer-Id";
|
||||
extern const char* const ednMsgCodeViewSelectedId = "edn-Msg-CodeView-Select-Id";
|
||||
extern const char* const ednMsgOpenFile = "edn-Msg-OpenFile";
|
||||
|
||||
extern const char* const ednMsgBufferListChange = "edn-Msg-BufferListChange";
|
||||
|
||||
extern const char* const ednMsgBufferColor = "edn-Msg-Buffer-Color";
|
||||
|
||||
|
78
sources/appl/globalMsg.h
Normal file
78
sources/appl/globalMsg.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file appl/globalMsg.h
|
||||
* @brief Editeur De N'ours : message beetween thread and GUI elements ... (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/02/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __MSG_BROADCAST_H__
|
||||
#define __MSG_BROADCAST_H__
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Event of the gui request something :
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
extern const char* const ednMsgGuiNew; // data : ""
|
||||
extern const char* const ednMsgGuiOpen; // data : ""
|
||||
extern const char* const ednMsgGuiClose; // data : "current" "All"
|
||||
extern const char* const ednMsgGuiSave; // data : ""
|
||||
extern const char* const ednMsgGuiSaveAs; // data : ""
|
||||
extern const char* const ednMsgProperties; // data : ""
|
||||
|
||||
extern const char* const ednMsgGuiUndo; // data : ""
|
||||
extern const char* const ednMsgGuiRedo; // data : ""
|
||||
extern const char* const ednMsgGuiCopy; // data : "STD" "Middle" "1" ... "9"
|
||||
extern const char* const ednMsgGuiCut; // data : "STD" "Middle" "1" ... "9"
|
||||
extern const char* const ednMsgGuiPaste; // data : "STD" "Middle" "1" ... "9"
|
||||
extern const char* const ednMsgGuiRm; // data : "Word" "Line" "Paragraph"
|
||||
extern const char* const ednMsgGuiSelect; // data : "ALL" "NONE"
|
||||
extern const char* const ednMsgGuiGotoLine; // data : "???" / "1" ... "999999999999"
|
||||
|
||||
extern const char* const ednMsgGuiSearch; // data : ""
|
||||
extern const char* const ednMsgGuiReplace; // data : "Normal" "All"
|
||||
extern const char* const ednMsgGuiFind; // data : "Next" "Previous" "All" "None"
|
||||
|
||||
extern const char* const ednMsgGuiChangeColor; // data : "Black" "White"
|
||||
extern const char* const ednMsgGuiChangeCharset; // data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
|
||||
extern const char* const ednMsgGuiShowSpaces; // data : "enable" "disable"
|
||||
extern const char* const ednMsgGuiShowEndOfLine; // data : "enable" "disable"
|
||||
|
||||
extern const char* const ednMsgGuiCtags; // data : "Load" "ReLoad" "Jump" "Back"
|
||||
extern const char* const ednMsgCtagsLoadFile; // data : "filename of the ctags file"
|
||||
|
||||
extern const char* const ednMsgGuiReloadShader; // data : ""
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Event internal :
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
extern const char* const ednMsgBufferState; // data : "Saved" "Modify" "HasHistory" "HasNotHistory" "HasFutureHistory" "HasNotFutureHistory"
|
||||
extern const char* const ednMsgBufferName; // data : "filename"
|
||||
extern const char* const ednMsgBufferId; // data : "0" ... "99999999999"
|
||||
extern const char* const ednMsgCodeViewSelectedId; // data : "0" ... "99999999999"
|
||||
extern const char* const ednMsgOpenFile; // data : "/Compleate/file/name.xx"
|
||||
|
||||
extern const char* const ednMsgBufferListChange; // data : ""
|
||||
|
||||
extern const char* const ednMsgBufferColor; // data : "new"
|
||||
|
||||
|
||||
#endif
|
||||
|
191
sources/appl/init.cpp
Normal file
191
sources/appl/init.cpp
Normal file
@@ -0,0 +1,191 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <etk/UString.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <etk/tool.h>
|
||||
#include <Gui/MainWindows.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <HighlightManager.h>
|
||||
#include <Gui/Search.h>
|
||||
#include <unistd.h>
|
||||
#include <readtags.h>
|
||||
#include <CTagsManager.h>
|
||||
#include <globalMsg.h>
|
||||
#include <ewol/font/FontManager.h>
|
||||
|
||||
MainWindows * basicWindows = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* @brief main application function Initialisation
|
||||
*/
|
||||
void APP_Init(void)
|
||||
{
|
||||
#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(etk::Vector2D<int32_t>(800, 600));
|
||||
etk::InitDefaultFolder(PROJECT_NAME);
|
||||
|
||||
ewol::font::SetDefaultFont("Font/freefont/FreeSerif.ttf");
|
||||
//ewol::font::SetDefaultFont("Font/ACharmingFont.ttf");
|
||||
#ifdef __TARGET_OS__Android
|
||||
ewol::font::SetDefaultSize(19);
|
||||
#else
|
||||
ewol::font::SetDefaultSize(14);
|
||||
#endif
|
||||
// init internal global value
|
||||
globals::init();
|
||||
|
||||
|
||||
// init ALL Singleton :
|
||||
//(void)CTagsManager::getInstance();
|
||||
BufferManager::Init();
|
||||
|
||||
// set color and other trucs...
|
||||
ColorizeManager::Init();
|
||||
ColorizeManager::LoadFile( "white" );
|
||||
ColorizeManager::DisplayListOfColor();
|
||||
|
||||
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';
|
||||
//APPL_INFO("The current working directory is " << cCurrentPath);
|
||||
|
||||
basicWindows = new MainWindows();
|
||||
|
||||
if (NULL == basicWindows) {
|
||||
APPL_ERROR("Can not allocate the basic windows");
|
||||
ewol::Stop();
|
||||
return;
|
||||
}
|
||||
// create the specific windows
|
||||
ewol::DisplayWindows(basicWindows);
|
||||
|
||||
// add generic shortcut ...
|
||||
// (shift, control, alt, meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data)
|
||||
ewol::shortCut::Add("ctrl+o", ednMsgGuiOpen, "");
|
||||
ewol::shortCut::Add("ctrl+n", ednMsgGuiNew, "");
|
||||
|
||||
ewol::shortCut::Add("ctrl+s", ednMsgGuiSave, "current");
|
||||
ewol::shortCut::Add("ctrl+shift+s", ednMsgGuiSave, "All");
|
||||
|
||||
ewol::shortCut::Add("ctrl+q", ednMsgGuiClose, "current");
|
||||
ewol::shortCut::Add("ctrl+shift+q", ednMsgGuiClose, "All");
|
||||
|
||||
ewol::shortCut::Add("ctrl+z", ednMsgGuiUndo, "");
|
||||
ewol::shortCut::Add("ctrl+shift+z", ednMsgGuiRedo, "");
|
||||
|
||||
ewol::shortCut::Add("ctrl+l", ednMsgGuiGotoLine, "???");
|
||||
|
||||
ewol::shortCut::Add("ctrl+f", ednMsgGuiSearch, "");
|
||||
ewol::shortCut::Add("F12", ednMsgGuiReloadShader, "");
|
||||
|
||||
ewol::shortCut::Add("ctrl+d", ednMsgGuiCtags, "Jump");
|
||||
|
||||
|
||||
// add files
|
||||
APPL_INFO("show list of files : ");
|
||||
bool ctagDetected = false;
|
||||
for( int32_t iii=0 ; iii<ewol::CmdLine::Nb(); iii++) {
|
||||
etk::UString tmpppp = ewol::CmdLine::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);
|
||||
}
|
||||
}
|
||||
|
||||
APPL_INFO("==> Init Edn (END)");
|
||||
}
|
||||
|
||||
|
||||
etk::FSNode APP_Icon(void)
|
||||
{
|
||||
etk::FSNode bitmapFile("DATA:iconEdn.bmp");
|
||||
return bitmapFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief main application function Un-Initialisation
|
||||
*/
|
||||
void APP_UnInit(void)
|
||||
{
|
||||
APPL_INFO("==> Un-Init Edn (START)");
|
||||
// Remove windows :
|
||||
ewol::DisplayWindows(NULL);
|
||||
|
||||
cTagsManager::UnInit();
|
||||
|
||||
APPL_INFO("Stop Hightlight");
|
||||
HighlightManager::UnInit();
|
||||
//Kill all singleton
|
||||
APPL_INFO("Stop BufferManager");
|
||||
BufferManager::UnInit();
|
||||
APPL_INFO("Stop ColorizeManager");
|
||||
ColorizeManager::UnInit();
|
||||
APPL_INFO("Stop Search");
|
||||
//Search::Kill();
|
||||
//APPL_INFO("Stop Accel key");
|
||||
//AccelKey::Kill();
|
||||
|
||||
if (NULL != basicWindows) {
|
||||
delete(basicWindows);
|
||||
basicWindows = NULL;
|
||||
}
|
||||
APPL_INFO("==> Un-Init Edn (END)");
|
||||
}
|
||||
|
Reference in New Issue
Block a user