From 33a36fa0f7cb9a053610a7a1216e727e735dc100 Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Tue, 16 Oct 2012 18:32:21 +0200 Subject: [PATCH] [DEV][CTAGS] integration of the first ewol display version --- Sources/appl/Gui/CodeView.cpp | 20 +- Sources/appl/Gui/TagFileList.cpp | 145 +++++++++++ Sources/appl/Gui/TagFileList.h | 76 ++++++ Sources/appl/Gui/TagFileSelection.cpp | 216 +++++++++++++++++ Sources/appl/Gui/TagFileSelection.h | 79 ++++++ Sources/appl/ctags/CTagsManager.cpp | 336 +++++++++++--------------- Sources/appl/ctags/CTagsManager.h | 39 +-- Sources/appl/init.cpp | 5 + Sources/file.mk | 4 +- 9 files changed, 676 insertions(+), 244 deletions(-) create mode 100644 Sources/appl/Gui/TagFileList.cpp create mode 100644 Sources/appl/Gui/TagFileList.h create mode 100644 Sources/appl/Gui/TagFileSelection.cpp create mode 100644 Sources/appl/Gui/TagFileSelection.h diff --git a/Sources/appl/Gui/CodeView.cpp b/Sources/appl/Gui/CodeView.cpp index ac0da17..110e644 100644 --- a/Sources/appl/Gui/CodeView.cpp +++ b/Sources/appl/Gui/CodeView.cpp @@ -66,6 +66,7 @@ void CodeView::Init(void) RegisterMultiCast(ednMsgGuiChangeCharset); RegisterMultiCast(ednMsgGuiFind); RegisterMultiCast(ednMsgGuiReplace); + RegisterMultiCast(ednMsgGuiGotoLine); SetLimitScrolling(0.2); } @@ -397,21 +398,12 @@ void CodeView::OnReceiveMessage(ewol::EObject * CallerObject, const char * event } 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); } - /* - switch (id) - { - case APPL_MSG__CURRENT_GOTO_LINE: - if (dataID<0) { - dataID = 0; - } - BufferManager::Get(m_bufferID)->JumpAtLine(dataID); - break; - case APPL_MSG__CURRENT_SET_CHARSET: - BufferManager::Get(m_bufferID)->SetCharset((unicode::charset_te)dataID); - break; - } - */ // Force redraw of the widget MarkToRedraw(); } diff --git a/Sources/appl/Gui/TagFileList.cpp b/Sources/appl/Gui/TagFileList.cpp new file mode 100644 index 0000000..ac9de2e --- /dev/null +++ b/Sources/appl/Gui/TagFileList.cpp @@ -0,0 +1,145 @@ +/** + ******************************************************************************* + * @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 +#include + +extern "C" { + // file browsing ... + #include +} + +#undef __class__ +#define __class__ "TagFileList" + +extern const char * const applEventCtagsListSelect = "appl-event-ctags-list-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= 0 && raw < m_list.Size() && NULL != m_list[raw]) { + myTextToWrite = *m_list[raw]; + } else { + myTextToWrite = "ERROR"; + } + fg = draw::color::black; + if (raw % 2) { + bg = 0xFFFFFF00; + } else { + bg = 0xBFBFBFFF; + } + if (m_selectedLine == raw) { + bg = 0x8F8FFFFF; + } + 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; + } + if (previousRaw != m_selectedLine) { + if( m_selectedLine >=0 + && m_selectedLine < m_list.Size() + && NULL != m_list[m_selectedLine] ) { + GenerateEventId(applEventCtagsListSelect, *m_list[m_selectedLine]); + } + } else { + if( m_selectedLine >=0 + && m_selectedLine < m_list.Size() + && NULL != m_list[m_selectedLine] ) { + GenerateEventId(applEventCtagsListValidate, *m_list[m_selectedLine]); + } + } + // 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) +{ + etk::UString *tmpFile = new etk::UString(file); + if (NULL != tmpFile) { + m_list.PushBack(tmpFile); + } + MarkToRedraw(); +} + + diff --git a/Sources/appl/Gui/TagFileList.h b/Sources/appl/Gui/TagFileList.h new file mode 100644 index 0000000..721ea93 --- /dev/null +++ b/Sources/appl/Gui/TagFileList.h @@ -0,0 +1,76 @@ +/** + ******************************************************************************* + * @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 +#include +#include + + +extern const char * const applEventCtagsListSelect; +extern const char * const applEventCtagsListValidate; + +namespace appl { + class TagFileList : public ewol::List + { + private: + int32_t m_selectedLine; + etk::Vector 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 + + diff --git a/Sources/appl/Gui/TagFileSelection.cpp b/Sources/appl/Gui/TagFileSelection.cpp new file mode 100644 index 0000000..ef6fb30 --- /dev/null +++ b/Sources/appl/Gui/TagFileSelection.cpp @@ -0,0 +1,216 @@ +/** + ******************************************************************************* + * @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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +#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_widgetListFolder->RegisterOnEvent(this, ewolEventFSFolderValidate, ewolEventFileChooserListFolder); + 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) { + GenerateEventId(eventId, "???"); + //==> Auto remove ... + AutoDestroy(); + } else if (eventId == applEventctagsCancel) { + //Nothing selected ... + //==> 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; + } +} + + + + + diff --git a/Sources/appl/Gui/TagFileSelection.h b/Sources/appl/Gui/TagFileSelection.h new file mode 100644 index 0000000..6a8b019 --- /dev/null +++ b/Sources/appl/Gui/TagFileSelection.h @@ -0,0 +1,79 @@ +/** + ******************************************************************************* + * @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 +#include +#include +#include + +extern const char * const applEventctagsSelection; +extern const char * const applEventctagsCancel; + +namespace appl { + class TagFileSelection : public ewol::PopUp + { + private: + appl::TagFileList* m_listTag; + 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 \ No newline at end of file diff --git a/Sources/appl/ctags/CTagsManager.cpp b/Sources/appl/ctags/CTagsManager.cpp index 1133872..e14cb6c 100644 --- a/Sources/appl/ctags/CTagsManager.cpp +++ b/Sources/appl/ctags/CTagsManager.cpp @@ -28,12 +28,89 @@ #include #include #include +#include +#include #undef __class__ #define __class__ "CTagsManager" -#if 0 + + +typedef struct{ + char filename[MAX_FILE_NAME]; + char RegExp[MAX_REG_EXP_SEARCH]; + int32_t lineID; +} TagListFind_ts; + +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, bool small); + etk::UString GetFolder(etk::UString &inputString); + etk::UString m_tagFolderBase; + etk::UString m_tagFilename; + tagFile * m_ctagFile; + // history system + void AddToHistory(int32_t bufferID); + int32_t m_historyPos; + etk::Vector m_historyList; + etk::Vector m_currentList; + void JumpAtID(int32_t selectID); +}; + +static CTagsManager* s_elementPointer = NULL; +void cTagsManager::Init(void) +{ + if (NULL != s_elementPointer) { + delete(s_elementPointer); + s_elementPointer = NULL; + EWOL_WARNING("Ctags manager already instanciate ... ==> restart IT"); + } + 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 * @@ -48,7 +125,9 @@ CTagsManager::CTagsManager(void) m_tagFolderBase = ""; m_ctagFile = NULL; m_historyPos = 0; - ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiCtags); + RegisterMultiCast(ednMsgGuiCtags); + RegisterMultiCast(ednMsgBufferId); + EWOL_INFO("Ctags manager (INIT)"); } /** @@ -61,14 +140,13 @@ CTagsManager::CTagsManager(void) */ 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(); } - */ } etk::UString CTagsManager::GetFolder(etk::UString &inputString) @@ -93,65 +171,55 @@ etk::UString CTagsManager::GetFolder(etk::UString &inputString) return out; } -bool CTagsManager::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, float x, float y) +const char * ednEventPopUpCtagsLoadFile = "edn-event-load-ctags"; + +void CTagsManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data) { - /* - switch (id) - { - case APPL_MSG__BUFFER_CHANGE_CURRENT: - m_currentSelectedID = dataID; - break; - case APPL_MSG__OPEN_CTAGS: + if (eventId == ednMsgBufferId) { + //m_currentSelectedID = dataID; + } else if (eventId == ednEventPopUpCtagsLoadFile) { + // open the new one : + etk::File tmpFilename = data; + m_tagFilename = tmpFilename.GetShortFilename(); + m_tagFolderBase = tmpFilename.GetFolder(); + APPL_DEBUG("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " "); + LoadTagFile(); + } else if (eventId == ednMsgGuiCtags) { + if (data == "Load") { APPL_INFO("Request opening ctag file"); - { - GtkWidget *dialog = gtk_file_chooser_dialog_new( "Open Exuberant Ctags File", NULL, - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL); // end button/response list - if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) - { - // open the new one : - m_tagFilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog)); - m_tagFolderBase = GetFolder(m_tagFilename); - LoadTagFile(); - } - gtk_widget_destroy(dialog); + 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); } - break; - case APPL_MSG__RELOAD_CTAGS: + } else if (data == "ReLoad") { + APPL_INFO("Request re-load ctag file"); LoadTagFile(); - break; - case APPL_MSG__JUMP_TO_CURRENT_SELECTION: + } else if (data == "Jump") { JumpTo(); - break; - case APPL_MSG__JUMP_BACK: + } else if (data == "Back") { if (m_historyList.Size() > 0) { - BufferManager *myBufferManager = BufferManager::getInstance(); int32_t id = m_historyList.Size()-1; - if (false == myBufferManager->Exist(*m_historyList[id]) ) { - // need to open the file : - int32_t openID = myBufferManager->Open(*m_historyList[id]); - SendMessage(APPL_MSG__CURRENT_CHANGE_BUFFER_ID, openID); - } else { - SendMessage(APPL_MSG__CURRENT_CHANGE_BUFFER_ID, myBufferManager->GetId(*m_historyList[id])); - } - SendMessage(APPL_MSG__CURRENT_GOTO_LINE, m_historyList[id]->GetLineNumber()); + SendMultiCast(ednMsgOpenFile, m_historyList[id]->GetCompleateName() ); + SendMultiCast(ednMsgGuiGotoLine, m_historyList[id]->GetLineNumber()); // Remove element .... delete(m_historyList[id]); m_historyList[id]=NULL; m_historyList.PopBack(); } - break; + } else { + + } } - */ - return false; } void CTagsManager::LoadTagFile(void) { - /* tagFileInfo info; // close previous tag file @@ -170,156 +238,45 @@ void CTagsManager::LoadTagFile(void) } else { APPL_INFO("Error to open ctags file ..."); } - */ } void CTagsManager::AddToHistory(int32_t bufferID) { - /* // check tho history position : remove if needed - if (m_historyPos < edn_max(m_historyList.Size()-1, 0) ) { + if (m_historyPos < etk_max(m_historyList.Size()-1, 0) ) { for(int32_t iii= m_historyPos; iii < m_historyList.Size(); iii++) { delete(m_historyList[iii]); } m_historyList.EraseLen(m_historyPos, m_historyList.Size() - m_historyPos); } // add the current element - BufferManager *myBufferManager = BufferManager::getInstance(); - etk::File currentFilename = myBufferManager->Get(bufferID)->GetFileName(); - */ + etk::File currentFilename = BufferManager::Get(bufferID)->GetFileName(); } -/* -enum -{ - CTAGS_COL_FILE = 0, - CTAGS_COL_LINE_NUMBER, - CTAGS_NUM_COLS -}; -void CTagsManager::cb_row(GtkTreeView *p_treeview, - GtkTreePath * p_path, - GtkTreeViewColumn * p_column, - gpointer data) -{ - APPL_DEBUG("event"); - CTagsManager * self = static_cast(data); - - gchar * p_file=NULL; - gint lineNumber; - GtkTreeIter iter; - - - if (gtk_tree_model_get_iter( GTK_TREE_MODEL(self->m_listStore), &iter, p_path)) - { - gtk_tree_model_get( GTK_TREE_MODEL(self->m_listStore), - &iter, - CTAGS_COL_FILE, &p_file, - CTAGS_COL_LINE_NUMBER, &lineNumber, - -1 ); - APPL_DEBUG("find : " << p_file << ":" << lineNumber); - for (int32_t iii = 0; iii < self->m_currentList.Size() ; iii++) { - if( self->m_currentList[iii].lineID == lineNumber - && strcmp(self->m_currentList[iii].filename, p_file)==0) - { - g_object_unref( GTK_TREE_MODEL(self->m_listStore)); - // Remove dialogue - gtk_widget_destroy(self->m_Dialog); - // Jump ... - self->JumpAtID(iii); - return; - } - } - } -} -*/ - -/* -GtkWidget * CTagsManager::CreateViewAndModel(void) -{ - - GtkCellRenderer * renderer; - GtkWidget * view; - view = gtk_tree_view_new(); - - // Column 1 - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), - -1, - "File", - renderer, - "text", CTAGS_COL_FILE, - NULL); - - // Column 2 - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), - -1, - "lineNumber", - renderer, - "text", CTAGS_COL_LINE_NUMBER, - NULL); - - // Set data in the list : - GtkTreeIter iter; - m_listStore = gtk_list_store_new(CTAGS_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT); - // Append a row and fill in some data - for (int32_t iii=0; iiiGetWidget())); - // add writting area - GtkWidget *myContentArea = gtk_dialog_get_content_area( GTK_DIALOG(m_Dialog)); - GtkWidget *listView = CreateViewAndModel(); - gtk_box_pack_start(GTK_BOX(myContentArea), listView, TRUE, TRUE, 0); - // Display it - gtk_widget_show_all(myContentArea); - int32_t result = gtk_dialog_run(GTK_DIALOG(m_Dialog)); - // Get data from the gtk entry - if (result == GTK_RESPONSE_NO) { - g_object_unref(GTK_TREE_MODEL(m_listStore)); - // Remove dialogue - gtk_widget_destroy(m_Dialog); + 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 { + for (int32_t iii=0; iiiAddCtagsNewItem(m_currentList[iii].filename, m_currentList[iii].lineID); + } + PopUpWidgetPush(tmpWidget); + tmpWidget->RegisterOnEvent(this, applEventctagsSelection); } - */ return 0; } void CTagsManager::JumpAtID(int32_t selectID) { -/* - BufferManager *myBufferManager = BufferManager::getInstance(); etk::File myFile = m_currentList[selectID].filename; APPL_INFO("save curent filename and position : "); - int32_t currentSelected = myBufferManager->GetSelected(); - Buffer* tmpBuf = myBufferManager->Get(currentSelected); + int32_t currentSelected = BufferManager::GetSelected(); + Buffer* tmpBuf = BufferManager::Get(currentSelected); if (NULL != tmpBuf) { etk::File * bufferFilename = new etk::File(); *bufferFilename = tmpBuf->GetFileName(); @@ -327,40 +284,33 @@ void CTagsManager::JumpAtID(int32_t selectID) m_historyList.PushBack(bufferFilename); } APPL_INFO(" OPEN the TAG file Destination : " << myFile ); - if (false == myBufferManager->Exist(myFile) ) { - // need to open the file : - int32_t openID = myBufferManager->Open(myFile); - SendMessage(APPL_MSG__CURRENT_CHANGE_BUFFER_ID, openID); - } else { - SendMessage(APPL_MSG__CURRENT_CHANGE_BUFFER_ID, myBufferManager->GetId(myFile)); - } - SendMessage(APPL_MSG__CURRENT_GOTO_LINE, m_currentList[selectID].lineID - 1); -*/ + SendMultiCast(ednMsgOpenFile, myFile.GetCompleateName()); + SendMultiCast(ednMsgGuiGotoLine, m_currentList[selectID].lineID - 1); } void CTagsManager::JumpTo(void) { -/* m_currentList.Clear(); if (NULL != m_ctagFile) { - etk::Vector data; // get the middle button of the clipboard ==> represent the current selection ... - ClipBoard::Get(COPY_MIDDLE_BUTTON, data); + etk::UString data = ewol::clipBoard::Get(ewol::clipBoard::CLIPBOARD_SELECTION); + APPL_DEBUG("clipboard data : \"" << data << "\""); if (data.Size() == 0) { - APPL_INFO("No current S\E9lection"); + APPL_INFO("No current selection"); } tagEntry entry; - data.PushBack('\0'); - APPL_INFO("try to find the tag : " << (const char *)&data[0]); - if (tagsFind (m_ctagFile, &entry, (const char *)&data[0], 0) == TagSuccess) { + 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 : do { etk::UString destinationFilename = m_tagFolderBase; + destinationFilename += "/"; destinationFilename += entry.file; + APPL_WARNING("plop : \"" << destinationFilename << "\" from : " << m_tagFolderBase << " " << entry.file); etk::File myfile = destinationFilename; TagListFind_ts myStruct; strncpy(myStruct.filename, myfile.GetCompleateName().c_str(), MAX_FILE_NAME); @@ -376,7 +326,6 @@ void CTagsManager::JumpTo(void) if (1==m_currentList.Size() ) { JumpAtID(0); - } else { // Open a choice windows... int32_t SelectID = MultipleJump(); @@ -385,19 +334,19 @@ void CTagsManager::JumpTo(void) APPL_INFO("no tag find ..."); } } -*/ } -/* + + void CTagsManager::PrintTag (const tagEntry *entry, bool small) { if (small==true) { APPL_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file - << "\" at line="<< entry->address.lineNumber); + << "\" at line="<< (int32_t)entry->address.lineNumber); } else { int i; APPL_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file - << "\" pattern=\"" <address.pattern - << "\" at line="<address.lineNumber); + << "\" pattern=\"" << entry->address.pattern + << "\" at line="<< (int32_t)entry->address.lineNumber); APPL_INFO("Extention field : "); if (entry->kind != NULL && entry->kind [0] != '\0') { @@ -411,7 +360,4 @@ void CTagsManager::PrintTag (const tagEntry *entry, bool small) } } } -*/ - -#endif diff --git a/Sources/appl/ctags/CTagsManager.h b/Sources/appl/ctags/CTagsManager.h index 4d8128b..c6bd401 100644 --- a/Sources/appl/ctags/CTagsManager.h +++ b/Sources/appl/ctags/CTagsManager.h @@ -33,40 +33,11 @@ #define MAX_REG_EXP_SEARCH (1024) -typedef struct{ - char filename[MAX_FILE_NAME]; - char RegExp[MAX_REG_EXP_SEARCH]; - int32_t lineID; -} TagListFind_ts; - -/* -class CTagsManager: public etk::Singleton, public ewol::Widget +namespace cTagsManager { - friend class etk::Singleton; - // specific for sigleton system... - private: - // Constructeur - CTagsManager(void); - ~CTagsManager(void); - - public: - virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, float x, float y); - private: - int32_t m_currentSelectedID; - void LoadTagFile(void); - int32_t MultipleJump(void); - void JumpTo(void); - void PrintTag(const tagEntry *entry, bool small); - etk::UString GetFolder(etk::UString &inputString); - etk::UString m_tagFolderBase; - etk::UString m_tagFilename; - tagFile * m_ctagFile; - // history system - void AddToHistory(int32_t bufferID); - int32_t m_historyPos; - etk::Vector m_historyList; - etk::Vector m_currentList; - void JumpAtID(int32_t selectID); + void Init(void); + void UnInit(void); }; -*/ + + #endif diff --git a/Sources/appl/init.cpp b/Sources/appl/init.cpp index 5f9282d..a2b9da3 100644 --- a/Sources/appl/init.cpp +++ b/Sources/appl/init.cpp @@ -89,6 +89,7 @@ void APP_Init(void) HighlightManager::Init(); HighlightManager::loadLanguages(); + cTagsManager::Init(); char cCurrentPath[FILENAME_MAX]; // get the curent program folder @@ -135,6 +136,8 @@ void APP_Init(void) 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 : "); @@ -164,6 +167,8 @@ void APP_UnInit(void) // Remove windows : ewol::DisplayWindows(NULL); + cTagsManager::UnInit(); + APPL_INFO("Stop Hightlight"); HighlightManager::UnInit(); //Kill all singleton diff --git a/Sources/file.mk b/Sources/file.mk index 139e84e..e640572 100644 --- a/Sources/file.mk +++ b/Sources/file.mk @@ -18,7 +18,9 @@ FILE_LIST+= appl/Gui/BufferView.cpp \ appl/Gui/CodeView.cpp \ appl/Gui/MainWindows.cpp \ appl/Gui/Search.cpp \ - appl/Gui/SearchData.cpp + appl/Gui/SearchData.cpp \ + appl/Gui/TagFileSelection.cpp \ + appl/Gui/TagFileList.cpp # All needed for the buffer management : FILE_LIST+= appl/Buffer/EdnVectorBuf.cpp \