create a class Edn::File that manage the modification of the falineme to get the real filename in the system ==> dit not work corectly...
This commit is contained in:
parent
55681d1dac
commit
ff055b88d4
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,6 +27,7 @@ doxygen/ALL/
|
||||
*.so
|
||||
*.pyc
|
||||
edn
|
||||
out
|
||||
edn_debug
|
||||
edn_release
|
||||
|
||||
|
@ -44,7 +44,7 @@ Buffer::Buffer()
|
||||
m_fileModify = true;
|
||||
m_haveName = false;
|
||||
Edn::String mString = "No-Name";
|
||||
m_fileName.SetCompleateName(mString);
|
||||
SetFileName(mString);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,8 +58,7 @@ Buffer::Buffer()
|
||||
Buffer::Buffer(Edn::String &newFileName)
|
||||
{
|
||||
m_fileModify = false;
|
||||
m_haveName = true;
|
||||
m_fileName.SetCompleateName(newFileName);
|
||||
SetFileName(newFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,85 +94,6 @@ void Buffer::SetModify(bool status)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Edn::File Buffer::GetFileName(void)
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Edn::String Buffer::GetName(void)
|
||||
{
|
||||
// nothing to do
|
||||
return m_fileName.GetCompleateName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Edn::String Buffer::GetShortName(void)
|
||||
{
|
||||
|
||||
// nothing to do
|
||||
return m_fileName.GetShortFilename();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Edn::String Buffer::GetFolder(void)
|
||||
{
|
||||
|
||||
// nothing to do
|
||||
return m_fileName.GetFolder();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool Buffer::HaveName(void)
|
||||
{
|
||||
// nothing to do
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Buffer::SetName(Edn::String &newName)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -47,13 +47,30 @@ class Buffer {
|
||||
Buffer(void);
|
||||
Buffer(Edn::String &filename);
|
||||
virtual ~Buffer(void);
|
||||
Edn::File GetFileName(void);
|
||||
virtual Edn::String GetName(void);
|
||||
virtual Edn::String GetShortName(void);
|
||||
virtual Edn::String GetFolder(void);
|
||||
virtual void SetName(Edn::String &newName);
|
||||
|
||||
Edn::File GetFileName(void)
|
||||
{
|
||||
return m_fileName;
|
||||
};
|
||||
|
||||
void SetFileName(Edn::File &newName)
|
||||
{
|
||||
m_fileName = newName;
|
||||
m_haveName = true;
|
||||
};
|
||||
|
||||
void SetFileName(Edn::String &newName)
|
||||
{
|
||||
m_fileName.SetCompleateName(newName);
|
||||
m_haveName = true;
|
||||
};
|
||||
|
||||
bool HaveName(void)
|
||||
{
|
||||
return m_haveName;
|
||||
}
|
||||
|
||||
virtual void Save(void);
|
||||
virtual bool HaveName(void);
|
||||
bool IsModify(void);
|
||||
protected:
|
||||
void SetModify(bool status);
|
||||
|
@ -242,7 +242,7 @@ int32_t BufferManager::GetId(Edn::String &filename)
|
||||
for (iii=0; iii < listBuffer.Size(); iii++) {
|
||||
// check if the buffer already existed
|
||||
if (NULL != listBuffer[iii]) {
|
||||
if ( listBuffer[iii]->GetName() == filename) {
|
||||
if ( listBuffer[iii]->GetFileName().GetCompleateName() == filename) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
|
@ -147,17 +147,17 @@ gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, g
|
||||
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
basicColor_te selectBG = COLOR_LIST_BG_1;
|
||||
for (i=0; i < nbBufferOpen; i++) {
|
||||
Edn::String name;
|
||||
Edn::File name;
|
||||
bool isModify;
|
||||
if (self->m_bufferManager->Exist(i)) {
|
||||
isModify = self->m_bufferManager->Get(i)->IsModify();
|
||||
name = self->m_bufferManager->Get(i)->GetShortName();
|
||||
name = self->m_bufferManager->Get(i)->GetFileName();
|
||||
char *tmpModify = (char*)" ";
|
||||
if (true == isModify) {
|
||||
tmpModify = (char*)"M";
|
||||
}
|
||||
char name2[1024] = "";
|
||||
sprintf(name2, "[%2d](%s) %s", i, tmpModify, name.c_str() );
|
||||
sprintf(name2, "[%2d](%s) %s", i, tmpModify, name.GetShortFilename().c_str() );
|
||||
|
||||
if (true == isModify) {
|
||||
selectFG = COLOR_LIST_TEXT_MODIFY;
|
||||
|
@ -93,17 +93,25 @@ MainWindows::~MainWindows(void)
|
||||
}
|
||||
|
||||
|
||||
void MainWindows::SetTitle(Edn::String &fileName, bool isModify)
|
||||
void MainWindows::SetTitle(Edn::File &fileName, bool isModify)
|
||||
{
|
||||
Edn::String tmp = "";
|
||||
if (fileName != "") {
|
||||
tmp += fileName;
|
||||
if (fileName.GetShortFilename() != "") {
|
||||
tmp += fileName.GetShortFilename();
|
||||
tmp += " - ";
|
||||
tmp += fileName.GetFolder();
|
||||
tmp += " - ";
|
||||
}
|
||||
tmp += "Edn";
|
||||
gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
|
||||
}
|
||||
|
||||
void MainWindows::SetNoTitle(void)
|
||||
{
|
||||
Edn::String tmp = "Edn";
|
||||
gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
|
||||
}
|
||||
|
||||
void MainWindows::OnMessage(int32_t id, int32_t dataID)
|
||||
{
|
||||
switch (id)
|
||||
@ -112,12 +120,11 @@ void MainWindows::OnMessage(int32_t id, int32_t dataID)
|
||||
// change Title :
|
||||
// TODO : String error when remove the error with -1;
|
||||
if (-1 == dataID) {
|
||||
Edn::String plop = "";
|
||||
SetTitle(plop, false );
|
||||
SetNoTitle();
|
||||
} else {
|
||||
Buffer *mybuf = BufferManager::getInstance()->Get(dataID);
|
||||
if (NULL != mybuf) {
|
||||
Edn::String plop = mybuf->GetName();
|
||||
Edn::File plop = mybuf->GetFileName();
|
||||
SetTitle(plop, mybuf->IsModify() );
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,8 @@ class MainWindows: public Singleton<MainWindows>, public MsgBroadcast
|
||||
static bool OnQuit(GtkWidget *widget, gpointer data);
|
||||
|
||||
private:
|
||||
void SetTitle(Edn::String &fileName, bool isModify);
|
||||
void SetTitle(Edn::File &fileName, bool isModify);
|
||||
void SetNoTitle(void);
|
||||
// main windows widget :
|
||||
GtkWidget * m_mainWindow;
|
||||
BufferView m_BufferView;
|
||||
|
@ -101,9 +101,9 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
|
||||
if( -1 != m_currentBufferID
|
||||
&& true == myBufferManager->Exist(m_currentBufferID) )
|
||||
{
|
||||
Edn::String fileFolder = myBufferManager->Get(m_currentBufferID)->GetFolder();
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(dialog), fileFolder.c_str());
|
||||
//gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(dialog), "Untitled document");
|
||||
Edn::File fileName = myBufferManager->Get(m_currentBufferID)->GetFileName();
|
||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), fileName.GetFolder().c_str());
|
||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fileName.GetShortFilename().c_str());
|
||||
}
|
||||
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
@ -132,7 +132,7 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
|
||||
}
|
||||
Buffer *myBuffer = BufferManager::getInstance()->Get(idSelected);
|
||||
Edn::String tmpString = "Save as file : ";
|
||||
tmpString += myBuffer->GetShortName().c_str();
|
||||
tmpString += myBuffer->GetFileName().GetShortFilename().c_str();
|
||||
GtkWidget *dialog = gtk_file_chooser_dialog_new( tmpString.c_str(), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
GTK_STOCK_CANCEL, // button text
|
||||
@ -145,7 +145,7 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
|
||||
Edn::String myfilename;
|
||||
myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
|
||||
|
||||
myBuffer->SetName(myfilename);
|
||||
myBuffer->SetFileName(myfilename);
|
||||
myBuffer->Save();
|
||||
|
||||
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idSelected);
|
||||
|
@ -159,9 +159,7 @@ void CTagsManager::AddToHistory(int32_t bufferID)
|
||||
}
|
||||
// add the current element
|
||||
BufferManager *myBufferManager = BufferManager::getInstance();
|
||||
Edn::String currentFilename = myBufferManager->Get(bufferID)->GetName();
|
||||
int32_t currentLineId = 0;
|
||||
Edn::File * currentFile = new Edn::File(currentFilename);
|
||||
Edn::File currentFilename = myBufferManager->Get(bufferID)->GetFileName();
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,41 +52,6 @@ Edn::File::~File(void)
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
void Edn::File::ExtranctAndName(Edn::String &inputString)
|
||||
{
|
||||
m_folder = "";
|
||||
m_shortFilename = "";
|
||||
|
||||
for (int32_t iii=inputString.Size()-1; iii >= 0 ; iii--) {
|
||||
/*
|
||||
if (inputString[iii] != '/') {
|
||||
m_shortFilename.Insert(0, inputString[iii]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
char tmpVal[4096];
|
||||
strncpy(tmpVal, inputString.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;
|
||||
out+= '/';
|
||||
}
|
||||
return out;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
Edn::String Edn::File::GetFolder(void)
|
||||
{
|
||||
@ -106,11 +71,28 @@ Edn::String Edn::File::GetCompleateName(void)
|
||||
out += m_shortFilename;
|
||||
}
|
||||
|
||||
const Edn::File& Edn::File::operator= (const Edn::File &ednF )
|
||||
{
|
||||
if( this != &ednF ) // avoid copy to itself
|
||||
{
|
||||
m_folder = ednF.m_folder;
|
||||
m_shortFilename = ednF.m_shortFilename;
|
||||
m_lineNumberOpen = ednF.m_lineNumberOpen;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Edn::File::SetCompleateName(Edn::String &newFilename)
|
||||
{
|
||||
char buf[MAX_FILE_NAME];
|
||||
memset(buf, 0, MAX_FILE_NAME);
|
||||
char * ok;
|
||||
// Reset ALL DATA :
|
||||
m_folder = "";
|
||||
m_shortFilename = "";
|
||||
m_lineNumberOpen = 0;
|
||||
|
||||
Edn::String destFilename;
|
||||
if (newFilename.Size() == 0) {
|
||||
destFilename = "no-name";
|
||||
@ -133,14 +115,44 @@ void Edn::File::SetCompleateName(Edn::String &newFilename)
|
||||
// Get the real Path of the current File
|
||||
ok = realpath(destFilename.c_str(), buf);
|
||||
if (!ok) {
|
||||
EDN_ERROR("Can not find real name of \"" << destFilename.c_str() << "\"");
|
||||
int32_t lastPos = destFilename.FindBack('/');
|
||||
if (-1 != lastPos) {
|
||||
// Get the FileName
|
||||
Edn::String tmpFilename = destFilename.Extract(lastPos+1);
|
||||
destFilename.Remove(lastPos, destFilename.Size() - lastPos);
|
||||
//EDN_DEBUG("try to find :\"" << destFilename.c_str() << "\" / \"" << tmpFilename.c_str() << "\" ");
|
||||
ok = realpath(destFilename.c_str(), buf);
|
||||
if (!ok) {
|
||||
EDN_ERROR("Can not find real Path name of \"" << destFilename.c_str() << "\"");
|
||||
m_shortFilename = tmpFilename;
|
||||
m_folder = destFilename;
|
||||
} else {
|
||||
// ALL is OK ...
|
||||
m_shortFilename = tmpFilename;
|
||||
m_folder = destFilename;
|
||||
}
|
||||
} else {
|
||||
EDN_WARNING("file : \"" << destFilename.c_str() << "\" ==> No data???");
|
||||
// Basic ERROR ...
|
||||
m_shortFilename = destFilename;
|
||||
}
|
||||
} else {
|
||||
EDN_DEBUG("file : \"" << destFilename.c_str() << "\" done:\"" << buf << "\" ");
|
||||
// TODO : try again with no name
|
||||
destFilename = buf;
|
||||
int32_t lastPos = destFilename.FindBack('/');
|
||||
if (-1 != lastPos) {
|
||||
m_shortFilename = destFilename.Extract(lastPos+1);
|
||||
m_folder = destFilename.Extract(0, lastPos);
|
||||
} else {
|
||||
// Basic ERROR ...
|
||||
EDN_WARNING("file : \"" << destFilename.c_str() << "\" ==> No data???");
|
||||
m_shortFilename = destFilename;
|
||||
}
|
||||
}
|
||||
EDN_DEBUG("Set FileName :\"" << m_folder.c_str() << "\" / \"" << m_shortFilename.c_str() << "\" ");
|
||||
}
|
||||
|
||||
int32_t Edn::File::GetLineNumber(void)
|
||||
{
|
||||
return m_lineNumberOpen;
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,10 @@ namespace Edn
|
||||
Edn::String GetCompleateName(void);
|
||||
int32_t GetLineNumber(void);
|
||||
|
||||
const Edn::File& operator= (const Edn::File &ednF );
|
||||
void SetCompleateName(Edn::String &newFilename);
|
||||
|
||||
private :
|
||||
void ExtranctAndName(Edn::String &inputString);
|
||||
Edn::String m_folder;
|
||||
Edn::String m_shortFilename;
|
||||
int32_t m_lineNumberOpen;
|
||||
|
@ -17,8 +17,8 @@
|
||||
- Project manager phase 1
|
||||
|
||||
# action a faire (ordonner) :
|
||||
- HL : Parsing caracter/caractère et plus section par section ...
|
||||
- sys : real filename ...
|
||||
- HL : Parsing caracter/caractère et plus section par section ...
|
||||
- ctags : Back simple et multiple
|
||||
- ctags : Multiple files
|
||||
- sys : search complet, replace complet
|
||||
|
Loading…
x
Reference in New Issue
Block a user