[ERROR] Abandonned version in std::u32string ==> unexistant regexp
This commit is contained in:
parent
febbaffdf4
commit
154351e629
@ -357,15 +357,15 @@ void appl::Buffer::moveCursor(int64_t _pos) {
|
||||
bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos,
|
||||
appl::Buffer::Iterator &_beginPos,
|
||||
appl::Buffer::Iterator &_endPos) {
|
||||
char32_t currentValue = *position(_startPos);
|
||||
char32_t currentValue = *_startPos;
|
||||
_beginPos = begin();
|
||||
_endPos = end();
|
||||
if ( currentValue == u32char::Tabulation
|
||||
|| currentValue == u32char::Space) {
|
||||
APPL_DEBUG("select spacer");
|
||||
// Search back
|
||||
for (Iterator it = --position(_startPos);
|
||||
(bool)it == true;
|
||||
for (Iterator it = --Iterator(_startPos);
|
||||
it != m_data.begin();
|
||||
--it) {
|
||||
currentValue = *it;
|
||||
if ( currentValue != u32char::Tabulation
|
||||
@ -375,8 +375,8 @@ bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos,
|
||||
}
|
||||
}
|
||||
// Search forward
|
||||
for (Iterator it = position(_startPos);
|
||||
(bool)it == true;
|
||||
for (Iterator it = _startPos;
|
||||
it != m_data.end();
|
||||
++it) {
|
||||
currentValue = *it;
|
||||
if ( currentValue != u32char::Tabulation
|
||||
@ -390,8 +390,8 @@ bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos,
|
||||
|| currentValue == '_') {
|
||||
APPL_DEBUG("select normal Char");
|
||||
// Search back
|
||||
for (Iterator it = --position(_startPos);
|
||||
(bool)it == true;
|
||||
for (Iterator it = --Iterator(_startPos);
|
||||
it == m_data.begin();
|
||||
--it) {
|
||||
currentValue = *it;
|
||||
if ( currentValue != '_'
|
||||
@ -401,8 +401,8 @@ bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos,
|
||||
}
|
||||
}
|
||||
// Search forward
|
||||
for (Iterator it = position(_startPos);
|
||||
(bool)it == true;
|
||||
for (Iterator it = _startPos;
|
||||
it != m_data.end();
|
||||
++it) {
|
||||
currentValue = *it;
|
||||
if ( currentValue != '_'
|
||||
@ -416,8 +416,8 @@ bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos,
|
||||
APPL_DEBUG("select same char");
|
||||
char32_t comparechar = currentValue;
|
||||
// Search back
|
||||
for (Iterator it = --position(_startPos);
|
||||
(bool)it == true;
|
||||
for (Iterator it = --Iterator(_startPos);
|
||||
it == m_data.begin();
|
||||
--it) {
|
||||
currentValue = *it;
|
||||
if (comparechar != currentValue) {
|
||||
@ -426,8 +426,8 @@ bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos,
|
||||
}
|
||||
}
|
||||
// Search forward
|
||||
for (Iterator it = position(_startPos);
|
||||
(bool)it == true;
|
||||
for (Iterator it = --Iterator(_startPos);
|
||||
it != m_data.end();
|
||||
++it) {
|
||||
currentValue = *it;
|
||||
if (comparechar != currentValue) {
|
||||
@ -437,13 +437,13 @@ bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
_beginPos = begin();
|
||||
_endPos = begin();
|
||||
_beginPos = m_data.begin();
|
||||
_endPos = m_data.begin();
|
||||
return false;
|
||||
}
|
||||
|
||||
void appl::Buffer::setSelectionPos(const appl::Buffer::Iterator& _pos) {
|
||||
m_cursorSelectPos = _pos;
|
||||
m_cursorSelectPos = std::distance(m_data.begin(), _pos);
|
||||
signalSelectChange.emit();
|
||||
}
|
||||
|
||||
@ -499,8 +499,8 @@ appl::Buffer::Iterator appl::Buffer::countForwardNLines(const appl::Buffer::Iter
|
||||
char32_t value;
|
||||
int32_t lineCount = 0;
|
||||
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
|
||||
for (Iterator it = position(_startPos);
|
||||
(bool)it == true;
|
||||
for (Iterator it = Iterator(_startPos);
|
||||
it != m_data.end();
|
||||
++it) {
|
||||
value = *it;
|
||||
if (value == u32char::Return) {
|
||||
@ -519,8 +519,8 @@ appl::Buffer::Iterator appl::Buffer::countBackwardNLines(const appl::Buffer::Ite
|
||||
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
|
||||
char32_t value;
|
||||
int32_t lineCount = 0;
|
||||
for (Iterator it = --position(_startPos);
|
||||
(bool)it == true;
|
||||
for (Iterator it = --Iterator(_startPos);
|
||||
it != m_data.begin();
|
||||
--it) {
|
||||
value = *it;
|
||||
if (value == u32char::Return) {
|
||||
@ -544,7 +544,7 @@ bool appl::Buffer::copy(std::string& _data) {
|
||||
int32_t endPos = getStopSelectionPos();
|
||||
for (Iterator it = position(startPos);
|
||||
it != position(endPos) &&
|
||||
(bool)it == true;
|
||||
it != m_data.end();
|
||||
++it) {
|
||||
_data += *it;
|
||||
}
|
||||
@ -557,39 +557,33 @@ void appl::Buffer::copy(std::string& _data, const appl::Buffer::Iterator& _pos,
|
||||
_data.clear();
|
||||
for (Iterator it = _pos;
|
||||
it != _posEnd &&
|
||||
(bool)it == true;
|
||||
it != m_data.end();
|
||||
++it) {
|
||||
_data += *it;
|
||||
}
|
||||
}
|
||||
|
||||
bool appl::Buffer::write(const std::string& _data, const appl::Buffer::Iterator& _pos) {
|
||||
int64_t position = (int64_t)_pos;
|
||||
if (position < 0){
|
||||
position = 0;
|
||||
}
|
||||
APPL_VERBOSE("write at pos: " << (int64_t)_pos << " ==> " << position << " data : " << _data);
|
||||
m_data.insert(position, (int8_t*)(_data.c_str()), _data.size());
|
||||
std::u32string data2 = utf8::convertUnicode(_data);
|
||||
APPL_VERBOSE("write at pos: " << std::distance(m_data.begin(), _pos) << " data : " << data2);
|
||||
m_data.insert(_pos, data2.begin(), data2.end());
|
||||
if (m_cursorPos < 0) {
|
||||
m_cursorPos = 0;
|
||||
}
|
||||
regenerateHighLightAt(position, 0, _data.size());
|
||||
regenerateHighLightAt(std::distance(m_data.begin(), _pos), 0, data2.size());
|
||||
m_selectMode = false;
|
||||
moveCursor(position+_data.size());
|
||||
moveCursor(std::distance(m_data.begin(),_pos+data2.size()));
|
||||
countNumberofLine(); // TODO : use more intelligent counter
|
||||
setModification(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool appl::Buffer::replace(const std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) {
|
||||
int64_t position = (int64_t)_pos;
|
||||
if (position < 0){
|
||||
position = 0;
|
||||
}
|
||||
m_data.replace(position, (int64_t)_posEnd-(int64_t)_pos, (int8_t*)(_data.c_str()), _data.size());
|
||||
regenerateHighLightAt(position, (int64_t)_posEnd-(int64_t)_pos, _data.size());
|
||||
std::u32string data2 = utf8::convertUnicode(_data);
|
||||
m_data.replace(_pos, _posEnd, data2.c_str(), data2.size());
|
||||
regenerateHighLightAt(std::distance(m_data.begin(),_pos), std::distance(m_data.begin(),_posEnd)-std::distance(m_data.begin(),_pos), data2.size());
|
||||
m_selectMode = false;
|
||||
moveCursor(position+_data.size());
|
||||
moveCursor(std::distance(m_data.begin(),_pos+data2.size()));
|
||||
countNumberofLine(); // TODO : use more intelligent counter
|
||||
setModification(true);
|
||||
return true;
|
||||
@ -601,7 +595,7 @@ void appl::Buffer::removeSelection() {
|
||||
}
|
||||
int64_t startPos = getStartSelectionPos();
|
||||
int64_t endPos = getStopSelectionPos();
|
||||
m_data.remove(startPos, endPos-startPos);
|
||||
m_data.erase(startPos, endPos-startPos);
|
||||
regenerateHighLightAt(startPos, endPos-startPos, 0);
|
||||
m_selectMode = false;
|
||||
moveCursor(startPos);
|
||||
@ -823,13 +817,13 @@ void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, const ap
|
||||
//int64_t timeStart = ewol::getTime();
|
||||
|
||||
appl::Buffer::Iterator HLStartLine = getStartLine(_HLStart);
|
||||
int64_t HLStartPos = (int64_t)HLStartLine;
|
||||
int64_t HLStartPos = std::distance(m_data.begin(),HLStartLine);
|
||||
_MData.HLData.clear();
|
||||
int64_t HLStop = (int64_t)countForwardNLines(HLStartLine, _nbLines);
|
||||
int64_t HLStop = std::distance(m_data.begin(),countForwardNLines(HLStartLine, _nbLines));
|
||||
int64_t startId = 0;
|
||||
int64_t stopId = 0;
|
||||
// find element previous
|
||||
findMainHighLightPosition(_HLStart, HLStop, startId, stopId, true);
|
||||
findMainHighLightPosition(std::distance(m_data.begin(),_HLStart), HLStop, startId, stopId, true);
|
||||
|
||||
//APPL_DEBUG("List of section between : "<< startId << " & " << stopId);
|
||||
int64_t endSearch = stopId+1;
|
||||
@ -910,7 +904,7 @@ uint32_t appl::Buffer::getCursorLinesId() {
|
||||
}
|
||||
uint32_t line = 0;
|
||||
for (Iterator it = begin();
|
||||
(bool)it == true && it <= cursor();
|
||||
it != m_data.end() && it <= cursor();
|
||||
++it) {
|
||||
if (*it == u32char::Return) {
|
||||
++line;
|
||||
|
@ -222,7 +222,7 @@ void appl::TextViewer::onRegenerateDisplay() {
|
||||
int64_t startLineId = 0;
|
||||
if (m_size.y() < m_displayText.getPos().y()) {
|
||||
for (startingIt = m_buffer->begin();
|
||||
(bool)startingIt == true;
|
||||
startingIt != m_buffer->end();
|
||||
++startingIt) {
|
||||
if (*startingIt == u32char::Return) {
|
||||
++startLineId;
|
||||
@ -275,7 +275,7 @@ void appl::TextViewer::onRegenerateDisplay() {
|
||||
bool DisplayCursorAndSelection = isSelectedLast();
|
||||
appl::Buffer::Iterator it;
|
||||
for (it = startingIt;
|
||||
(bool)it == true;
|
||||
it != m_buffer->end();
|
||||
++it) {
|
||||
if (it == m_buffer->cursor()) {
|
||||
// need to display the cursor :
|
||||
@ -307,7 +307,7 @@ void appl::TextViewer::onRegenerateDisplay() {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
HLColor = m_buffer->getElementColorAtPosition(displayLocalSyntax, (int64_t)it);
|
||||
HLColor = m_buffer->getElementColorAtPosition(displayLocalSyntax, std::distance(m_buffer->begin(),it));
|
||||
bool haveBackground = false;
|
||||
if ( HLColor != nullptr
|
||||
&& HLColor->patern != nullptr) {
|
||||
@ -639,7 +639,7 @@ appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativeP
|
||||
m_displayText.forceLineReturn();
|
||||
positionCurentDisplay = m_displayText.getPos();
|
||||
for (appl::Buffer::Iterator it = m_buffer->begin();
|
||||
(bool)it == true;
|
||||
it != m_buffer->end();
|
||||
++it) {
|
||||
currentValue = *it;
|
||||
if (currentValue == u32char::Return) {
|
||||
@ -756,7 +756,7 @@ bool appl::TextViewer::moveCursor(const appl::Buffer::Iterator& _pos) {
|
||||
updateScrolling();
|
||||
return true;
|
||||
}
|
||||
m_buffer->moveCursor((int64_t)_pos);
|
||||
m_buffer->moveCursor(std::distance(m_buffer->begin(),_pos));
|
||||
updateScrolling();
|
||||
return true;
|
||||
}
|
||||
@ -937,7 +937,7 @@ appl::Buffer::Iterator appl::TextViewer::getPosSize(const appl::Buffer::Iterator
|
||||
m_displayText.clear();
|
||||
m_displayText.forceLineReturn();
|
||||
for (appl::Buffer::Iterator it = _startLinePos;
|
||||
(bool)it == true;
|
||||
it != m_buffer->end();
|
||||
++it) {
|
||||
currentValue = *it;
|
||||
m_buffer->expand(countColomn, currentValue, stringToDisplay);
|
||||
@ -965,7 +965,7 @@ float appl::TextViewer::getScreenSize(const appl::Buffer::Iterator& _startLinePo
|
||||
m_displayText.clear();
|
||||
|
||||
for (appl::Buffer::Iterator it = _startLinePos;
|
||||
(bool)it == true && it <= _stopPos;
|
||||
it != m_buffer->end() && it <= _stopPos;
|
||||
++it) {
|
||||
currentValue = *it;
|
||||
//APPL_DEBUG("parse : " << currentValue);
|
||||
|
@ -168,7 +168,7 @@ void appl::Highlight::parse(int64_t _start,
|
||||
int64_t _stop,
|
||||
std::vector<appl::HighlightInfo> & _metaData,
|
||||
int64_t _addingPos,
|
||||
etk::Buffer & _buffer) {
|
||||
std::u32string& _buffer) {
|
||||
if (0 > _addingPos) {
|
||||
_addingPos = 0;
|
||||
}
|
||||
@ -230,7 +230,7 @@ void appl::Highlight::parse(int64_t _start,
|
||||
void appl::Highlight::parse2(int64_t _start,
|
||||
int64_t _stop,
|
||||
std::vector<appl::HighlightInfo> &_metaData,
|
||||
etk::Buffer &_buffer) {
|
||||
std::u32string&_buffer) {
|
||||
HL2_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() <<
|
||||
" == > position search: (" << _start << "," << _stop << ")" );
|
||||
int64_t elementStart = _start;
|
||||
|
@ -55,11 +55,11 @@ namespace appl {
|
||||
int64_t _stop,
|
||||
std::vector<appl::HighlightInfo> &_metaData,
|
||||
int64_t _addingPos,
|
||||
etk::Buffer &_buffer);
|
||||
std::u32string &_buffer);
|
||||
void parse2(int64_t _start,
|
||||
int64_t _stop,
|
||||
std::vector<appl::HighlightInfo> &_metaData,
|
||||
etk::Buffer &_buffer);
|
||||
std::u32string &_buffer);
|
||||
private:
|
||||
void parseRules(exml::Element* _child,
|
||||
std::vector<std::unique_ptr<HighlightPattern>> &_mListPatern,
|
||||
|
@ -16,25 +16,29 @@
|
||||
appl::HighlightPattern::HighlightPattern(const std::shared_ptr<appl::GlyphPainting>& _glyphPainting) :
|
||||
m_glyphPainting(_glyphPainting),
|
||||
m_paternName(""),
|
||||
m_regExp(nullptr),
|
||||
m_regExp(),
|
||||
m_colorName(""),
|
||||
m_level(0) {
|
||||
m_regExp = std::unique_ptr<etk::RegExp<etk::Buffer>>(new etk::RegExp<etk::Buffer>());
|
||||
|
||||
}
|
||||
|
||||
appl::HighlightPattern::~HighlightPattern() {
|
||||
|
||||
}
|
||||
|
||||
void appl::HighlightPattern::setPatern(std::string& _regExp, bool forceMaximize) {
|
||||
if (m_regExp == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_regExp->compile(_regExp);
|
||||
m_regExp->setMaximize(forceMaximize);
|
||||
void appl::HighlightPattern::setPatern(const std::string& _regExp, bool forceMaximize) {
|
||||
m_regexValue = _regExp;
|
||||
const std::u32string data = utf8::convertUnicode(_regExp);
|
||||
const std::u32string data2 = U"kjhkjhk";
|
||||
const std::string data3 = "kjhkjhk";
|
||||
//std::basic_regex<char32_t, std::u32string> regexp(data2);
|
||||
std::basic_regex<char32_t> regexp((const char32_t*)data2.c_str());
|
||||
//m_regExp.assign((const std::u32string)data);
|
||||
//m_regExp.assign(_regExp);
|
||||
//m_regExp.setMaximize(forceMaximize);
|
||||
}
|
||||
std::string appl::HighlightPattern::getPaternString() {
|
||||
return m_regExp->getRegExDecorated();
|
||||
return m_regexValue;
|
||||
}
|
||||
|
||||
void appl::HighlightPattern::setColorGlyph(std::string& _colorName) {
|
||||
@ -46,7 +50,8 @@ void appl::HighlightPattern::setColorGlyph(std::string& _colorName) {
|
||||
void appl::HighlightPattern::display() {
|
||||
APPL_INFO("patern : '" << m_paternName << "' level=" << m_level );
|
||||
APPL_INFO(" == > colorName '" << m_colorName << "'");
|
||||
APPL_INFO(" == > regExp '" << m_regExp->getRegExp() << "'");
|
||||
//APPL_INFO(" == > regExp '" << m_regExp.getRegExp() << "'");
|
||||
APPL_INFO(" == > regExp '" << m_regexValue << "'");
|
||||
}
|
||||
|
||||
void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level, bool forceMaximize) {
|
||||
@ -92,23 +97,47 @@ void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level, b
|
||||
}
|
||||
}
|
||||
|
||||
typedef std::match_results<std::u32string::const_iterator> s32match;
|
||||
|
||||
enum resultFind appl::HighlightPattern::find(int32_t _start,
|
||||
int32_t _stop,
|
||||
appl::HighlightInfo& _resultat,
|
||||
etk::Buffer& _buffer) {
|
||||
const std::u32string& _buffer) {
|
||||
//APPL_DEBUG(" try to find the element");
|
||||
_resultat.start = -1;
|
||||
_resultat.stop = -1;
|
||||
_resultat.notEnded = false;
|
||||
_resultat.patern = this;
|
||||
|
||||
/*
|
||||
// when we have only one element:
|
||||
if (true == m_regExp->processOneElement(_buffer, _start, _stop)) {
|
||||
if (true == m_regExp.processOneElement(_buffer, _start, _stop)) {
|
||||
_resultat.start = m_regExp->start();
|
||||
_resultat.stop = m_regExp->stop();
|
||||
return HLP_FIND_OK;
|
||||
}
|
||||
//APPL_DEBUG("NOT find hightlightpatern ...");
|
||||
return HLP_FIND_ERROR;
|
||||
*/
|
||||
|
||||
s32match resultMatch;
|
||||
std::regex_search(_buffer, resultMatch, m_regExp);
|
||||
if (resultMatch.size() > 0) {
|
||||
_resultat.start = std::distance(_buffer.begin(), resultMatch[0].first);;
|
||||
_resultat.stop = std::distance(_buffer.begin(), resultMatch[0].second);
|
||||
/*
|
||||
if (false){
|
||||
TK_DEBUG("in line : '" << etk::to_string(_buffer) << "'");
|
||||
TK_DEBUG(" Find " << resultMatch.size() << " elements");
|
||||
for (size_t iii=0; iii<resultMatch.size(); ++iii) {
|
||||
int32_t posStart = std::distance(_buffer.begin(), resultMatch[iii].first);
|
||||
int32_t posStop = std::distance(_buffer.begin(), resultMatch[iii].second);
|
||||
TK_DEBUG(" [" << iii << "] " << *resultMatch[iii].first);
|
||||
TK_DEBUG(" [" << iii << "] " << *resultMatch[iii].second);
|
||||
TK_DEBUG(" [" << iii << "] " << etk::to_string(std::u32string(_buffer, posStart, posStop-posStart)));
|
||||
}
|
||||
}
|
||||
*/
|
||||
return HLP_FIND_OK;
|
||||
}
|
||||
return HLP_FIND_ERROR;
|
||||
}
|
||||
|
@ -14,9 +14,9 @@
|
||||
class HighlightPattern;
|
||||
|
||||
|
||||
#include <etk/RegExp.h>
|
||||
#include <appl/GlyphPainting.h>
|
||||
#include <vector>
|
||||
#include <regex>
|
||||
#include <exml/exml.h>
|
||||
#include <etk/Buffer.h>
|
||||
|
||||
@ -44,9 +44,10 @@ namespace appl {
|
||||
return m_paternName;
|
||||
};
|
||||
private:
|
||||
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExp; //!< Start of Regular expression
|
||||
std::string m_regexValue;
|
||||
std::basic_regex<char32_t> m_regExp; //!< Start of Regular expression
|
||||
public:
|
||||
void setPatern(std::string& _regExp, bool forceMaximize=false);
|
||||
void setPatern(const std::string& _regExp, bool forceMaximize=false);
|
||||
std::string getPaternString();
|
||||
private:
|
||||
std::string m_colorName; //!< Current color name
|
||||
@ -82,7 +83,7 @@ namespace appl {
|
||||
enum resultFind find(int32_t _start,
|
||||
int32_t _stop,
|
||||
appl::HighlightInfo& _resultat,
|
||||
etk::Buffer& _buffer);
|
||||
const std::u32string& _buffer);
|
||||
|
||||
void parseRules(exml::Element* _child, int32_t _level, bool forceMaximize=false);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user