[DEV] Add ctags jumping
This commit is contained in:
parent
cc5afe2d55
commit
48260131d3
@ -225,11 +225,13 @@ MainWindows::MainWindows(void) {
|
||||
(void)myMenu->add(idMenuSearch, "Find (next)", "", ednMsgGuiFind, "Next");
|
||||
(void)myMenu->add(idMenuSearch, "Find (all)", "", ednMsgGuiFind, "All");
|
||||
(void)myMenu->add(idMenuSearch, "Un-Select", "", ednMsgGuiFind, "None");
|
||||
/* ==> must be in the pluggin list control ...
|
||||
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, "Color Black", "", appl::MsgNameGuiChangeColor, "colorBlack/");
|
||||
(void)myMenu->add(idMenugDisplay, "Color White", "", appl::MsgNameGuiChangeColor, "colorWhite/");
|
||||
|
@ -15,8 +15,7 @@
|
||||
#include <appl/Buffer.h>
|
||||
#include <appl/Gui/ViewerManager.h>
|
||||
|
||||
class Search : public widget::Composer
|
||||
{
|
||||
class Search : public widget::Composer {
|
||||
private:
|
||||
appl::ViewerManager* m_viewerManager; //!< handle on the buffer manager
|
||||
bool m_forward;
|
||||
|
@ -55,53 +55,31 @@ appl::TagFileSelection::TagFileSelection(void) {
|
||||
EWOL_ERROR("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySizerVert->lockExpand(bvec2(true,true));
|
||||
mySizerVert->setExpand(bvec2(true,true));
|
||||
// set it in the pop-up-system :
|
||||
setSubWidget(mySizerVert);
|
||||
|
||||
mySizerHori = new widget::Sizer(widget::Sizer::modeHori);
|
||||
if (NULL == mySizerHori) {
|
||||
EWOL_ERROR("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySizerVert->subWidgetAdd(mySizerHori);
|
||||
mySpacer = new widget::Spacer();
|
||||
if (NULL == mySpacer) {
|
||||
EWOL_ERROR("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySpacer->setExpand(bvec2(true,false));
|
||||
mySizerHori->subWidgetAdd(mySpacer);
|
||||
}
|
||||
myWidgetValidate = new widget::Button();
|
||||
if (NULL == myWidgetValidate) {
|
||||
EWOL_ERROR("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
myWidgetValidate->setSubWidget(
|
||||
new widget::Composer(widget::Composer::String,
|
||||
"<composer>\n"
|
||||
" <sizer mode=\"hori\">\n"
|
||||
" <image src=\"THEME:GUI:icon/Load.svg\" fill=\"true\" size=\"70,70mm\"/>\n"
|
||||
" <label>Jump</label>\n"
|
||||
" </sizer>\n"
|
||||
"</composer\n"));
|
||||
|
||||
myWidgetValidate->registerOnEvent(this, widget::Button::eventPressed, applEventctagsSelection);
|
||||
mySizerHori->subWidgetAdd(myWidgetValidate);
|
||||
}
|
||||
myWidgetCancel = new widget::Button();
|
||||
if (NULL == myWidgetCancel) {
|
||||
EWOL_ERROR("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
myWidgetCancel->setSubWidget(
|
||||
new widget::Composer(widget::Composer::String,
|
||||
"<composer>\n"
|
||||
" <sizer mode=\"hori\">\n"
|
||||
" <image src=\"THEME:GUI:icon/Remove.svg\" fill=\"true\" size=\"70,70mm\"/>\n"
|
||||
" <label>Cancel</label>\n"
|
||||
" </sizer>\n"
|
||||
"</composer\n"));
|
||||
myWidgetCancel->registerOnEvent(this, widget::Button::eventPressed, applEventctagsCancel);
|
||||
mySizerHori->subWidgetAdd(myWidgetCancel);
|
||||
}
|
||||
}
|
||||
widget::Composer* compose = new widget::Composer(widget::Composer::String,
|
||||
"<sizer mode=\"hori\" expand=\"true,false\" lock=\"false,true\">\n"
|
||||
" <spacer expand=\"true,false\"/>\n"
|
||||
" <button name=\"PLUGIN-CTAGS-jump\" expand=\"false\" fill=\"true\">"
|
||||
" <sizer mode=\"hori\">\n"
|
||||
" <image src=\"THEME:GUI:Load.svg\" fill=\"true\" size=\"10,10mm\"/>\n"
|
||||
" <label>Jump</label>\n"
|
||||
" </sizer>\n"
|
||||
" </button>\n"
|
||||
" <button name=\"PLUGIN-CTAGS-cancel\" expand=\"false\" fill=\"true\">"
|
||||
" <sizer mode=\"hori\">\n"
|
||||
" <image src=\"THEME:GUI:Remove.svg\" fill=\"true\" size=\"10,10mm\"/>\n"
|
||||
" <label>Cancel</label>\n"
|
||||
" </sizer>\n"
|
||||
" </button>\n"
|
||||
"</sizer>\n");
|
||||
compose->setExpand(bvec2(true,false));
|
||||
compose->setFill(bvec2(true,true));
|
||||
mySizerVert->subWidgetAdd(compose);
|
||||
compose->registerOnEventNameWidget(this, "PLUGIN-CTAGS-jump", "pressed", applEventctagsSelection);
|
||||
compose->registerOnEventNameWidget(this, "PLUGIN-CTAGS-cancel", "pressed", applEventctagsCancel);
|
||||
|
||||
m_listTag = new appl::TagFileList();
|
||||
if (NULL == m_listTag) {
|
||||
EWOL_ERROR("Can not allocate widget == > display might be in error");
|
||||
|
@ -37,8 +37,9 @@ appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) :
|
||||
registerMultiCast(ednMsgBufferId);
|
||||
registerMultiCast(ednMsgGuiFind);
|
||||
registerMultiCast(ednMsgGuiReplace);
|
||||
registerMultiCast(ednMsgGuiGotoLine);
|
||||
registerMultiCast(appl::MsgSelectGotoLine);
|
||||
registerMultiCast(appl::MsgSelectNewFile);
|
||||
registerMultiCast(appl::MsgSelectGotoLineSelect);
|
||||
setLimitScrolling(0.2);
|
||||
|
||||
// load buffer manager:
|
||||
@ -585,6 +586,24 @@ void appl::TextViewer::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
if (isSelectedLast() == false) {
|
||||
return;
|
||||
}
|
||||
if (_msg.getMessage() == appl::MsgSelectGotoLineSelect) {
|
||||
if (m_buffer == NULL) {
|
||||
return;
|
||||
}
|
||||
appl::Buffer::Iterator it = m_buffer->countForwardNLines(m_buffer->begin(), std::stoi(_msg.getData()));
|
||||
select(it, m_buffer->getEndLine(it));
|
||||
markToRedraw();
|
||||
return;
|
||||
}
|
||||
if (_msg.getMessage() == appl::MsgSelectGotoLine) {
|
||||
if (m_buffer == NULL) {
|
||||
return;
|
||||
}
|
||||
appl::Buffer::Iterator it = m_buffer->countForwardNLines(m_buffer->begin(), std::stoi(_msg.getData()));
|
||||
moveCursor(it);
|
||||
markToRedraw();
|
||||
return;
|
||||
}
|
||||
if (_msg.getMessage() == appl::MsgSelectNewFile) {
|
||||
// reset scroll:
|
||||
if (m_buffer != NULL) {
|
||||
|
@ -10,36 +10,181 @@
|
||||
#include <appl/TextPluginCtags.h>
|
||||
#include <ewol/clipBoard.h>
|
||||
#include <appl/Gui/TextViewer.h>
|
||||
#include <ewol/widget/meta/FileChooser.h>
|
||||
#include <ewol/renderer/eContext.h>
|
||||
#include <appl/Gui/TagFileSelection.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "TextPluginCtags"
|
||||
|
||||
|
||||
appl::TextPluginCtags::TextPluginCtags(void) {
|
||||
appl::TextPluginCtags::TextPluginCtags(void) :
|
||||
m_tagFilename(""),
|
||||
m_tagFolderBase(""),
|
||||
m_ctagFile(NULL) {
|
||||
m_activateOnReceiveMessage = true;
|
||||
// load buffer manager:
|
||||
m_bufferManager = appl::BufferManager::keep();
|
||||
}
|
||||
appl::TextPluginCtags::~TextPluginCtags(void) {
|
||||
appl::BufferManager::release(m_bufferManager);
|
||||
}
|
||||
|
||||
const char* eventJumpDestination = "event-plugin-ctags-jump-destination";
|
||||
const char* eventJumpBack = "event-plugin-ctags-jump-back";
|
||||
const char* eventOpenCtagsFile = "event-plugin-ctags-open";
|
||||
const char* eventOpenCtagsOpenFileReturn = "event-plugin-ctags-open-file-return";
|
||||
const char* eventOpenCtagsSelectReturn = "event-plugin-ctags-select-file-return";
|
||||
|
||||
void appl::TextPluginCtags::onPluginEnable(appl::TextViewer& _textDrawer) {
|
||||
// Add local event of this object (no dependency with the viewer ...
|
||||
/*
|
||||
registerMultiCast(ednMsgGuiCtags);
|
||||
registerMultiCast(ednMsgBufferId);
|
||||
registerMultiCast(ednMsgCtagsLoadFile);
|
||||
*/
|
||||
// add event :
|
||||
_textDrawer.ext_registerMultiCast(eventJumpDestination);
|
||||
_textDrawer.ext_registerMultiCast(eventJumpBack);
|
||||
_textDrawer.ext_registerMultiCast(eventOpenCtagsFile);
|
||||
_textDrawer.ext_shortCutAdd("ctrl+d", eventJumpDestination);
|
||||
_textDrawer.ext_shortCutAdd("ctrl+shift+d", eventJumpBack);
|
||||
_textDrawer.ext_shortCutAdd("ctrl+alt+d", eventOpenCtagsFile);
|
||||
}
|
||||
|
||||
void appl::TextPluginCtags::onPluginDisable(appl::TextViewer& _textDrawer) {
|
||||
// TODO : unknow function ...
|
||||
}
|
||||
|
||||
void appl::TextPluginCtags::jumpTo(const std::string& _name) {
|
||||
if (m_ctagFile == NULL) {
|
||||
APPL_WARNING("No ctags file open");
|
||||
return;
|
||||
}
|
||||
tagEntry entry;
|
||||
APPL_INFO("try to find the tag : " << _name);
|
||||
if (tagsFind (m_ctagFile, &entry, _name.c_str(), 0) != TagSuccess) {
|
||||
APPL_INFO("no tag find ...");
|
||||
return;
|
||||
}
|
||||
tagEntry entrySave = entry;
|
||||
int32_t numberOfTags = 0;
|
||||
|
||||
// For all tags : Save in an internal Structure :
|
||||
std::string 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);
|
||||
ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
|
||||
tmpWidget->registerOnEvent(this, applEventctagsSelection, eventOpenCtagsSelectReturn);
|
||||
}
|
||||
} else {
|
||||
jumpFile(myfile.getName(), lineID - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void appl::TextPluginCtags::jumpFile(const std::string& _filename, int64_t _lineId) {
|
||||
// save the current file in the history
|
||||
// TODO : registerHistory();
|
||||
if (m_bufferManager != NULL) {
|
||||
m_bufferManager->open(_filename);
|
||||
}
|
||||
sendMultiCast(appl::MsgSelectChange, _filename);
|
||||
sendMultiCast(appl::MsgSelectGotoLineSelect, std::to_string(_lineId));
|
||||
}
|
||||
|
||||
void appl::TextPluginCtags::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 appl::TextPluginCtags::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
|
||||
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 (int32_t iii = 0 ; iii < _entry->fields.count ; ++iii) {
|
||||
APPL_INFO(" " << _entry->fields.list[iii].key << ":" << _entry->fields.list[iii].value );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void appl::TextPluginCtags::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
if (_msg.getMessage() == eventOpenCtagsOpenFileReturn) {
|
||||
// open the new one :
|
||||
etk::FSNode tmpFilename = _msg.getData();
|
||||
m_tagFilename = tmpFilename.getNameFile();
|
||||
m_tagFolderBase = tmpFilename.getNameFolder();
|
||||
APPL_DEBUG("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " ");
|
||||
loadTagFile();
|
||||
} else if (_msg.getMessage() == eventOpenCtagsSelectReturn) {
|
||||
// parse the input data
|
||||
char tmp[4096];
|
||||
int32_t lineID;
|
||||
// TODO : Review this ...
|
||||
sscanf(_msg.getData().c_str(), "%d:%s", &lineID, tmp);
|
||||
jumpFile(tmp, lineID - 1);
|
||||
}
|
||||
}
|
||||
bool appl::TextPluginCtags::onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||
const ewol::EMessage& _msg) {
|
||||
if (isEnable() == false) {
|
||||
return false;
|
||||
}
|
||||
if (_msg.getMessage() == eventJumpDestination) {
|
||||
if (_msg.getMessage() == eventOpenCtagsFile) {
|
||||
APPL_INFO("Request opening ctag file");
|
||||
widget::FileChooser* tmpWidget = new widget::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");
|
||||
ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
|
||||
tmpWidget->registerOnEvent(this, widget::FileChooser::eventValidate, eventOpenCtagsOpenFileReturn);
|
||||
}
|
||||
return true;
|
||||
} else if (_msg.getMessage() == eventJumpDestination) {
|
||||
if (_textDrawer.hasBuffer() == false) {
|
||||
return false;
|
||||
}
|
||||
@ -55,7 +200,7 @@ bool appl::TextPluginCtags::onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||
}
|
||||
_textDrawer.copy(textToSearch, _beginPos, _endPos);
|
||||
}
|
||||
APPL_ERROR("CTAGS might search : '" << textToSearch << "'");
|
||||
jumpTo(textToSearch);
|
||||
return true;
|
||||
} else if (_msg.getMessage() == eventJumpBack) {
|
||||
if (_textDrawer.hasBuffer() == false) {
|
||||
|
@ -14,18 +14,33 @@
|
||||
#include <appl/Gui/TextViewer.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
#include <appl/TextPlugin.h>
|
||||
#include <appl/ctags/readtags.h>
|
||||
|
||||
namespace appl {
|
||||
class TextPluginCtags : public appl::TextViewerPlugin {
|
||||
private:
|
||||
// Global plugin data (not specific on buffer :
|
||||
/*
|
||||
std::vector<std::pair<std::string, int64_t>> m_historyList;
|
||||
*/
|
||||
std::string m_tagFolderBase;
|
||||
std::string m_tagFilename;
|
||||
tagFile* m_ctagFile;
|
||||
void loadTagFile(void);
|
||||
void printTag(const tagEntry *_entry);
|
||||
void jumpTo(const std::string& _name);
|
||||
void jumpFile(const std::string& _filename, int64_t _lineId);
|
||||
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
|
||||
public:
|
||||
TextPluginCtags(void);
|
||||
~TextPluginCtags(void) {
|
||||
// nothing to do ...
|
||||
};
|
||||
~TextPluginCtags(void);
|
||||
public:
|
||||
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
|
||||
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
|
||||
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer, const ewol::EMessage& _msg);
|
||||
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||
const ewol::EMessage& _msg);
|
||||
// internal message :
|
||||
virtual void onReceiveMessage(const ewol::EMessage& _msg);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,254 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <appl/ctags/CTagsManager.h>
|
||||
#include <appl/BufferManager.h>
|
||||
#include <ewol/renderer/EObject.h>
|
||||
#include <ewol/renderer/eContext.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);
|
||||
|
||||
const char * const getObjectType(void) {
|
||||
return "CTagsManager";
|
||||
};
|
||||
void onReceiveMessage(const ewol::EMessage& _msg);
|
||||
|
||||
int32_t m_currentSelectedID;
|
||||
void loadTagFile(void);
|
||||
int32_t multipleJump(void);
|
||||
void jumpTo(void);
|
||||
void printTag(const tagEntry *entry);
|
||||
std::string getFolder(std::string &inputString);
|
||||
std::string m_tagFolderBase;
|
||||
std::string m_tagFilename;
|
||||
tagFile * m_ctagFile;
|
||||
// history system
|
||||
int32_t m_historyPos;
|
||||
std::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 ...");
|
||||
}
|
||||
}
|
||||
|
||||
CTagsManager::CTagsManager(void) {
|
||||
m_tagFilename = "";
|
||||
m_tagFolderBase = "";
|
||||
m_ctagFile = NULL;
|
||||
m_historyPos = 0;
|
||||
registerMultiCast(ednMsgGuiCtags);
|
||||
registerMultiCast(ednMsgBufferId);
|
||||
registerMultiCast(ednMsgCtagsLoadFile);
|
||||
EWOL_INFO("Ctags manager (INIT)");
|
||||
}
|
||||
|
||||
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(const ewol::EMessage& _msg) {
|
||||
//EWOL_INFO("ctags manager event ... : \"" << eventId << "\" == > data=\"" << data << "\"" );
|
||||
if (_msg.getMessage() == ednMsgBufferId) {
|
||||
//m_currentSelectedID = dataID;
|
||||
} else if( _msg.getMessage() == ednEventPopUpCtagsLoadFile
|
||||
|| _msg.getMessage() == ednMsgCtagsLoadFile) {
|
||||
// open the new one :
|
||||
etk::FSNode tmpFilename = _msg.getData();
|
||||
m_tagFilename = tmpFilename.getNameFile();
|
||||
m_tagFolderBase = tmpFilename.getNameFolder();
|
||||
APPL_DEBUG("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " ");
|
||||
loadTagFile();
|
||||
} else if (_msg.getMessage() == ednMsgGuiCtags) {
|
||||
if (_msg.getData() == "Load") {
|
||||
APPL_INFO("Request opening ctag file");
|
||||
widget::FileChooser* tmpWidget = new widget::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");
|
||||
ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
|
||||
tmpWidget->registerOnEvent(this, widget::FileChooser::eventValidate, ednEventPopUpCtagsLoadFile);
|
||||
}
|
||||
} else if (_msg.getData() == "ReLoad") {
|
||||
APPL_INFO("Request re-load ctag file");
|
||||
loadTagFile();
|
||||
} else if (_msg.getData() == "Jump") {
|
||||
jumpTo();
|
||||
} else if (_msg.getData() == "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.pop_back();
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
} else if (_msg.getMessage() == applEventctagsSelection) {
|
||||
// save the current file in the history
|
||||
registerHistory();
|
||||
// parse the input data
|
||||
char tmp[4096];
|
||||
int32_t lineID;
|
||||
sscanf(_msg.getData().c_str(), "%d:%s", &lineID, tmp);
|
||||
// generate envents
|
||||
sendMultiCast(ednMsgOpenFile, tmp);
|
||||
sendMultiCast(ednMsgGuiGotoLine, std::to_string(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();
|
||||
BufferText* tmpBuf = BufferManager::get(currentSelected);
|
||||
if (NULL != tmpBuf) {
|
||||
etk::FSNode * bufferFilename = new etk::FSNode();
|
||||
*bufferFilename = tmpBuf->getFileName();
|
||||
// TODO : bufferFilename->setLineNumber(tmpBuf->getCurrentLine());
|
||||
m_historyList.push_back(bufferFilename);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CTagsManager::jumpTo(void) {
|
||||
if (NULL != m_ctagFile) {
|
||||
// get the middle button of the clipboard == > represent the current selection ...
|
||||
std::string data = ewol::clipBoard::get(ewol::clipBoard::clipboardSelection);
|
||||
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 :
|
||||
std::string 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);
|
||||
ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
|
||||
tmpWidget->registerOnEvent(this, applEventctagsSelection);
|
||||
}
|
||||
} else {
|
||||
registerHistory();
|
||||
APPL_INFO(" OPEN the TAG file Destination : " << tmpFile );
|
||||
sendMultiCast(ednMsgOpenFile, myfile.getName());
|
||||
sendMultiCast(ednMsgGuiGotoLine, std::to_string(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
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __C_TAGS_MANAGER_H__
|
||||
#define __C_TAGS_MANAGER_H__
|
||||
|
||||
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <appl/globalMsg.h>
|
||||
#include <appl/ctags/readtags.h>
|
||||
|
||||
#define MAX_REG_EXP_SEARCH (1024)
|
||||
|
||||
namespace cTagsManager {
|
||||
void init(void);
|
||||
void unInit(void);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -60,5 +60,7 @@ extern const char* const appl::MsgSelectNewFile = "edn-msg-select-new-file";
|
||||
extern const char* const appl::MsgSelectChange = "edn-msg-select-change";
|
||||
extern const char* const appl::MsgNameChange = "edn-msg-buffer-name-change";
|
||||
extern const char* const appl::MsgNameGuiChangeColor = "edn-Msg-Gui-Change-color";
|
||||
extern const char* const appl::MsgSelectGotoLine = "edn-Msg-Gui-goto-line";
|
||||
extern const char* const appl::MsgSelectGotoLineSelect = "edn-Msg-Gui-goto-line-select";
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ namespace appl {
|
||||
extern const char* const MsgSelectChange; // data : ""
|
||||
extern const char* const MsgNameChange; // data : ""
|
||||
extern const char* const MsgNameGuiChangeColor; // data : "Black" "White"
|
||||
extern const char* const MsgSelectGotoLine; // data : "75822"
|
||||
extern const char* const MsgSelectGotoLineSelect; // data : "75822"
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <appl/Gui/MainWindows.h>
|
||||
#include <appl/Gui/Search.h>
|
||||
#include <appl/ctags/readtags.h>
|
||||
#include <appl/ctags/CTagsManager.h>
|
||||
#include <appl/globalMsg.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -87,7 +86,6 @@ bool APP_Init(ewol::eContext& _context) {
|
||||
bufferManager = appl::BufferManager::keep();
|
||||
|
||||
appl::highlightManager::init();
|
||||
cTagsManager::init();
|
||||
appl::textPluginManager::init();
|
||||
appl::textPluginManager::addDefaultPlugin();
|
||||
|
||||
@ -149,7 +147,6 @@ void APP_UnInit(ewol::eContext& _context) {
|
||||
tmpWindows = NULL;
|
||||
}
|
||||
appl::textPluginManager::unInit();
|
||||
cTagsManager::unInit();
|
||||
|
||||
APPL_INFO("Stop Hightlight");
|
||||
appl::highlightManager::unInit();
|
||||
|
@ -8,8 +8,7 @@ def Create(target):
|
||||
myModule = lutinModule.module(__file__, 'edn', 'PACKAGE')
|
||||
# add the file to compile:
|
||||
myModule.AddSrcFile([
|
||||
'appl/ctags/readtags.cpp',
|
||||
'appl/ctags/CTagsManager.cpp'])
|
||||
'appl/ctags/readtags.cpp'])
|
||||
|
||||
myModule.AddSrcFile([
|
||||
'appl/debug.cpp',
|
||||
|
Loading…
x
Reference in New Issue
Block a user