[DEV] work with std::string

This commit is contained in:
2013-11-14 21:57:10 +01:00
parent a5b44ae974
commit 101f77dc3d
36 changed files with 457 additions and 420 deletions

View File

@@ -17,8 +17,8 @@
#undef __class__
#define __class__ "BufferView"
static void SortElementList(etk::Vector<appl::dataBufferStruct*>& _list) {
etk::Vector<appl::dataBufferStruct *> tmpList = _list;
static void SortElementList(std::vector<appl::dataBufferStruct*>& _list) {
std::vector<appl::dataBufferStruct *> tmpList = _list;
_list.clear();
for(int32_t iii=0; iii<tmpList.size(); iii++) {
if (NULL == tmpList[iii]) {
@@ -35,7 +35,7 @@ static void SortElementList(etk::Vector<appl::dataBufferStruct*>& _list) {
}
}
//EWOL_DEBUG("position="<<findPos);
_list.insert(findPos, tmpList[iii]);
_list.insert(_list.begin()+findPos, tmpList[iii]);
}
}
@@ -92,7 +92,7 @@ void BufferView::onReceiveMessage(const ewol::EMessage& _msg) {
APPL_ERROR("Allocation error of the tmp buffer list element");
return;
}
m_list.pushBack(tmp);
m_list.push_back(tmp);
markToRedraw();
return;
}
@@ -140,7 +140,7 @@ void BufferView::onReceiveMessage(const ewol::EMessage& _msg) {
etk::FSNode name = tmpBuffer->getFileName();
appl::dataBufferStruct* tmpElement = new appl::dataBufferStruct(name, iii, isModify);
if (NULL != tmpElement) {
m_list.pushBack(tmpElement);
m_list.push_back(tmpElement);
} else {
APPL_ERROR("Allocation error of the tmp buffer list element");
}
@@ -175,7 +175,7 @@ void BufferView::onObjectRemove(ewol::EObject* _removeObject) {
if (m_list[iii]->m_buffer != _removeObject) {
continue;
}
m_list.remove(iii);
m_list.erase(m_list.begin()+iii);
markToRedraw();
return;
}
@@ -190,7 +190,7 @@ uint32_t BufferView::getNuberOfColomn(void) {
return 1;
}
bool BufferView::getTitle(int32_t _colomn, etk::UString &_myTitle, etk::Color<> &_fg, etk::Color<> &_bg) {
bool BufferView::getTitle(int32_t _colomn, std::string &_myTitle, etk::Color<> &_fg, etk::Color<> &_bg) {
_myTitle = "Buffers : ";
return true;
}
@@ -199,7 +199,7 @@ uint32_t BufferView::getNuberOfRaw(void) {
return m_list.size();
}
bool BufferView::getElement(int32_t _colomn, int32_t _raw, etk::UString& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
bool BufferView::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
if( _raw >= 0
&& _raw<m_list.size()
&& NULL != m_list[_raw]) {

View File

@@ -22,7 +22,7 @@ namespace appl
public:
etk::FSNode m_bufferName;
appl::Buffer* m_buffer;
dataBufferStruct(const etk::UString& _bufferName, appl::Buffer* _buffer) :
dataBufferStruct(const std::string& _bufferName, appl::Buffer* _buffer) :
m_bufferName(_bufferName),
m_buffer(_buffer) {
@@ -45,7 +45,7 @@ class BufferView : public widget::List
private:
int32_t m_selectedIdRequested;
int32_t m_selectedID;
etk::Vector<appl::dataBufferStruct*> m_list;
std::vector<appl::dataBufferStruct*> m_list;
public:
// Constructeur
BufferView(void);
@@ -61,9 +61,9 @@ class BufferView : public widget::List
void removeAllElement(void);
// Derived function
virtual uint32_t getNuberOfColomn(void);
virtual bool getTitle(int32_t _colomn, etk::UString& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg);
virtual bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg);
virtual uint32_t getNuberOfRaw(void);
virtual bool getElement(int32_t _colomn, int32_t _raw, etk::UString& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg);
virtual bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg);
virtual bool onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y);
};

View File

@@ -34,14 +34,14 @@
namespace appl
{
etk::UString getVersion(void)
std::string getVersion(void)
{
#define FIRST_YEAR (2010)
etk::UString tmpOutput = (date::getYear()-FIRST_YEAR);
std::string tmpOutput = std::to_string(date::getYear()-FIRST_YEAR);
tmpOutput += ".";
tmpOutput += date::getMonth();
tmpOutput += std::to_string(date::getMonth());
tmpOutput += ".";
tmpOutput += date::getDay();
tmpOutput += std::to_string(date::getDay());
return tmpOutput;
}
@@ -67,7 +67,7 @@ class ParameterAboutGui : public widget::Sizer {
mySpacer->setExpand(bvec2(true,true));
subWidgetAdd(mySpacer);
}
etk::UString tmpLabel = "<left>";
std::string tmpLabel = "<left>";
tmpLabel += " <b>Editeur De N'ours</b> : v:";
tmpLabel += appl::getVersion();
tmpLabel += "<br/>";
@@ -239,7 +239,7 @@ MainWindows::MainWindows(void) {
// add generic shortcut ...
// (shift, control, alt, meta, etk::UChar unicodeValue, const char * generateEventId, etk::UString& data)
// (shift, control, alt, meta, char32_t unicodeValue, const char * generateEventId, std::string& data)
shortCutAdd("ctrl+o", ednMsgGuiOpen, "", true);
shortCutAdd("ctrl+n", ednMsgGuiNew, "", true);
@@ -322,7 +322,7 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
APPL_ERROR("can not call unexistant buffer manager ... ");
return;
}
if (_msg.getData().toLower() == "current") {
if (to_lower(_msg.getData()) == "current") {
appl::Buffer* tmpBuffer = m_bufferManager->getBufferSelected();
if (tmpBuffer == NULL) {
APPL_WARNING("No buffer selected !!! ");
@@ -340,7 +340,7 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
APPL_ERROR("can not save the file !!! '" << tmpBuffer->getFileName() << "'");
}
return;
} else if (_msg.getData().toLower() == "all") {
} else if (to_lower(_msg.getData()) == "all") {
APPL_TODO("Need to save all the buffers ... ");
for (esize_t iii=0; iii < m_bufferManager->size(); ++iii) {
appl::Buffer* tmpBuffer = m_bufferManager->get(iii);
@@ -386,8 +386,8 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
} else {
tmpWidget->setTitle("Save files As...");
tmpWidget->setValidateLabel("Save");
etk::UString folder = "/home/";
etk::UString fileName = "";
std::string folder = "/home/";
std::string fileName = "";
if (true == myBuffer->haveName()) {
etk::FSNode tmpName = myBuffer->getFileName();
folder = tmpName.getNameFolder();
@@ -403,7 +403,7 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
}
} else if (_msg.getMessage() == ednEventPopUpFileSaveAs) {
// get the filename :
etk::UString tmpData = _msg.getData();
std::string tmpData = _msg.getData();
APPL_DEBUG("Request Saving As file : " << tmpData);
/*
BufferManager::get(m_currentSavingAsIdBuffer)->setFileName(tmpData);
@@ -417,14 +417,14 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
if (NULL != tmpBuffer) {
etk::FSNode compleateName = tmpBuffer->getFileName();
bool isModify = tmpBuffer->isModify();
etk::UString directName = compleateName.getName();
std::string directName = compleateName.getName();
if (true == isModify) {
directName += " *";
}
if (NULL != m_widgetLabelFileName) {
m_widgetLabelFileName->setLabel(etk::UString("<left>") + directName + "</left>");
m_widgetLabelFileName->setLabel(std::string("<left>") + directName + "</left>");
}
etk::UString windowsTitle = "edn - ";
std::string windowsTitle = "edn - ";
windowsTitle += directName;
setTitle(windowsTitle);
return;

View File

@@ -14,13 +14,13 @@
#define __class__ "SearchData"
static etk::UString m_findRequest = "";
static std::string m_findRequest = "";
void SearchData::setSearch(const etk::UString &myData)
void SearchData::setSearch(const std::string &myData)
{
m_findRequest = myData;
}
void SearchData::getSearch(etk::UString &myData)
void SearchData::getSearch(std::string &myData)
{
myData = m_findRequest;
}
@@ -32,12 +32,12 @@ bool SearchData::isSearchEmpty(void)
return true;
}
static etk::UString m_replaceRequest = "";
void SearchData::setReplace(const etk::UString &myData)
static std::string m_replaceRequest = "";
void SearchData::setReplace(const std::string &myData)
{
m_replaceRequest = myData;
}
void SearchData::getReplace(etk::UString &myData)
void SearchData::getReplace(std::string &myData)
{
myData = m_replaceRequest;
}

View File

@@ -14,11 +14,11 @@
namespace SearchData
{
void setSearch(const etk::UString &myData);
void getSearch(etk::UString &myData);
void setSearch(const std::string &myData);
void getSearch(std::string &myData);
bool isSearchEmpty(void);
void setReplace(const etk::UString &myData);
void getReplace(etk::UString &myData);
void setReplace(const std::string &myData);
void getReplace(std::string &myData);
bool isReplaceEmpty(void);
void setCase(bool value);
bool getCase(void);

View File

@@ -41,7 +41,7 @@ uint32_t appl::TagFileList::getNuberOfColomn(void) {
return 2;
}
bool appl::TagFileList::getTitle(int32_t _colomn, etk::UString& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg) {
bool appl::TagFileList::getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg) {
_myTitle = "title";
return true;
}
@@ -50,10 +50,10 @@ uint32_t appl::TagFileList::getNuberOfRaw(void) {
return m_list.size();
}
bool appl::TagFileList::getElement(int32_t _colomn, int32_t _raw, etk::UString& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
bool appl::TagFileList::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
if (_raw >= 0 && _raw < m_list.size() && NULL != m_list[_raw]) {
if (0 == _colomn) {
_myTextToWrite = etk::UString(m_list[_raw]->fileLine);
_myTextToWrite = std::to_string(m_list[_raw]->fileLine);
} else {
_myTextToWrite = m_list[_raw]->filename;
}
@@ -102,7 +102,7 @@ bool appl::TagFileList::onItemEvent(int32_t _IdInput, enum ewol::keyEvent::statu
if( m_selectedLine >= 0
&& m_selectedLine < m_list.size()
&& NULL != m_list[m_selectedLine] ) {
generateEventId(event, etk::UString(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename);
generateEventId(event, std::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename);
} else {
generateEventId(applEventCtagsListUnSelect);
}
@@ -120,10 +120,10 @@ bool appl::TagFileList::onItemEvent(int32_t _IdInput, enum ewol::keyEvent::statu
* @param[in] file Compleate file name
* @param[in] jump line id
*/
void appl::TagFileList::add(etk::UString& _file, int32_t _line) {
void appl::TagFileList::add(std::string& _file, int32_t _line) {
appl::TagListElement *tmpFile = new appl::TagListElement(_file, _line);
if (NULL != tmpFile) {
m_list.pushBack(tmpFile);
m_list.push_back(tmpFile);
}
markToRedraw();
}

View File

@@ -20,9 +20,9 @@ extern const char * const applEventCtagsListUnSelect;
namespace appl {
class TagListElement {
public:
etk::UString filename;
std::string filename;
int32_t fileLine;
TagListElement(etk::UString& _file, int32_t _line) :
TagListElement(std::string& _file, int32_t _line) :
filename(_file),
fileLine(_line) {
@@ -34,16 +34,16 @@ namespace appl {
class TagFileList : public widget::List {
private:
int32_t m_selectedLine;
etk::Vector<appl::TagListElement*> m_list;
std::vector<appl::TagListElement*> m_list;
public:
TagFileList(void);
~TagFileList(void);
// display API :
virtual etk::Color<> getBasicBG(void);
uint32_t getNuberOfColomn(void);
bool getTitle(int32_t _colomn, etk::UString& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg);
bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg);
uint32_t getNuberOfRaw(void);
bool getElement(int32_t _colomn, int32_t _raw, etk::UString& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg);
bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg);
bool onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y);
// derived function
const char * const getObjectType(void) {
@@ -55,7 +55,7 @@ namespace appl {
* @param[in] file Compleate file name
* @param[in] jump line id
*/
void add(etk::UString& _file, int32_t _line);
void add(std::string& _file, int32_t _line);
};
};

View File

@@ -159,7 +159,7 @@ void appl::TagFileSelection::onReceiveMessage(const ewol::EMessage& _msg) {
* @param[in] file Compleate file name
* @param[in] jump line id
*/
void appl::TagFileSelection::addCtagsNewItem(etk::UString _file, int32_t _line) {
void appl::TagFileSelection::addCtagsNewItem(std::string _file, int32_t _line) {
if (NULL != m_listTag) {
m_listTag->add(_file, _line);
}

View File

@@ -20,7 +20,7 @@ namespace appl {
class TagFileSelection : public widget::PopUp {
private:
appl::TagFileList* m_listTag;
etk::UString m_eventNamed;
std::string m_eventNamed;
public:
TagFileSelection(void);
virtual ~TagFileSelection(void);
@@ -29,7 +29,7 @@ namespace appl {
* @param[in] file Compleate file name
* @param[in] jump line id
*/
void addCtagsNewItem(etk::UString file, int32_t line);
void addCtagsNewItem(std::string file, int32_t line);
public: // herited function
const char * const getObjectType(void) { return "EwolFileChooser"; };
void onReceiveMessage(const ewol::EMessage& _msg);

View File

@@ -21,7 +21,7 @@
#undef __class__
#define __class__ "TextViewer"
appl::TextViewer::TextViewer(const etk::UString& _fontName, int32_t _fontSize) :
appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) :
m_buffer(NULL),
m_displayText(_fontName, _fontSize),
m_insertMode(false) {
@@ -109,7 +109,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
m_maxSize.setY(256);
m_displayText.setTextAlignement(10, m_size.x()-20, ewol::Text::alignLeft);
m_displayText.setRelPos(vec3(10, 0, 0));
etk::UString tmpString("<br/>\n"
std::string tmpString("<br/>\n"
"<font color=\"red\">\n"
" <b>\n"
" edn - Editeur De N'ours\n"
@@ -137,7 +137,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
float countNbLine = 1;
esize_t countColomn = 0;
// the siplay string :
etk::UString stringToDisplay;
std::u32string stringToDisplay;
esize_t bufferElementSize = 0;
bool isSelect = false;
appl::Buffer::Iterator selectPosStart = m_buffer->begin();
@@ -166,7 +166,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
}
// Display line number :
m_lastOffsetDisplay = 0;
vec3 tmpLetterSize = m_displayText.calculateSize((etk::UChar)'A');
vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A');
{
esize_t nbLine = m_buffer->getNumberOfLines();
float nbLineCalc = nbLine;
@@ -277,7 +277,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
}
// set maximum size (X&Y) :
{
vec3 tmpLetterSize = m_displayText.calculateSize((etk::UChar)'A');
vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A');
esize_t nbLines = m_buffer->getNumberOfLines();
m_maxSize.setX(maxSizeX+m_originScrooled.x());
m_maxSize.setY((float)nbLines*tmpLetterSize.y());
@@ -302,7 +302,7 @@ bool appl::TextViewer::onEventEntry(const ewol::EventEntry& _event) {
if (_event.getStatus() != ewol::keyEvent::statusDown) {
return false;
}
etk::UChar localValue = _event.getChar();
char32_t localValue = _event.getChar();
if (localValue == etk::UChar::Return) {
if (true == _event.getSpecialKey().isSetShift()) {
localValue = etk::UChar::CarrierReturn;
@@ -333,15 +333,16 @@ bool appl::TextViewer::onEventEntry(const ewol::EventEntry& _event) {
m_buffer->setSelectMode(false);
// normal adding char ...
char output[5];
int32_t nbElement = localValue.getUtf8(output);
int32_t nbElement = etk::getUtf8(localValue, output);
if ( m_buffer->hasTextSelected() == false
&& _event.getSpecialKey().isSetInsert() == true) {
appl::Buffer::Iterator pos = m_buffer->cursor();
appl::Buffer::Iterator posEnd = pos;
++posEnd;
replace(localValue, pos, posEnd);
replace(output, pos, posEnd);
//TODO : choisce UTF ... replace(localValue, pos, posEnd);
} else {
etk::UString myString = output;
std::string myString = output;
write(myString);
}
return true;
@@ -492,11 +493,11 @@ void appl::TextViewer::mouseEventTriple(void) {
}
appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativePos) {
etk::UChar currentValue;
char32_t currentValue;
vec3 positionCurentDisplay(0,0,0);
vec3 tmpLetterSize = m_displayText.calculateSize((etk::UChar)'A');
vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A');
esize_t countColomn = 0;
etk::UString stringToDisplay;
std::u32string stringToDisplay;
m_displayText.clear();
m_displayText.forceLineReturn();
for (appl::Buffer::Iterator it = m_buffer->begin();
@@ -532,7 +533,7 @@ appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativeP
void appl::TextViewer::onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID) {
if (m_buffer != NULL) {
etk::UString data = ewol::clipBoard::get(_clipboardID);
std::string data = ewol::clipBoard::get(_clipboardID);
write(data);
}
markToRedraw();
@@ -602,7 +603,7 @@ void appl::TextViewer::setFontSize(int32_t _size) {
setScrollingSize(_size*3.0*1.46); // 1.46 is a magic number ...
}
void appl::TextViewer::setFontName(const etk::UString& _fontName) {
void appl::TextViewer::setFontName(const std::string& _fontName) {
m_displayText.setFontName(_fontName);
}
@@ -618,7 +619,7 @@ bool appl::TextViewer::moveCursor(const appl::Buffer::Iterator& _pos) {
return true;
}
bool appl::TextViewer::write(const etk::UString& _data) {
bool appl::TextViewer::write(const std::string& _data) {
if (m_buffer == NULL) {
return false;
}
@@ -628,7 +629,7 @@ bool appl::TextViewer::write(const etk::UString& _data) {
return write(_data, m_buffer->cursor());
}
bool appl::TextViewer::write(const etk::UString& _data, const appl::Buffer::Iterator& _pos) {
bool appl::TextViewer::write(const std::string& _data, const appl::Buffer::Iterator& _pos) {
if (m_buffer == NULL) {
return false;
}
@@ -642,7 +643,7 @@ bool appl::TextViewer::write(const etk::UString& _data, const appl::Buffer::Iter
return ret;
}
bool appl::TextViewer::replace(const etk::UString& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) {
bool appl::TextViewer::replace(const std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) {
if (m_buffer == NULL) {
return false;
}
@@ -656,7 +657,7 @@ bool appl::TextViewer::replace(const etk::UString& _data, const appl::Buffer::It
return ret;
}
bool appl::TextViewer::replace(const etk::UString& _data) {
bool appl::TextViewer::replace(const std::string& _data) {
if (m_buffer == NULL) {
return false;
}
@@ -788,9 +789,9 @@ void appl::TextViewer::moveCursorDown(esize_t _nbLine) {
// TODO : Rename ...
appl::Buffer::Iterator appl::TextViewer::getPosSize(const appl::Buffer::Iterator& _startLinePos, float _distance) {
etk::UChar currentValue;
char32_t currentValue;
esize_t countColomn = 0;
etk::UString stringToDisplay;
std::u32string stringToDisplay;
m_displayText.clear();
m_displayText.forceLineReturn();
for (appl::Buffer::Iterator it = _startLinePos;
@@ -816,9 +817,9 @@ appl::Buffer::Iterator appl::TextViewer::getPosSize(const appl::Buffer::Iterator
// TODO : Rename ...
float appl::TextViewer::getScreenSize(const appl::Buffer::Iterator& _startLinePos, const appl::Buffer::Iterator& _stopPos) {
float ret = 0;
etk::UChar currentValue;
char32_t currentValue;
esize_t countColomn = 0;
etk::UString stringToDisplay;
std::u32string stringToDisplay;
m_displayText.clear();
for (appl::Buffer::Iterator it = _startLinePos;

View File

@@ -42,7 +42,7 @@ namespace appl {
private:
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
public:
TextViewer(const etk::UString& _fontName="", int32_t _fontSize=-1);
TextViewer(const std::string& _fontName="", int32_t _fontSize=-1);
virtual ~TextViewer(void);
private:
appl::Buffer* m_buffer; //!< pointer on the current buffer to display (can be null if the buffer is remover or in state of changing buffer)
@@ -50,7 +50,7 @@ namespace appl {
ewol::Drawing m_displayDrawing; //!< Other diaplay requested.
public:
void setFontSize(int32_t _size);
void setFontName(const etk::UString& _fontName);
void setFontName(const std::string& _fontName);
protected: // derived function
virtual void onDraw(void);
public: // Derived function
@@ -73,10 +73,10 @@ namespace appl {
public:
// TODO : Doc : write data on buffer
bool moveCursor(const appl::Buffer::Iterator& _pos);
bool write(const etk::UString& _data);
bool write(const etk::UString& _data, const appl::Buffer::Iterator& _pos);
bool replace(const etk::UString& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd);
bool replace(const etk::UString& _data);
bool write(const std::string& _data);
bool write(const std::string& _data, const appl::Buffer::Iterator& _pos);
bool replace(const std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd);
bool replace(const std::string& _data);
void remove(void);