[DEV] correct some parsing, add js and set back part of ctags

This commit is contained in:
2017-09-05 21:12:12 +02:00
parent 735bfbc9e9
commit 24616dac9c
9 changed files with 180 additions and 34 deletions

View File

@@ -13,7 +13,7 @@ appl::HighlightPattern::HighlightPattern(const ememory::SharedPtr<appl::GlyphPai
m_hasParsingError(true),
m_regexValue(),
m_hasEndRegEx(false),
m_regExp(),
m_regex(),
m_colorName(""),
m_level(0) {
parseRules(_child, _level);
@@ -25,7 +25,7 @@ appl::HighlightPattern::HighlightPattern() :
m_hasParsingError(true),
m_regexValue(),
m_hasEndRegEx(false),
m_regExp(),
m_regex(),
m_colorName(""),
m_level(0) {
@@ -35,24 +35,24 @@ appl::HighlightPattern::~HighlightPattern() {
}
void appl::HighlightPattern::setPatern(const etk::String& _regExp, const etk::String& _regExpStop, bool _hasEndRegEx) {
m_regexValue[0] = _regExp;
m_regexValue[1] = _regExpStop;
void appl::HighlightPattern::setPatern(const etk::String& _regex, const etk::String& _regexStop, bool _hasEndRegEx) {
m_regexValue[0] = _regex;
m_regexValue[1] = _regexStop;
m_hasEndRegEx = _hasEndRegEx;
APPL_DEBUG("parse regex='" << _regExp << "' -> '" << _regExpStop << "'");
APPL_DEBUG("parse regex='" << _regex << "' -> '" << _regexStop << "'");
m_hasParsingError = false;
if (_regExp != "") {
m_regExp[0].compile(_regExp);
if (m_regExp[0].getStatus() == false) {
if (_regex != "") {
m_regex[0].compile(_regex);
if (m_regex[0].getStatus() == false) {
m_hasParsingError = true;
APPL_ERROR("can not parse regex for : " << _regExp);
APPL_ERROR("can not parse regex for : " << _regex);
}
}
if (_regExpStop != "") {
m_regExp[1].compile(_regExpStop);
if (m_regExp[1].getStatus() == false) {
if (_regexStop != "") {
m_regex[1].compile(_regexStop);
if (m_regex[1].getStatus() == false) {
m_hasParsingError = true;
APPL_ERROR("can not parse regex for : " << _regExpStop);
APPL_ERROR("can not parse regex for : " << _regexStop);
}
}
}
@@ -153,9 +153,9 @@ bool appl::HighlightPattern::find(int32_t _start,
return false;
}
// when we have only one element:
if (m_regExp[0].processOneElement(_buffer, _start, _stop) == true) {
_resultat.start = m_regExp[0].start();
_resultat.stop = m_regExp[0].stop();
if (m_regex[0].processOneElement(_buffer, _start, _stop) == true) {
_resultat.start = m_regex[0].start();
_resultat.stop = m_regex[0].stop();
//APPL_DEBUG("find data at : start=" << _resultat.start << " stop=" << _resultat.stop << " data='" <<etk::String(_buffer, _resultat.start, _resultat.stop-_resultat.start) << "'" );
//APPL_DEBUG("find data at : start=" << _resultat.start << " stop=" << _resultat.stop );
if (m_hasEndRegEx == true) {
@@ -166,8 +166,8 @@ bool appl::HighlightPattern::find(int32_t _start,
}
_start = _resultat.stop;
while (_start < _stop) {
if (m_regExp[1].processOneElement(_buffer, _start, _stop) == true) {
_resultat.stop = m_regExp[1].stop();
if (m_regex[1].processOneElement(_buffer, _start, _stop) == true) {
_resultat.stop = m_regex[1].stop();
return true;
}
_start++;

View File

@@ -45,9 +45,9 @@ namespace appl {
bool m_hasParsingError;
etk::String m_regexValue[2];
bool m_hasEndRegEx;
etk::RegEx<etk::Buffer> m_regExp[2]; //!< Start of Regular expression
etk::RegEx<etk::Buffer> m_regex[2]; //!< Start of Regular expression
public:
void setPatern(const etk::String& _regExp, const etk::String& _regExpStop="", bool _hasEndRegEx=false);
void setPatern(const etk::String& _regex, const etk::String& _regexStop="", bool _hasEndRegEx=false);
etk::Pair<etk::String,etk::String> getPaternString();
private:
etk::String m_colorName; //!< Current color name

View File

@@ -10,6 +10,12 @@
#include <ewol/context/Context.hpp>
#include <appl/Gui/TagFileSelection.hpp>
static etk::String g_staticCtagsFileName;
void appl::setCtagsFileName(const etk::String& _file) {
g_staticCtagsFileName = _file;
}
appl::TextPluginCtags::TextPluginCtags() :
m_tagFolderBase(""),
m_tagFilename(""),
@@ -18,6 +24,10 @@ appl::TextPluginCtags::TextPluginCtags() :
// load buffer manager:
m_bufferManager = appl::BufferManager::create();
addObjectType("appl::TextPluginCtags");
if (g_staticCtagsFileName != "") {
m_tagFilename = g_staticCtagsFileName;
loadTagFile();
}
}
appl::TextPluginCtags::~TextPluginCtags() {
@@ -25,7 +35,6 @@ appl::TextPluginCtags::~TextPluginCtags() {
}
void appl::TextPluginCtags::onPluginEnable(appl::TextViewer& _textDrawer) {
// add event :
_textDrawer.ext_shortCutAdd("ctrl+d", "appl::TextPluginCtags::JumpDestination");
_textDrawer.ext_shortCutAdd("ctrl+shift+d", "appl::TextPluginCtags::JumpBack");
_textDrawer.ext_shortCutAdd("ctrl+alt+d", "appl::TextPluginCtags::OpenCtagsFile");
@@ -83,7 +92,11 @@ void appl::TextPluginCtags::jumpFile(const etk::String& _filename, int64_t _line
// save the current file in the history
// TODO : registerHistory();
if (m_bufferManager != nullptr) {
m_bufferManager->open(_filename);
etk::String plop = _filename;
while (plop[0] == '/') {
plop.erase(0);
}
m_bufferManager->open(plop);
}
//sendMultiCast(appl::MsgSelectGotoLineSelect, etk::toString(_lineId));
APPL_TODO("request jup at line ...");

View File

@@ -13,8 +13,10 @@
// create ctags file : "ctags-exuberant --fields=n -R"
// --fields=n add the line number needed for this software version ..
// ctags --recurse -f tags --fields=n -h ".h.hpp" --tag-relative=yes framework/atria-soft/
namespace appl {
void setCtagsFileName(const etk::String& _file);
class TextPluginCtags : public appl::TextViewerPlugin {
private:
// Global plugin data (not specific on buffer :

View File

@@ -24,6 +24,7 @@
#include <appl/Gui/Search.hpp>
#include <appl/ctags/readtags.hpp>
#include <appl/globalMsg.hpp>
#include <appl/TextPluginCtags.hpp>
class MainApplication : public ewol::context::Application {
private:
@@ -36,7 +37,7 @@ class MainApplication : public ewol::context::Application {
etk::String tmpppp = _context.getCmd().get(iii);
if ( tmpppp == "-h"
|| tmpppp == "--help") {
APPL_INFO(" -t c-flags-file-name" );
APPL_INFO(" --ctags=xxx c-flags-file-name" );
APPL_INFO(" -h/--help display this help" );
exit(0);
}
@@ -97,17 +98,13 @@ class MainApplication : public ewol::context::Application {
// add files
APPL_INFO("show list of files : ");
bool ctagDetected = false;
for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) {
etk::String tmpppp = _context.getCmd().get(iii);
if (tmpppp == "-t") {
ctagDetected = true;
} else if (ctagDetected == true) {
if (tmpppp.startWith("--ctags=") == true) {
etk::FSNode file(tmpppp);
etk::String name = file.getName();
etk::String name = tmpppp.extract(8);
APPL_INFO("Load ctag file : \"" << name << "\"" );
ctagDetected = false;
//_context.getEObjectManager().multiCast().anonymousSend(ednMsgCtagsLoadFile, name);
appl::setCtagsFileName(name);
} else if ( tmpppp == "-h"
|| tmpppp == "--help") {
// nothing to do ...
@@ -166,6 +163,18 @@ int main(int _argc, const char *_argv[]) {
APPL_ERROR(" base signature = " << typeid(etk::String).name());
APPL_CRITICAL(" END ");
*/
// this is really bad ...
for( int32_t iii=0 ; iii<_argc; iii++) {
etk::String tmpppp = _argv[iii];
if (tmpppp.startWith("--ctags=") == true) {
etk::FSNode file(tmpppp);
etk::String name = tmpppp.extract(8);
APPL_INFO("Load ctag file : \"" << name << "\"" );
appl::setCtagsFileName(name);
}
}
// second possibility
return ewol::run(ETK_NEW(MainApplication), _argc, _argv);
}