Edn::File is now implemented an integrated in the system ==> test is OK
This commit is contained in:
@@ -41,9 +41,11 @@
|
||||
*/
|
||||
Buffer::Buffer()
|
||||
{
|
||||
static int32_t fileBasicID = 0;
|
||||
m_fileModify = true;
|
||||
m_haveName = false;
|
||||
Edn::String mString = "No-Name";
|
||||
Edn::String mString = "Untitle - ";
|
||||
mString += fileBasicID++;
|
||||
SetFileName(mString);
|
||||
}
|
||||
|
||||
@@ -55,10 +57,10 @@ Buffer::Buffer()
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Buffer::Buffer(Edn::String &newFileName)
|
||||
Buffer::Buffer(Edn::File &newName)
|
||||
{
|
||||
m_fileModify = false;
|
||||
SetFileName(newFileName);
|
||||
SetFileName(newName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -45,7 +45,7 @@ typedef struct{
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer(void);
|
||||
Buffer(Edn::String &filename);
|
||||
Buffer(Edn::File &newName);
|
||||
virtual ~Buffer(void);
|
||||
|
||||
Edn::File GetFileName(void)
|
||||
@@ -105,9 +105,10 @@ class Buffer {
|
||||
virtual void JumpAtLine(int32_t newLine);
|
||||
|
||||
protected:
|
||||
bool m_fileModify;
|
||||
Edn::File m_fileName;
|
||||
bool m_haveName; //!< to know if the file have a name or NOT
|
||||
bool m_fileModify; //!<
|
||||
// naming
|
||||
Edn::File m_fileName; //!< filename of the curent buffer
|
||||
bool m_haveName; //!< to know if the file have a name or NOT
|
||||
};
|
||||
|
||||
|
||||
|
@@ -185,10 +185,11 @@ int32_t BufferManager::Create(void)
|
||||
* @todo : check if this file is not curently open and return the old ID
|
||||
*
|
||||
*/
|
||||
int32_t BufferManager::Open(Edn::String &filename)
|
||||
int32_t BufferManager::Open(Edn::File &myFile)
|
||||
{
|
||||
// TODO : Check here if the file is already open ==> and display it if needed
|
||||
// allocate a new Buffer
|
||||
Buffer *myBuffer = new BufferText(filename);
|
||||
Buffer *myBuffer = new BufferText(myFile);
|
||||
// Add at the list of element
|
||||
listBuffer.PushBack(myBuffer);
|
||||
int32_t basicID = listBuffer.Size() - 1;
|
||||
@@ -235,14 +236,23 @@ bool BufferManager::Exist(int32_t BufferID)
|
||||
}
|
||||
|
||||
|
||||
int32_t BufferManager::GetId(Edn::String &filename)
|
||||
bool BufferManager::Exist(Edn::File &myFile )
|
||||
{
|
||||
if (-1 == GetId(myFile)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int32_t BufferManager::GetId(Edn::File &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().GetCompleateName() == filename) {
|
||||
if ( listBuffer[iii]->GetFileName() == myFile) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
@@ -250,14 +260,6 @@ int32_t BufferManager::GetId(Edn::String &filename)
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool BufferManager::Exist(Edn::String &filename)
|
||||
{
|
||||
if (-1 == GetId(filename)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t BufferManager::Size(void)
|
||||
|
@@ -48,13 +48,13 @@ class BufferManager: public Singleton<BufferManager>, public MsgBroadcast
|
||||
// create a buffer with no element
|
||||
int32_t Create(void);
|
||||
// open curent filename
|
||||
int32_t Open(Edn::String &filename);
|
||||
int32_t Open(Edn::File &myFile);
|
||||
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(Edn::String &filename);
|
||||
int32_t GetId(Edn::String &filename);
|
||||
bool Exist(Edn::File &myFile);
|
||||
int32_t GetId(Edn::File &myFile);
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t Size(void);
|
||||
int32_t WitchBuffer(int32_t iEmeElement);
|
||||
|
@@ -50,16 +50,10 @@ const uint32_t nbLineAllocatedInBase = 300;
|
||||
*/
|
||||
void BufferText::BasicInit(void)
|
||||
{
|
||||
static int32_t fileBasicID = 0;
|
||||
NeedToCleanEndPage = true;
|
||||
// set the first element that is displayed
|
||||
m_displayStartBufferPos = 0;
|
||||
// set basic filename :
|
||||
filename = "Untitled ";
|
||||
filename += fileBasicID;
|
||||
// no name ...
|
||||
haveName = false;
|
||||
fileBasicID++;
|
||||
|
||||
// set the number of the lineNumber;
|
||||
nbColoneForLineNumber = 1;
|
||||
// init the link with the buffer manager
|
||||
@@ -104,16 +98,14 @@ BufferText::BufferText()
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
BufferText::BufferText(Edn::String &newFileName)
|
||||
BufferText::BufferText(Edn::File &fileName) : Buffer(fileName)
|
||||
{
|
||||
BasicInit();
|
||||
EDN_INFO("Add Data from file(" << newFileName.c_str() << ")");
|
||||
EDN_INFO("Add Data from file(" << GetFileName().GetCompleateName().c_str() << ")");
|
||||
FILE * myFile = NULL;
|
||||
// set the filename :
|
||||
SetName(newFileName);
|
||||
// try to open the file. if not existed, new file
|
||||
|
||||
myFile = fopen(newFileName.c_str(), "r");
|
||||
myFile = fopen(fileName.GetCompleateName().c_str(), "r");
|
||||
if (NULL != myFile) {
|
||||
m_EdnBuf.DumpFrom(myFile);
|
||||
// close the input file
|
||||
@@ -121,7 +113,7 @@ BufferText::BufferText(Edn::String &newFileName)
|
||||
SetModify(false);
|
||||
} else {
|
||||
// fichier inexistant... creation d'un nouveaux
|
||||
EDN_WARNING("No File ==> created a new one(" << newFileName.c_str() << ")");
|
||||
EDN_WARNING("No File ==> created a new one(" << GetFileName().GetCompleateName().c_str() << ")");
|
||||
SetModify(true);
|
||||
}
|
||||
UpdateWindowsPosition();
|
||||
@@ -139,9 +131,9 @@ BufferText::BufferText(Edn::String &newFileName)
|
||||
*/
|
||||
void BufferText::Save(void)
|
||||
{
|
||||
EDN_INFO("Save File : \"" << filename.c_str() << "\"" );
|
||||
EDN_INFO("Save File : \"" << GetFileName().GetCompleateName().c_str() << "\"" );
|
||||
FILE * myFile = NULL;
|
||||
myFile = fopen(filename.c_str(), "w");
|
||||
myFile = fopen(GetFileName().GetCompleateName().c_str(), "w");
|
||||
if (NULL != myFile) {
|
||||
m_EdnBuf.DumpIn(myFile);
|
||||
fclose(myFile);
|
||||
@@ -187,104 +179,6 @@ void BufferText::SelectionCheckMode(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Edn::String BufferText::GetName(void)
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Edn::String BufferText::GetShortName(void)
|
||||
{
|
||||
char *ptr = strrchr(filename.c_str(), '/');
|
||||
if (NULL == ptr) {
|
||||
ptr = strrchr(filename.c_str(), '\\');
|
||||
}
|
||||
Edn::String out = filename;
|
||||
if (NULL != ptr) {
|
||||
out = ptr+1;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Edn::String BufferText::GetFolder(void)
|
||||
{
|
||||
char tmpVal[4096];
|
||||
strncpy(tmpVal, filename.c_str(), 4096);
|
||||
tmpVal[4096-1] = '\0';
|
||||
char *ptr = strrchr(tmpVal, '/');
|
||||
if (NULL == ptr) {
|
||||
ptr = strrchr(tmpVal, '\\');
|
||||
}
|
||||
Edn::String out = "./";
|
||||
if (NULL != ptr) {
|
||||
*ptr = '\0';
|
||||
out = tmpVal;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool BufferText::HaveName(void)
|
||||
{
|
||||
return haveName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::SetName(Edn::String &newName)
|
||||
{
|
||||
filename = newName;
|
||||
haveName = true;
|
||||
// Find HL system
|
||||
if (true == HighlightManager::getInstance()->Exist(newName)) {
|
||||
Highlight * myHL = HighlightManager::getInstance()->Get(newName);
|
||||
// Set the new HL
|
||||
if (NULL != myHL) {
|
||||
m_EdnBuf.SetHLSystem(myHL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@@ -41,14 +41,9 @@ typedef enum {
|
||||
class BufferText : public Buffer {
|
||||
public:
|
||||
BufferText(void);
|
||||
BufferText(Edn::String &filename);
|
||||
BufferText(Edn::File &fileName);
|
||||
virtual ~BufferText(void);
|
||||
Edn::String GetName(void);
|
||||
Edn::String GetShortName(void);
|
||||
Edn::String GetFolder(void);
|
||||
void SetName(Edn::String &newName);
|
||||
void Save(void);
|
||||
bool HaveName(void);
|
||||
|
||||
void GetInfo(infoStatBuffer_ts &infoToUpdate);
|
||||
void SetLineDisplay(uint32_t lineNumber);
|
||||
@@ -80,9 +75,6 @@ class BufferText : public Buffer {
|
||||
void SetCharset(charset_te newCharset);
|
||||
|
||||
private:
|
||||
// naming
|
||||
Edn::String filename; //!< filename of the curent buffer
|
||||
bool haveName; //!< to know if the file have a name or NOT
|
||||
// Display
|
||||
bool NeedToCleanEndPage; //!< if true, the end of the page need to be clean (arrive after a remove line)
|
||||
uint32_t nbColoneForLineNumber; //!< number of colome used to display the line Number
|
||||
|
Reference in New Issue
Block a user