[DEV] update for build URI

This commit is contained in:
Edouard DUPIN 2018-09-29 21:59:06 +02:00
parent 1d65639191
commit a044d64f02
32 changed files with 245 additions and 278 deletions

View File

@ -122,7 +122,7 @@ appl::Buffer::Buffer() :
m_highlight(null) { m_highlight(null) {
addObjectType("appl::Buffer"); addObjectType("appl::Buffer");
static int32_t bufferBaseId = 0; static int32_t bufferBaseId = 0;
m_fileName = etk::FSNode("REL:No Name " + etk::toString(bufferBaseId)).getFileSystemName(); m_fileName = "No Name " + etk::toString(bufferBaseId);
bufferBaseId++; bufferBaseId++;
} }
@ -134,18 +134,15 @@ appl::Buffer::~Buffer() {
APPL_ERROR("REAL remove buffer : '" << propertyName << "'"); APPL_ERROR("REAL remove buffer : '" << propertyName << "'");
} }
bool appl::Buffer::loadFile(const etk::String& _name) { bool appl::Buffer::loadFile(const etk::Path& _name) {
APPL_DEBUG("Convert filename :'" << _name << "'"); APPL_DEBUG("Convert filename :'" << _name << "'");
etk::FSNode file(_name); m_fileName = _name;
etk::String name = file.getName();
APPL_INFO("Load file : '" << name << "'");
m_fileName = file.getFileSystemName();
m_hasFileName = true; m_hasFileName = true;
m_isModify = true; m_isModify = true;
m_cursorPos = 0; m_cursorPos = 0;
setHighlightType(""); setHighlightType("");
m_nbLines = 0; m_nbLines = 0;
if (m_data.dumpFrom(m_fileName) == true ) { if (m_data.dumpFrom(_name) == true ) {
countNumberofLine(); countNumberofLine();
tryFindHighlightType(); tryFindHighlightType();
m_isModify = false; m_isModify = false;
@ -154,14 +151,12 @@ bool appl::Buffer::loadFile(const etk::String& _name) {
return false; return false;
} }
void appl::Buffer::setFileName(const etk::String& _name) { void appl::Buffer::setFileName(const etk::Path& _name) {
APPL_DEBUG("Convert filename :'" << _name << "'"); APPL_DEBUG("Convert filename :'" << _name << "'");
etk::FSNode file(_name); if (m_fileName == _name) {
etk::String name = file.getName();
if (m_fileName == file.getFileSystemName()) {
return; return;
} }
m_fileName = file.getFileSystemName(); m_fileName = _name;
m_hasFileName = true; m_hasFileName = true;
signalChangeName.emit(); signalChangeName.emit();
setModification(true); setModification(true);
@ -675,8 +670,7 @@ void appl::Buffer::removeSelection() {
} }
void appl::Buffer::tryFindHighlightType() { void appl::Buffer::tryFindHighlightType() {
etk::FSNode file(m_fileName); etk::String type = appl::highlightManager::getTypeFile(m_fileName.getFileName());
etk::String type = appl::highlightManager::getTypeFile(file.getNameFile());
if (type.size() == 0) { if (type.size() == 0) {
return; return;
} }
@ -1013,7 +1007,7 @@ uint32_t appl::Buffer::getCursorLinesId() {
namespace etk { namespace etk {
template<> etk::String toString<ememory::SharedPtr<appl::Buffer>>(const ememory::SharedPtr<appl::Buffer>& _obj) { template<> etk::String toString<ememory::SharedPtr<appl::Buffer>>(const ememory::SharedPtr<appl::Buffer>& _obj) {
if (_obj != null) { if (_obj != null) {
return _obj->getFileName(); return _obj->getFileName().getString();
} }
return ""; return "";
} }
@ -1032,7 +1026,7 @@ namespace etk {
return from_string(_variableRet, etk::toString(_value)); return from_string(_variableRet, etk::toString(_value));
} }
template<> etk::String toString<appl::Buffer>(const appl::Buffer& _obj) { template<> etk::String toString<appl::Buffer>(const appl::Buffer& _obj) {
return _obj.getFileName(); return _obj.getFileName().getString();
} }
template<> etk::UString toUString<appl::Buffer>(const appl::Buffer& _obj) { template<> etk::UString toUString<appl::Buffer>(const appl::Buffer& _obj) {
return etk::toUString(etk::toString(_obj)); return etk::toUString(etk::toString(_obj));

View File

@ -6,7 +6,6 @@
#pragma once #pragma once
#include <etk/types.hpp> #include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <ewol/ewol.hpp> #include <ewol/ewol.hpp>
#include <etk/Buffer.hpp> #include <etk/Buffer.hpp>
#include <ewol/object/Object.hpp> #include <ewol/object/Object.hpp>
@ -300,12 +299,12 @@ namespace appl {
virtual ~Buffer(); virtual ~Buffer();
private: private:
bool m_hasFileName; //!< When new file, the buffer has no name ==> but it might be reference with a single name ... bool m_hasFileName; //!< When new file, the buffer has no name ==> but it might be reference with a single name ...
etk::String m_fileName; //!< name of the file (with his path) etk::Path m_fileName; //!< name of the file (with his path)
public: public:
/** /**
* @brief get the curent filename of the Buffer * @brief get the curent filename of the Buffer
*/ */
const etk::String& getFileName() const { const etk::Path& getFileName() const {
return m_fileName; return m_fileName;
} }
/** /**
@ -320,12 +319,12 @@ namespace appl {
* @param[in] _name name of the file. * @param[in] _name name of the file.
* @return true if file corectly opened. * @return true if file corectly opened.
*/ */
bool loadFile(const etk::String& _name); bool loadFile(const etk::Path& _name);
/** /**
* @brief Set a file name at this buffer (no saving ...) * @brief Set a file name at this buffer (no saving ...)
* @param[in] _name name of the file. * @param[in] _name name of the file.
*/ */
void setFileName(const etk::String& _name); void setFileName(const etk::Path& _name);
/** /**
* @brief save the file in the specify path. * @brief save the file in the specify path.
* @return true is saving well done * @return true is saving well done

View File

@ -4,7 +4,7 @@
* @license GPL v3 (see license file) * @license GPL v3 (see license file)
*/ */
#include <etk/types.hpp> #include <etk/types.hpp>
#include <etk/os/FSNode.hpp> #include <etk/path/fileSystem.hpp>
#include <appl/debug.hpp> #include <appl/debug.hpp>
#include <appl/global.hpp> #include <appl/global.hpp>
#include <appl/BufferManager.hpp> #include <appl/BufferManager.hpp>
@ -17,9 +17,7 @@ appl::BufferManager::BufferManager() :
signalNewBuffer(this, "new-buffer", ""), signalNewBuffer(this, "new-buffer", ""),
signalSelectFile(this, "select-buffer", ""), signalSelectFile(this, "select-buffer", ""),
signalTextSelectionChange(this, "text-selection-change", ""), signalTextSelectionChange(this, "text-selection-change", ""),
signalRemoveBuffer(this, "remove-buffer", ""), signalRemoveBuffer(this, "remove-buffer", "") {
signalSelectBuffer(this, "select-buffer-2", ""),
signalNewBuffer2(this, "new-buffer-2", "") {
addObjectType("appl::BufferManager"); addObjectType("appl::BufferManager");
} }
@ -37,17 +35,15 @@ ememory::SharedPtr<appl::Buffer> appl::BufferManager::createNewBuffer() {
tmp->setParent(ewol::Object::sharedFromThis()); tmp->setParent(ewol::Object::sharedFromThis());
m_list.pushBack(tmp); m_list.pushBack(tmp);
APPL_INFO("Create a new Buffer"); APPL_INFO("Create a new Buffer");
signalNewBuffer.emit(tmp->getFileName()); signalNewBuffer.emit(tmp);
signalNewBuffer2.emit(tmp);
APPL_INFO("Create a new Buffer (done)"); APPL_INFO("Create a new Buffer (done)");
APPL_INFO("select Buffer"); APPL_INFO("select Buffer");
signalSelectFile.emit(tmp->getFileName()); signalSelectFile.emit(tmp);
signalSelectBuffer.emit(tmp);
APPL_INFO("select Buffer (done)"); APPL_INFO("select Buffer (done)");
return tmp; return tmp;
} }
ememory::SharedPtr<appl::Buffer> appl::BufferManager::get(const etk::String& _fileName, bool _createIfNeeded) { ememory::SharedPtr<appl::Buffer> appl::BufferManager::get(const etk::Path& _fileName, bool _createIfNeeded) {
APPL_INFO("get('" << _fileName << "'," << _createIfNeeded << ")"); APPL_INFO("get('" << _fileName << "'," << _createIfNeeded << ")");
for (auto &it : m_list) { for (auto &it : m_list) {
if (it == null) { if (it == null) {
@ -58,7 +54,7 @@ ememory::SharedPtr<appl::Buffer> appl::BufferManager::get(const etk::String& _fi
} }
} }
if (_createIfNeeded == true) { if (_createIfNeeded == true) {
if (etk::FSNodeGetType(_fileName) == etk::typeNode_folder) { if (etk::path::isDirectory(_fileName) == true) {
APPL_WARNING("try open a folder : " << _fileName); APPL_WARNING("try open a folder : " << _fileName);
APPL_CRITICAL("plop"); APPL_CRITICAL("plop");
return null; return null;
@ -72,8 +68,7 @@ ememory::SharedPtr<appl::Buffer> appl::BufferManager::get(const etk::String& _fi
tmp->loadFile(_fileName); tmp->loadFile(_fileName);
m_list.pushBack(tmp); m_list.pushBack(tmp);
APPL_INFO("Creata a open Buffer"); APPL_INFO("Creata a open Buffer");
signalNewBuffer.emit(tmp->getFileName()); signalNewBuffer.emit(tmp);
signalNewBuffer2.emit(tmp);
APPL_INFO("Creata a open Buffer (done)"); APPL_INFO("Creata a open Buffer (done)");
return tmp; return tmp;
} }
@ -104,8 +99,7 @@ ememory::SharedPtr<appl::Buffer> appl::BufferManager::get(int32_t _id) {
return m_list.back(); return m_list.back();
} }
bool appl::BufferManager::exist(const etk::String& _fileName) { bool appl::BufferManager::exist(const etk::Path& _fileName) {
APPL_WARNING(" Check if buffer exist: '" << _fileName << "'");
for (auto &it : m_list) { for (auto &it : m_list) {
if (it == null) { if (it == null) {
continue; continue;
@ -120,23 +114,20 @@ bool appl::BufferManager::exist(const etk::String& _fileName) {
return false; return false;
} }
void appl::BufferManager::open(const etk::String& _fileName) { void appl::BufferManager::open(const etk::Path& _fileName) {
etk::FSNode file(_fileName); if (exist(_fileName) == true) {
etk::String fileName = file.getName(); APPL_WARNING(" the element '" << _fileName << "' already exist ... just reselect it ...");
if (exist(fileName) == true) { signalSelectFile.emit(get(_fileName));
APPL_WARNING(" the element '" << fileName << "' already exist ... just reselect it ..."); propertySetOnWidgetNamed("appl-widget-display-name", "value", _fileName.getString());
signalSelectFile.emit(fileName);
signalSelectBuffer.emit(get(fileName));
propertySetOnWidgetNamed("appl-widget-display-name", "value", etk::FSNodeGetRealName(fileName));
return; return;
} }
if (get(fileName, true) == null) { auto value = get(_fileName, true);
APPL_ERROR("Error get '" << fileName << "' ... "); if (value == null) {
APPL_ERROR("Error get '" << _fileName << "' ... ");
return; return;
} }
signalSelectFile.emit(fileName); signalSelectFile.emit(value);
signalSelectBuffer.emit(get(fileName)); propertySetOnWidgetNamed("appl-widget-display-name", "value", _fileName.getString());
propertySetOnWidgetNamed("appl-widget-display-name", "value", etk::FSNodeGetRealName(fileName));
} }
void appl::BufferManager::requestDestroyFromChild(const ememory::SharedPtr<Object>& _child) { void appl::BufferManager::requestDestroyFromChild(const ememory::SharedPtr<Object>& _child) {
@ -164,23 +155,20 @@ void appl::BufferManager::requestDestroyFromChild(const ememory::SharedPtr<Objec
if ( it != m_list.end() if ( it != m_list.end()
&& *it != null) { && *it != null) {
APPL_VERBOSE("Remove buffer select new one"); APPL_VERBOSE("Remove buffer select new one");
signalSelectFile.emit((*it)->getFileName()); signalSelectFile.emit(*it);
signalSelectBuffer.emit(*it); propertySetOnWidgetNamed("appl-widget-display-name", "value", (*it)->getFileName().getString());
propertySetOnWidgetNamed("appl-widget-display-name", "value", etk::FSNodeGetRealName((*it)->getFileName()));
APPL_VERBOSE("Remove buffer select new one (done)"); APPL_VERBOSE("Remove buffer select new one (done)");
return; return;
} }
if ( m_list.size() != 0 if ( m_list.size() != 0
&& m_list.back() != null) { && m_list.back() != null) {
APPL_VERBOSE("Remove buffer select new one (last)"); APPL_VERBOSE("Remove buffer select new one (last)");
signalSelectFile.emit(m_list.back()->getFileName()); signalSelectFile.emit(m_list.back());
signalSelectBuffer.emit(m_list.back()); propertySetOnWidgetNamed("appl-widget-display-name", "value", m_list.back()->getFileName().getString());
propertySetOnWidgetNamed("appl-widget-display-name", "value", etk::FSNodeGetRealName(m_list.back()->getFileName()));
APPL_VERBOSE("Remove buffer select new one (done)"); APPL_VERBOSE("Remove buffer select new one (done)");
return; return;
} }
signalSelectFile.emit(""); signalSelectFile.emit(null);
signalSelectBuffer.emit(null);
propertySetOnWidgetNamed("appl-widget-display-name", "value", "---"); propertySetOnWidgetNamed("appl-widget-display-name", "value", "---");
m_bufferSelected = null; m_bufferSelected = null;
} }

View File

@ -16,13 +16,11 @@ namespace appl {
using BufferManagerWeak = ememory::WeakPtr<appl::BufferManager>; using BufferManagerWeak = ememory::WeakPtr<appl::BufferManager>;
// TODO: This is a service ... // TODO: This is a service ...
class BufferManager : public ewol::Object { class BufferManager : public ewol::Object {
public: // signals: public:
esignal::Signal<etk::String> signalNewBuffer; esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalNewBuffer;
esignal::Signal<etk::String> signalSelectFile; esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalSelectFile;
esignal::Signal<> signalTextSelectionChange; esignal::Signal<> signalTextSelectionChange;
esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalRemoveBuffer; esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalRemoveBuffer;
esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalSelectBuffer;
esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalNewBuffer2;
protected: protected:
BufferManager(); BufferManager();
public: public:
@ -37,18 +35,18 @@ namespace appl {
* @param[in] _createIfNeeded Create the buffer if not existed. * @param[in] _createIfNeeded Create the buffer if not existed.
* @return a pointer on the buffer * @return a pointer on the buffer
*/ */
ememory::SharedPtr<appl::Buffer> get(const etk::String& _fileName, bool _createIfNeeded=false); ememory::SharedPtr<appl::Buffer> get(const etk::Path& _fileName, bool _createIfNeeded=false);
/** /**
* @brief Load a specific file, event if it not existed: * @brief Load a specific file, event if it not existed:
* @param[in] _fileName Name of the file to open or create. * @param[in] _fileName Name of the file to open or create.
*/ */
void open(const etk::String& _fileName); void open(const etk::Path& _fileName);
/** /**
* @brief Check if a buffer is already open. * @brief Check if a buffer is already open.
* @param[in] _fileName name of the file. * @param[in] _fileName name of the file.
* @return true if the buffer is already open. * @return true if the buffer is already open.
*/ */
bool exist(const etk::String& _fileName); bool exist(const etk::Path& _fileName);
/** /**
* @brief Get count of all buffer availlable. * @brief Get count of all buffer availlable.
* @return Number of buffer * @return Number of buffer

View File

@ -7,7 +7,6 @@
#include <appl/global.hpp> #include <appl/global.hpp>
#include <appl/GlyphPainting.hpp> #include <appl/GlyphPainting.hpp>
#include <ejson/ejson.hpp> #include <ejson/ejson.hpp>
#include <etk/os/FSNode.hpp>
#include <gale/resource/Manager.hpp> #include <gale/resource/Manager.hpp>
@ -15,9 +14,9 @@ appl::GlyphPainting::GlyphPainting() {
addResourceType("appl::GlyphPainting"); addResourceType("appl::GlyphPainting");
} }
void appl::GlyphPainting::init(const etk::String& _filename) { void appl::GlyphPainting::init(const etk::Uri& _uri) {
gale::Resource::init(_filename); gale::Resource::init(_uri);
APPL_DEBUG("SFP : load \"" << _filename << "\""); APPL_DEBUG("SFP : load \"" << _uri << "\"");
reload(); reload();
} }
@ -27,8 +26,8 @@ appl::GlyphPainting::~GlyphPainting() {
void appl::GlyphPainting::reload() { void appl::GlyphPainting::reload() {
ejson::Document doc; ejson::Document doc;
if (doc.load(m_name) == false) { if (doc.load(etk::Uri(m_name)) == false) {
APPL_ERROR("Can not load file : '" << m_name << "' = " << etk::FSNode(m_name).getFileSystemName()); APPL_ERROR("Can not load file : '" << m_name << "' = " << etk::Uri(m_name));
return; return;
} }
// for debug only : // for debug only :

View File

@ -16,9 +16,9 @@ namespace appl {
etk::Vector<appl::GlyphDecoration> m_list; etk::Vector<appl::GlyphDecoration> m_list;
protected: protected:
GlyphPainting(); GlyphPainting();
void init(const etk::String& _filename); void init(const etk::Uri& _uri);
public: public:
DECLARE_RESOURCE_NAMED_FACTORY(GlyphPainting); DECLARE_RESOURCE_URI_FACTORY(GlyphPainting);
virtual ~GlyphPainting(); virtual ~GlyphPainting();
public: public:
/** /**

View File

@ -331,14 +331,14 @@ void MainWindows::onCallbackMenuEvent(const etk::String& _value) {
APPL_TODO("Event from Menu : " << _value); APPL_TODO("Event from Menu : " << _value);
} else if ( _value == "menu:color:color/black/" } else if ( _value == "menu:color:color/black/"
|| _value == "menu:color:color/white/") { || _value == "menu:color:color/white/") {
etk::theme::setName("COLOR", etk::String(_value, 11)); EWOL_TODO("etk::theme::setName(\"COLOR\", etk::String(_value, 11));");
EWOL_ERROR("Select Shape or Color : 'COLOR'='" << etk::String(_value, 11) << "'"); EWOL_ERROR("Select Shape or Color : 'COLOR'='" << etk::String(_value, 11) << "'");
ewol::getContext().getResourcesManager().reLoadResources(); ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll(); ewol::getContext().forceRedrawAll();
} else if ( _value == "menu:shape:shape/square/" } else if ( _value == "menu:shape:shape/square/"
|| _value == "menu:shape:shape/round/") { || _value == "menu:shape:shape/round/") {
EWOL_ERROR("Select Shape or Color : 'GUI'='" << etk::String(_value, 11) << "'"); EWOL_ERROR("Select Shape or Color : 'GUI'='" << etk::String(_value, 11) << "'");
etk::theme::setName("GUI", etk::String(_value, 11)); EWOL_TODO("etk::theme::setName(\"GUI\", etk::String(_value, 11));");
ewol::getContext().getResourcesManager().reLoadResources(); ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll(); ewol::getContext().forceRedrawAll();
} else if (_value == "menu:reloadShape") { } else if (_value == "menu:reloadShape") {
@ -425,8 +425,7 @@ void MainWindows::displayOpen() {
// Get a ref on the buffer selected (if null, no buffer was selected ...) // Get a ref on the buffer selected (if null, no buffer was selected ...)
ememory::SharedPtr<appl::Buffer> tmpBuffer = m_bufferManager->getBufferSelected(); ememory::SharedPtr<appl::Buffer> tmpBuffer = m_bufferManager->getBufferSelected();
if (tmpBuffer != null) { if (tmpBuffer != null) {
etk::FSNode tmpFile = tmpBuffer->getFileName(); tmpWidget->propertyPath.set(tmpBuffer->getFileName().getParent());
tmpWidget->propertyPath.set(tmpFile.getNameFolder());
} }
// apply widget pop-up ... // apply widget pop-up ...
popUpWidgetPush(tmpWidget); popUpWidgetPush(tmpWidget);
@ -467,8 +466,8 @@ void MainWindows::displayProperty() {
#endif #endif
} }
void MainWindows::onCallbackselectNewFile(const etk::String& _value) { void MainWindows::onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _value) {
APPL_INFO("onCallbackselectNewFile(" << _value << ")"); APPL_INFO("onCallbackselectNewFile( ... )");
if (m_bufferManager == null) { if (m_bufferManager == null) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
return; return;
@ -477,15 +476,15 @@ void MainWindows::onCallbackselectNewFile(const etk::String& _value) {
m_connectionModify.disconnect(); m_connectionModify.disconnect();
m_connectionSaveName.disconnect(); m_connectionSaveName.disconnect();
onCallbackTitleUpdate(); onCallbackTitleUpdate();
ememory::SharedPtr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected(); if (_value != null) {
if (tmpp != null) { ememory::SharedPtr<appl::Buffer> tmp = _value;
m_connectionSave = tmpp->signalIsSave.connect(this, &MainWindows::onCallbackTitleUpdate); m_connectionSave = tmp->signalIsSave.connect(this, &MainWindows::onCallbackTitleUpdate);
m_connectionModify = tmpp->signalIsModify.connect(this, &MainWindows::onCallbackTitleUpdate); m_connectionModify = tmp->signalIsModify.connect(this, &MainWindows::onCallbackTitleUpdate);
m_connectionSaveName = tmpp->signalChangeName.connect(this, &MainWindows::onCallbackTitleUpdate); m_connectionSaveName = tmp->signalChangeName.connect(this, &MainWindows::onCallbackTitleUpdate);
} }
} }
void MainWindows::onCallbackPopUpFileSelected(const etk::String& _value) { void MainWindows::onCallbackPopUpFileSelected(const etk::Path& _value) {
APPL_INFO("onCallbackPopUpFileSelected(" << _value << ")"); APPL_INFO("onCallbackPopUpFileSelected(" << _value << ")");
APPL_DEBUG("Request opening the file : " << _value); APPL_DEBUG("Request opening the file : " << _value);
m_bufferManager->open(_value); m_bufferManager->open(_value);
@ -505,10 +504,9 @@ void MainWindows::onCallbackTitleUpdate() {
m_widgetLabelFileName->propertyValue.set(""); m_widgetLabelFileName->propertyValue.set("");
} }
} else { } else {
etk::String nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName(); propertyTitle.set(etk::String("Edn : ") + (tmpp->isModify()==true?" *":"") + tmpp->getFileName().getString());
propertyTitle.set(etk::String("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem);
if (m_widgetLabelFileName != null) { if (m_widgetLabelFileName != null) {
m_widgetLabelFileName->propertyValue.set(nameFileSystem + (tmpp->isModify()==true?" *":"")); m_widgetLabelFileName->propertyValue.set(tmpp->getFileName().getString() + (tmpp->isModify()==true?" *":""));
} }
} }
} }
@ -532,7 +530,7 @@ void MainWindows::closeNotSavedFile(const ememory::SharedPtr<appl::Buffer>& _buf
return; return;
} }
tmpPopUp->propertyTitle.set("<bold>_T{Close un-saved file:}</bold>"); tmpPopUp->propertyTitle.set("<bold>_T{Close un-saved file:}</bold>");
tmpPopUp->propertyComment.set("_T{The file named:} <i>\"" + _buffer->getFileName() + "\"</i> _T{is curently modify.} <br/>_T{If you don't saves these modifications,<br/>they will be definitly lost...}"); tmpPopUp->propertyComment.set("_T{The file named:} <i>\"" + _buffer->getFileName().getString() + "\"</i> _T{is curently modify.} <br/>_T{If you don't saves these modifications,<br/>they will be definitly lost...}");
ememory::SharedPtr<ewol::widget::Button> bt = null; ememory::SharedPtr<ewol::widget::Button> bt = null;
if (_buffer->hasFileName() == true) { if (_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("_T{Save}", true); bt = tmpPopUp->addButton("_T{Save}", true);

View File

@ -44,11 +44,11 @@ class MainWindows : public ewol::widget::Windows {
void displayOpen(); void displayOpen();
void displayProperty(); void displayProperty();
private: private:
void onCallbackPopUpFileSelected(const etk::String& _value); void onCallbackPopUpFileSelected(const etk::Path& _value);
void onCallbackTitleUpdate(); void onCallbackTitleUpdate();
void onCallbackMenuEvent(const etk::String& _value); void onCallbackMenuEvent(const etk::String& _value);
void onCallbackShortCut(const etk::String& _value); void onCallbackShortCut(const etk::String& _value);
void onCallbackselectNewFile(const etk::String& _value); void onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _value);
}; };

View File

@ -14,7 +14,7 @@ appl::TagFileList::TagFileList() :
m_selectedLine = -1; m_selectedLine = -1;
setMouseLimit(1); setMouseLimit(1);
// Load color properties: (use file list to be generic ...) // Load color properties: (use file list to be generic ...)
m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:ListFileSystem.json"); m_colorProperty = ewol::resource::ColorFile::create("THEME_COLOR://ListFileSystem.json");
if (m_colorProperty != null) { if (m_colorProperty != null) {
m_colorIdText = m_colorProperty->request("text"); m_colorIdText = m_colorProperty->request("text");
m_colorIdBackground1 = m_colorProperty->request("background1"); m_colorIdBackground1 = m_colorProperty->request("background1");
@ -50,7 +50,7 @@ fluorine::Variant appl::TagFileList::getData(int32_t _role, const ivec2& _pos) {
if (0 == _pos.x()) { if (0 == _pos.x()) {
return etk::toString(m_list[_pos.y()]->fileLine); return etk::toString(m_list[_pos.y()]->fileLine);
} }
return m_list[_pos.y()]->filename; return m_list[_pos.y()]->filename.getString();
} }
return "ERROR"; return "ERROR";
case ewol::widget::ListRole::FgColor: case ewol::widget::ListRole::FgColor:
@ -82,9 +82,9 @@ bool appl::TagFileList::onItemEvent(const ewol::event::Input& _event, const ivec
&& m_selectedLine < (int64_t)m_list.size() && m_selectedLine < (int64_t)m_list.size()
&& null != m_list[m_selectedLine] ) { && null != m_list[m_selectedLine] ) {
if (previousRaw != m_selectedLine) { if (previousRaw != m_selectedLine) {
signalSelect.emit(etk::toString(m_list[_pos.y()]->fileLine)+":"+m_list[m_selectedLine]->filename); signalSelect.emit(m_list[m_selectedLine]->filename, m_list[_pos.y()]->fileLine);
} else { } else {
signalValidate.emit(etk::toString(m_list[_pos.y()]->fileLine)+":"+m_list[m_selectedLine]->filename); signalValidate.emit(m_list[m_selectedLine]->filename, m_list[_pos.y()]->fileLine);
} }
} else { } else {
signalUnSelect.emit(); signalUnSelect.emit();
@ -103,7 +103,7 @@ bool appl::TagFileList::onItemEvent(const ewol::event::Input& _event, const ivec
* @param[in] file Compleate file name * @param[in] file Compleate file name
* @param[in] jump line id * @param[in] jump line id
*/ */
void appl::TagFileList::add(etk::String& _file, int32_t _line) { void appl::TagFileList::add(etk::Path& _file, int32_t _line) {
appl::TagListElement *tmpFile = ETK_NEW(appl::TagListElement, _file, _line); appl::TagListElement *tmpFile = ETK_NEW(appl::TagListElement, _file, _line);
if (null != tmpFile) { if (null != tmpFile) {
m_list.pushBack(tmpFile); m_list.pushBack(tmpFile);
@ -112,3 +112,7 @@ void appl::TagFileList::add(etk::String& _file, int32_t _line) {
} }
#include <esignal/details/Signal.hxx>
// declare for signal event
ESIGNAL_DECLARE_SIGNAL(etk::Path, int32_t);

View File

@ -11,9 +11,9 @@
namespace appl { namespace appl {
class TagListElement { class TagListElement {
public: public:
etk::String filename; etk::Path filename;
int32_t fileLine; int32_t fileLine;
TagListElement(etk::String& _file, int32_t _line) : TagListElement(etk::Path& _file, int32_t _line) :
filename(_file), filename(_file),
fileLine(_line) { fileLine(_line) {
@ -24,8 +24,8 @@ namespace appl {
}; };
class TagFileList : public ewol::widget::List { class TagFileList : public ewol::widget::List {
public: public:
esignal::Signal<etk::String> signalSelect; esignal::Signal<etk::Path, int32_t> signalSelect;
esignal::Signal<etk::String> signalValidate; esignal::Signal<etk::Path, int32_t> signalValidate;
esignal::Signal<> signalUnSelect; esignal::Signal<> signalUnSelect;
private: private:
int32_t m_selectedLine; int32_t m_selectedLine;
@ -53,7 +53,7 @@ namespace appl {
* @param[in] file Compleate file name * @param[in] file Compleate file name
* @param[in] jump line id * @param[in] jump line id
*/ */
void add(etk::String& _file, int32_t _line); void add(etk::Path& _file, int32_t _line);
}; };
} }

View File

@ -91,8 +91,8 @@ appl::TagFileSelection::~TagFileSelection() {
} }
void appl::TagFileSelection::onCallbackCtagsSelection() { void appl::TagFileSelection::onCallbackCtagsSelection() {
if (m_eventNamed != "") { if (m_eventLine != -1) {
signalSelect.emit(m_eventNamed); signalSelect.emit(m_eventPath, m_eventLine);
// == > Auto remove ... // == > Auto remove ...
autoDestroy(); autoDestroy();
} }
@ -104,18 +104,20 @@ void appl::TagFileSelection::onCallbackCtagsCancel() {
autoDestroy(); autoDestroy();
} }
void appl::TagFileSelection::onCallbackCtagsListValidate(const etk::String& _value) { void appl::TagFileSelection::onCallbackCtagsListValidate(const etk::Path& _path, const int32_t& _line) {
signalSelect.emit(_value); signalSelect.emit(_path, _line);
// == > Auto remove ... // == > Auto remove ...
autoDestroy(); autoDestroy();
} }
void appl::TagFileSelection::onCallbackCtagsListSelect(const etk::String& _value) { void appl::TagFileSelection::onCallbackCtagsListSelect(const etk::Path& _path, const int32_t& _line) {
m_eventNamed = _value; m_eventPath = _path;
m_eventLine = _line;
} }
void appl::TagFileSelection::onCallbackCtagsListUnSelect() { void appl::TagFileSelection::onCallbackCtagsListUnSelect() {
m_eventNamed = ""; m_eventPath = "";
m_eventLine = -1;
} }
@ -125,7 +127,7 @@ void appl::TagFileSelection::onCallbackCtagsListUnSelect() {
* @param[in] file Compleate file name * @param[in] file Compleate file name
* @param[in] jump line id * @param[in] jump line id
*/ */
void appl::TagFileSelection::addCtagsNewItem(etk::String _file, int32_t _line) { void appl::TagFileSelection::addCtagsNewItem(etk::Path _file, int32_t _line) {
if (m_listTag != null) { if (m_listTag != null) {
m_listTag->add(_file, _line); m_listTag->add(_file, _line);
} }

View File

@ -11,11 +11,12 @@
namespace appl { namespace appl {
class TagFileSelection : public ewol::widget::PopUp { class TagFileSelection : public ewol::widget::PopUp {
public: public:
esignal::Signal<etk::String> signalSelect; esignal::Signal<etk::Path, int32_t> signalSelect;
esignal::Signal<> signalCancel; esignal::Signal<> signalCancel;
private: private:
ememory::SharedPtr<appl::TagFileList> m_listTag; ememory::SharedPtr<appl::TagFileList> m_listTag;
etk::String m_eventNamed; etk::Path m_eventPath;
int32_t m_eventLine = -1;
public: public:
TagFileSelection(); TagFileSelection();
void init(); void init();
@ -24,15 +25,15 @@ namespace appl {
virtual ~TagFileSelection(); virtual ~TagFileSelection();
/** /**
* @brief add a Ctags item on the curent list * @brief add a Ctags item on the curent list
* @param[in] file Compleate file name * @param[in] _path Compleate file name
* @param[in] jump line id * @param[in] _line Jump line id
*/ */
void addCtagsNewItem(etk::String file, int32_t line); void addCtagsNewItem(etk::Path _path, int32_t _line);
public: // callback function public: // callback function
void onCallbackCtagsSelection(); void onCallbackCtagsSelection();
void onCallbackCtagsCancel(); void onCallbackCtagsCancel();
void onCallbackCtagsListValidate(const etk::String& _value); void onCallbackCtagsListValidate(const etk::Path& _path, const int32_t& _line);
void onCallbackCtagsListSelect(const etk::String& _value); void onCallbackCtagsListSelect(const etk::Path& _path, const int32_t& _line);
void onCallbackCtagsListUnSelect(); void onCallbackCtagsListUnSelect();
}; };
} }

View File

@ -83,8 +83,12 @@ void appl::TextViewer::onCallbackShortCut(const etk::String& _value) {
} }
void appl::TextViewer::onCallbackselectNewFile(const etk::String& _value) { void appl::TextViewer::onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _value) {
APPL_INFO("Select new file: " << _value); if (_value == null) {
APPL_INFO("Select new file: ___NO-FILE___");
} else {
APPL_INFO("Select new file: " << _value->getFileName());
}
if (isSelectedLast() == false) { if (isSelectedLast() == false) {
return; return;
} }
@ -115,7 +119,7 @@ void appl::TextViewer::onCallbackselectNewFile(const etk::String& _value) {
} }
m_originScrooled = vec2(0,0); m_originScrooled = vec2(0,0);
if (m_bufferManager != null) { if (m_bufferManager != null) {
m_buffer = m_bufferManager->get(_value); m_buffer = _value;
m_bufferManager->setBufferSelected(m_buffer); m_bufferManager->setBufferSelected(m_buffer);
if (m_buffer != null) { if (m_buffer != null) {
m_buffer->signalIsModify.connect(sharedFromThis(), &appl::TextViewer::onCallbackIsModify); m_buffer->signalIsModify.connect(sharedFromThis(), &appl::TextViewer::onCallbackIsModify);
@ -138,12 +142,7 @@ etk::String appl::TextViewer::getBufferPath() {
if (m_buffer == null) { if (m_buffer == null) {
return ""; return "";
} }
etk::String filename = m_buffer->getFileName(); return m_buffer->getFileName().getParent().getString();
size_t pos = filename.rfind('/');
if (pos == etk::String::npos) {
return "";
}
return etk::String(filename, 0, pos);
} }

View File

@ -415,7 +415,7 @@ namespace appl {
void onCallbackIsModify(); void onCallbackIsModify();
void onCallbackShortCut(const etk::String& _value); void onCallbackShortCut(const etk::String& _value);
void onCallbackSelectChange(); void onCallbackSelectChange();
void onCallbackselectNewFile(const etk::String& _value); void onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _value);
}; };
} }

View File

@ -17,7 +17,7 @@ namespace appl {
DECLARE_FACTORY(WorkerCloseAllFile); DECLARE_FACTORY(WorkerCloseAllFile);
virtual ~WorkerCloseAllFile(); virtual ~WorkerCloseAllFile();
private: private:
etk::Vector<etk::String> m_bufferNameList; etk::Vector<etk::Path> m_bufferNameList;
ememory::SharedPtr<appl::WorkerCloseFile> m_worker; //! pop-up element that is open... ememory::SharedPtr<appl::WorkerCloseFile> m_worker; //! pop-up element that is open...
ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // callback function public: // callback function

View File

@ -24,14 +24,14 @@ void appl::WorkerCloseFile::init() {
ewol::object::Worker::init(); ewol::object::Worker::init();
} }
void appl::WorkerCloseFile::startAction(const etk::String& _bufferName) { void appl::WorkerCloseFile::startAction(const etk::Path& _bufferName) {
m_bufferName = _bufferName; m_bufferName = _bufferName;
if (m_bufferManager == null) { if (m_bufferManager == null) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
destroy(); destroy();
return; return;
} }
if (m_bufferName == "") { if (m_bufferName.isEmpty() == true) {
// need to find the curent file ... // need to find the curent file ...
ememory::SharedPtr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected(); ememory::SharedPtr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp == null) { if (tmpp == null) {
@ -66,7 +66,7 @@ void appl::WorkerCloseFile::startAction(const etk::String& _bufferName) {
return; return;
} }
tmpPopUp->propertyTitle.set("<bold>_T{Close un-saved file:}</bold>"); tmpPopUp->propertyTitle.set("<bold>_T{Close un-saved file:}</bold>");
tmpPopUp->propertyComment.set("_T{The file named:} <i>'" + m_buffer->getFileName() + "'</i> _T{is curently modify.}<br/>_T{If you don't saves these modifications,}<br/>_T{they will be definitly lost...}"); tmpPopUp->propertyComment.set("_T{The file named:} <i>'" + m_buffer->getFileName().getString() + "'</i> _T{is curently modify.}<br/>_T{If you don't saves these modifications,}<br/>_T{they will be definitly lost...}");
ememory::SharedPtr<ewol::widget::Button> bt = null; ememory::SharedPtr<ewol::widget::Button> bt = null;
if (m_buffer->hasFileName() == true) { if (m_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("_T{Save}", true); bt = tmpPopUp->addButton("_T{Save}", true);
@ -132,7 +132,7 @@ void appl::WorkerCloseFile::onCallbackSaveValidate() {
return; return;
} }
if (m_buffer->storeFile() == false) { if (m_buffer->storeFile() == false) {
ewol::tools::message::displayWarning("We can not save the file : <br/><i>" + m_buffer->getFileName() + "</i>"); ewol::tools::message::displayWarning("We can not save the file : <br/><i>" + m_buffer->getFileName().getString() + "</i>");
signalAbort.emit(); signalAbort.emit();
} else { } else {
m_buffer->destroy(); m_buffer->destroy();

View File

@ -25,9 +25,9 @@ namespace appl {
/** /**
* @brief Action to do * @brief Action to do
*/ */
void startAction(const etk::String& _bufferName); void startAction(const etk::Path& _bufferName);
private: private:
etk::String m_bufferName; etk::Path m_bufferName;
ememory::SharedPtr<appl::Buffer> m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer ememory::SharedPtr<appl::Buffer> m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer
ememory::SharedPtr<appl::WorkerSaveFile> m_worker; //! sub-worker element... ememory::SharedPtr<appl::WorkerSaveFile> m_worker; //! sub-worker element...
ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager

View File

@ -17,7 +17,7 @@ namespace appl {
DECLARE_FACTORY(WorkerSaveAllFile); DECLARE_FACTORY(WorkerSaveAllFile);
virtual ~WorkerSaveAllFile(); virtual ~WorkerSaveAllFile();
private: private:
etk::Vector<etk::String> m_bufferNameList; etk::Vector<etk::Path> m_bufferNameList;
ememory::SharedPtr<appl::WorkerSaveFile> m_worker; //! pop-up element that is open... ememory::SharedPtr<appl::WorkerSaveFile> m_worker; //! pop-up element that is open...
ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // callback function public: // callback function

View File

@ -62,9 +62,8 @@ void appl::WorkerSaveFile::init() {
} }
m_chooser->propertyLabelTitle.set("_T{Save files As...}"); m_chooser->propertyLabelTitle.set("_T{Save files As...}");
m_chooser->propertyLabelValidate.set("_T{Save}"); m_chooser->propertyLabelValidate.set("_T{Save}");
etk::FSNode tmpName(*propertyBufferName); m_chooser->propertyPath.set(propertyBufferName->getParent());
m_chooser->propertyPath.set(tmpName.getNameFolder()); m_chooser->propertyFile.set(propertyBufferName->getFileName());
m_chooser->propertyFile.set(tmpName.getNameFile());
ememory::SharedPtr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows(); ememory::SharedPtr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == null) { if (tmpWindows == null) {
APPL_ERROR("Error to get the windows."); APPL_ERROR("Error to get the windows.");
@ -85,13 +84,13 @@ void appl::WorkerSaveFile::onCallbackCancel() {
destroy(); destroy();
} }
void appl::WorkerSaveFile::onCallbackSaveAsValidate(const etk::String& _value) { void appl::WorkerSaveFile::onCallbackSaveAsValidate(const etk::Path& _value) {
if (m_bufferManager == null) { if (m_bufferManager == null) {
// nothing to do in this case ==> can do nothing ... // nothing to do in this case ==> can do nothing ...
destroy(); destroy();
return; return;
} }
if (_value == "") { if (_value.isEmpty() == true) {
APPL_ERROR(" might be an error of the File chooser system..."); APPL_ERROR(" might be an error of the File chooser system...");
destroy(); destroy();
return; return;
@ -109,7 +108,7 @@ void appl::WorkerSaveFile::onCallbackSaveAsValidate(const etk::String& _value) {
} }
tmpBuffer->setFileName(_value); tmpBuffer->setFileName(_value);
if (tmpBuffer->storeFile() == false) { if (tmpBuffer->storeFile() == false) {
ewol::tools::message::displayWarning("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>"); ewol::tools::message::displayWarning("We can not save the file : <br/><i>" + tmpBuffer->getFileName().getString() + "</i>");
} else { } else {
signalSaveDone.emit(); signalSaveDone.emit();
} }

View File

@ -13,7 +13,7 @@ namespace appl {
public: public:
esignal::Signal<> signalSaveDone; esignal::Signal<> signalSaveDone;
esignal::Signal<> signalAbort; esignal::Signal<> signalAbort;
eproperty::Value<etk::String> propertyBufferName; eproperty::Value<etk::Path> propertyBufferName;
eproperty::Value<bool> propertyForceSave; eproperty::Value<bool> propertyForceSave;
protected: protected:
WorkerSaveFile(); WorkerSaveFile();
@ -25,7 +25,7 @@ namespace appl {
ememory::SharedPtr<ewol::widget::FileChooser> m_chooser; //! pop-up element that is open... ememory::SharedPtr<ewol::widget::FileChooser> m_chooser; //! pop-up element that is open...
ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // callback function public: // callback function
void onCallbackSaveAsValidate(const etk::String& _value); void onCallbackSaveAsValidate(const etk::Path& _value);
void onCallbackCancel(); void onCallbackCancel();
}; };
} }

View File

@ -23,15 +23,15 @@ appl::Highlight::Highlight() {
addResourceType("appl::Highlight"); addResourceType("appl::Highlight");
} }
void appl::Highlight::init(const etk::String& _xmlFilename, const etk::String& _colorFile) { void appl::Highlight::init(const etk::Uri& _uriXml, const etk::Uri& _uriColorFile) {
gale::Resource::init(_xmlFilename); gale::Resource::init(_uriXml);
// keep color propertiy file : // keep color propertiy file :
m_paintingProperties = appl::GlyphPainting::create(_colorFile); m_paintingProperties = appl::GlyphPainting::create(_uriColorFile);
exml::Document doc; exml::Document doc;
if (doc.load(_xmlFilename) == false) { if (doc.load(_uriXml) == false) {
APPL_ERROR(" can not load file XML : " << _xmlFilename); APPL_ERROR(" can not load file XML : " << _uriXml);
return; return;
} }
exml::Element root = doc.nodes["EdnLang"]; exml::Element root = doc.nodes["EdnLang"];
@ -123,8 +123,8 @@ appl::Highlight::~Highlight() {
m_listFiles.clear(); m_listFiles.clear();
} }
bool appl::Highlight::isCompatible(const etk::String& _name) { bool appl::Highlight::isCompatible(const etk::Path& _name) {
etk::String extention = _name.extract(_name.rfind('.')+1); etk::String extention = _name.getExtention();
for (auto &it : m_listExtentions) { for (auto &it : m_listExtentions) {
APPL_WARNING(" check : " << it << "=?=" << extention); APPL_WARNING(" check : " << it << "=?=" << extention);
etk::RegEx<etk::String> regex; etk::RegEx<etk::String> regex;
@ -153,16 +153,14 @@ bool appl::Highlight::isCompatible(const etk::String& _name) {
return false; return false;
} }
bool appl::Highlight::fileNameCompatible(const etk::String& _fileName) { bool appl::Highlight::fileNameCompatible(const etk::Path& _fileName) {
etk::String extention; etk::String extention = _fileName.getExtention();
etk::FSNode file(_fileName); if (extention.isEmpty() == false ) {
if (true == file.fileHasExtention() ) { extention = "*." + extention;
extention = "*.";
extention += file.fileGetExtention();
} else { } else {
extention = file.getNameFile(); extention = _fileName.getFileName();
} }
APPL_DEBUG(" try to find : in \"" << file << "\" extention:\"" << extention << "\" "); APPL_DEBUG(" try to find : in \"" << _fileName << "\" extention:\"" << extention << "\" ");
for (auto &it : m_listExtentions) { for (auto &it : m_listExtentions) {
if (extention == it ) { if (extention == it ) {

View File

@ -19,7 +19,6 @@ namespace appl {
} }
#include <ememory/memory.hpp> #include <ememory/memory.hpp>
#include <etk/os/FSNode.hpp>
#include <appl/HighlightPattern.hpp> #include <appl/HighlightPattern.hpp>
#include <appl/GlyphPainting.hpp> #include <appl/GlyphPainting.hpp>
#include <etk/Buffer.hpp> #include <etk/Buffer.hpp>
@ -32,9 +31,9 @@ namespace appl {
public: public:
// Constructeur // Constructeur
Highlight(); Highlight();
void init(const etk::String& _xmlFilename, const etk::String& _colorFile = "THEME:COLOR:textViewer.json"); void init(const etk::Uri& _uriXML, const etk::Uri& _uriColorFile = "THEME_COLOR://textViewer.json");
public: public:
DECLARE_RESOURCE_NAMED_FACTORY(Highlight); DECLARE_RESOURCE_URI_FACTORY(Highlight);
virtual ~Highlight(); virtual ~Highlight();
private: private:
etk::String m_typeName; //!< descriptive string type like "C/C++" etk::String m_typeName; //!< descriptive string type like "C/C++"
@ -47,8 +46,8 @@ namespace appl {
return m_typeName; return m_typeName;
} }
public: public:
bool isCompatible(const etk::String& _name); bool isCompatible(const etk::Path& _name);
bool fileNameCompatible(const etk::String& _fileName); bool fileNameCompatible(const etk::Path& _fileName);
void display(); void display();
void parse(int64_t _start, void parse(int64_t _start,
int64_t _stop, int64_t _stop,

View File

@ -8,6 +8,7 @@
#include <appl/HighlightManager.hpp> #include <appl/HighlightManager.hpp>
#include <ewol/object/Object.hpp> #include <ewol/object/Object.hpp>
#include <ewol/object/Manager.hpp> #include <ewol/object/Manager.hpp>
#include <etk/path/fileSystem.hpp>
// TODO : Review this in a generic unique resource ... // TODO : Review this in a generic unique resource ...
@ -25,28 +26,25 @@ void appl::highlightManager::init() {
hlList.clear(); hlList.clear();
} }
APPL_DEBUG("HighlightManager == > INIT"); APPL_DEBUG("HighlightManager == > INIT");
etk::FSNode myFile("DATA:languages/"); // TODO: Add search in the etk::Uri uri("DATA_USER://languages/");
// get the subfolder list : etk::Uri uri("DATA://languages/");
etk::Vector<etk::FSNode *> list = myFile.folderGetSubList(false, true, false,false); // get the subfolder list:
for (auto &it : list) { etk::Vector<etk::Uri> list = etk::uri::listRecursive(uri); // TODO: filter only the folder
if (it == null) { for (auto &it: list) {
// TODO: etk::uri::isDirectory(it) ==> not implemented ...
if (etk::path::isDirectory(it.getPath()) == false) {
continue; continue;
} }
if (it->getNodeType() != etk::typeNode_folder) { ememory::SharedPtr<appl::Highlight> myHightLight = appl::Highlight::create(it.getPath() / "highlight.xml");
continue; if (myHightLight != null) {
}
etk::String filename = it->getName() + "/highlight.xml";
APPL_DEBUG("Load xml name : " << filename);
ememory::SharedPtr<appl::Highlight> myHightLine = appl::Highlight::create(filename);
if (myHightLine != null) {
// Check if the language name already exist // Check if the language name already exist
for (auto &it2 : hlList) { for (auto &it2 : hlList) {
if ( it2 != null if ( it2 != null
&& it2->getTypeName() == myHightLine->getTypeName() ) { && it2->getTypeName() == myHightLight->getTypeName() ) {
APPL_WARNING("LANGUAGE : replace pattern name: '" << myHightLine->getTypeName() << "' with file '" << filename << "' replace: " << it2->getName()); APPL_WARNING("LANGUAGE : replace pattern name: '" << myHightLight->getTypeName() << "' with file '" << it.getPath() / "highlight.xml" << "' replace: " << it2->getName());
} }
} }
hlList.pushBack(myHightLine); hlList.pushBack(myHightLight);
} else { } else {
APPL_ERROR("Can not allocate HighLight"); APPL_ERROR("Can not allocate HighLight");
} }
@ -70,8 +68,8 @@ void appl::highlightManager::unInit() {
hlList.clear(); hlList.clear();
} }
etk::String appl::highlightManager::getTypeFile(const etk::String& _fileName) { etk::String appl::highlightManager::getTypeFile(const etk::Path& _fileName) {
if (_fileName.size() == 0) { if (_fileName.isEmpty() == true) {
return ""; return "";
} }
APPL_WARNING("Try to find type for extention : '" << _fileName << "' in " << s_list().size() << " types"); APPL_WARNING("Try to find type for extention : '" << _fileName << "' in " << s_list().size() << " types");
@ -106,6 +104,12 @@ etk::String appl::highlightManager::getFileWithTypeType(const etk::String& _type
etk::Vector<etk::String> appl::highlightManager::getTypeList() { etk::Vector<etk::String> appl::highlightManager::getTypeList() {
etk::Vector<etk::String> ret; etk::Vector<etk::String> ret;
for (auto &it : s_list()) {
if (it == null) {
continue;
}
ret.pushBack(it->getTypeName());
}
return ret; return ret;
} }

View File

@ -25,7 +25,7 @@ namespace appl {
* @param[in] _fileName name of the file * @param[in] _fileName name of the file
* @return type of highlight * @return type of highlight
*/ */
etk::String getTypeFile(const etk::String& _fileName); etk::String getTypeFile(const etk::Path& _fileName);
/** /**
* @brief Get filename with type. * @brief Get filename with type.
* @param[in] _type Type name of the highlight. * @param[in] _type Type name of the highlight.

View File

@ -10,10 +10,10 @@
#include <ewol/context/Context.hpp> #include <ewol/context/Context.hpp>
#include <appl/Gui/TagFileSelection.hpp> #include <appl/Gui/TagFileSelection.hpp>
static etk::String g_staticCtagsFileName; static etk::Uri g_staticCtagsFileName;
void appl::setCtagsFileName(const etk::String& _file) { void appl::setCtagsFileName(const etk::Uri& _uri) {
g_staticCtagsFileName = _file; g_staticCtagsFileName = _uri;
} }
appl::TextPluginCtags::TextPluginCtags() : appl::TextPluginCtags::TextPluginCtags() :
@ -24,8 +24,9 @@ appl::TextPluginCtags::TextPluginCtags() :
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::create(); m_bufferManager = appl::BufferManager::create();
addObjectType("appl::TextPluginCtags"); addObjectType("appl::TextPluginCtags");
if (g_staticCtagsFileName != "") { if (g_staticCtagsFileName.isEmpty() == false) {
m_tagFilename = g_staticCtagsFileName; m_tagFolderBase = g_staticCtagsFileName.getPath().getParent();
m_tagFilename = g_staticCtagsFileName.getPath().getFileName();
loadTagFile(); loadTagFile();
} }
} }
@ -61,8 +62,7 @@ void appl::TextPluginCtags::jumpTo(const etk::String& _name) {
int32_t numberOfTags = 0; int32_t numberOfTags = 0;
// For all tags : Save in an internal Structure : // For all tags : Save in an internal Structure :
etk::String tmpFile(m_tagFolderBase + "/" + entry.file); etk::Path tmpFile = m_tagFolderBase / entry.file;
etk::FSNode myfile(tmpFile);
int32_t lineID = entry.address.lineNumber; int32_t lineID = entry.address.lineNumber;
printTag(&entry); printTag(&entry);
@ -72,31 +72,26 @@ void appl::TextPluginCtags::jumpTo(const etk::String& _name) {
if (tmpWidget == null) { if (tmpWidget == null) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID); tmpWidget->addCtagsNewItem(tmpFile, lineID);
do { do {
tmpFile = m_tagFolderBase + "/" + entry.file; tmpFile = m_tagFolderBase / entry.file;
myfile = tmpFile;
lineID = entry.address.lineNumber; lineID = entry.address.lineNumber;
printTag(&entry); printTag(&entry);
tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID); tmpWidget->addCtagsNewItem(tmpFile, lineID);
} while (tagsFindNext (m_ctagFile, &entry) == TagSuccess); } while (tagsFindNext (m_ctagFile, &entry) == TagSuccess);
ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
tmpWidget->signalSelect.connect(sharedFromThis(), &appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn); tmpWidget->signalSelect.connect(sharedFromThis(), &appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn);
} }
} else { } else {
jumpFile(myfile.getName(), lineID - 1); jumpFile(tmpFile, lineID - 1);
} }
} }
void appl::TextPluginCtags::jumpFile(const etk::String& _filename, int64_t _lineId) { void appl::TextPluginCtags::jumpFile(const etk::Path& _filename, int64_t _lineId) {
// save the current file in the history // save the current file in the history
// TODO : registerHistory(); // TODO : registerHistory();
if (m_bufferManager != null) { if (m_bufferManager != null) {
etk::String plop = _filename; m_bufferManager->open(_filename);
while (plop[0] == '/') {
plop.erase(0);
}
m_bufferManager->open(plop);
} }
//sendMultiCast(appl::MsgSelectGotoLineSelect, etk::toString(_lineId)); //sendMultiCast(appl::MsgSelectGotoLineSelect, etk::toString(_lineId));
APPL_TODO("request jup at line ..."); APPL_TODO("request jup at line ...");
@ -113,8 +108,8 @@ void appl::TextPluginCtags::loadTagFile() {
return; return;
} }
// load (open) the tag file : // load (open) the tag file :
APPL_INFO("try to open tag file : " << m_tagFilename); APPL_INFO("try to open tag file : " << g_staticCtagsFileName);
m_ctagFile = tagsOpen(m_tagFilename.c_str(), &info); m_ctagFile = tagsOpen(g_staticCtagsFileName.getPath().getString().c_str(), &info);
if (null != m_ctagFile) { if (null != m_ctagFile) {
APPL_INFO("open exuberant Ctags file is OK ..."); APPL_INFO("open exuberant Ctags file is OK ...");
} else { } else {
@ -144,22 +139,17 @@ void appl::TextPluginCtags::printTag(const tagEntry *_entry) {
#endif #endif
} }
void appl::TextPluginCtags::onCallbackOpenCtagsOpenFileReturn(const etk::String& _value) { void appl::TextPluginCtags::onCallbackOpenCtagsOpenFileReturn(const etk::Path& _path) {
// open the new one : // open the new one :
etk::FSNode tmpFilename = _value; m_tagFilename = _path.getFileName();
m_tagFilename = tmpFilename.getNameFile(); m_tagFolderBase = _path.getParent();
m_tagFolderBase = tmpFilename.getNameFolder();
APPL_INFO("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " "); APPL_INFO("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " ");
loadTagFile(); loadTagFile();
} }
void appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn(const etk::String& _value) { void appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn(const etk::Path& _path, const int32_t& _line) {
// parse the input data
char tmp[4096]; jumpFile(_path, _line - 1);
int32_t lineID;
// TODO : Review this ...
sscanf(_value.c_str(), "%d:%s", &lineID, tmp);
jumpFile(tmp, lineID - 1);
} }
bool appl::TextPluginCtags::onReceiveShortCut(appl::TextViewer& _textDrawer, bool appl::TextPluginCtags::onReceiveShortCut(appl::TextViewer& _textDrawer,

View File

@ -16,20 +16,20 @@
// ctags --recurse -f tags --fields=n -h ".h.hpp" --tag-relative=yes framework/atria-soft/ // ctags --recurse -f tags --fields=n -h ".h.hpp" --tag-relative=yes framework/atria-soft/
namespace appl { namespace appl {
void setCtagsFileName(const etk::String& _file); void setCtagsFileName(const etk::Uri& _uri);
class TextPluginCtags : public appl::TextViewerPlugin { class TextPluginCtags : public appl::TextViewerPlugin {
private: private:
// Global plugin data (not specific on buffer : // Global plugin data (not specific on buffer :
/* /*
etk::Vector<etk::Pair<etk::String, int64_t>> m_historyList; etk::Vector<etk::Pair<etk::String, int64_t>> m_historyList;
*/ */
etk::String m_tagFolderBase; etk::Path m_tagFolderBase;
etk::String m_tagFilename; etk::String m_tagFilename;
tagFile* m_ctagFile; tagFile* m_ctagFile;
void loadTagFile(); void loadTagFile();
void printTag(const tagEntry *_entry); void printTag(const tagEntry *_entry);
void jumpTo(const etk::String& _name); void jumpTo(const etk::String& _name);
void jumpFile(const etk::String& _filename, int64_t _lineId); void jumpFile(const etk::Path& _filename, int64_t _lineId);
ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
protected: protected:
TextPluginCtags(); TextPluginCtags();
@ -42,8 +42,8 @@ namespace appl {
virtual bool onReceiveShortCut(appl::TextViewer& _textDrawer, virtual bool onReceiveShortCut(appl::TextViewer& _textDrawer,
const etk::String& _shortCutName); const etk::String& _shortCutName);
// callback function: // callback function:
void onCallbackOpenCtagsOpenFileReturn(const etk::String& _value); void onCallbackOpenCtagsOpenFileReturn(const etk::Path& _path);
void onCallbackOpenCtagsSelectReturn(const etk::String& _value); void onCallbackOpenCtagsSelectReturn(const etk::Path& _path, const int32_t& _line);
}; };
} }

View File

@ -8,10 +8,10 @@
#include <ewol/object/Object.hpp> #include <ewol/object/Object.hpp>
#include <ewol/context/Context.hpp> #include <ewol/context/Context.hpp>
#include <gale/resource/Manager.hpp> #include <gale/resource/Manager.hpp>
#include <etk/os/FSNode.hpp> #include <etk/theme/theme.hpp>
#include <ejson/ejson.hpp> #include <ejson/ejson.hpp>
static etk::String g_baseDBName = "USERDATA:genericConfig.json"; static etk::Uri g_baseDBName = "USER_DATA://genericConfig.json";
class myParamGlobal : public ewol::Object { class myParamGlobal : public ewol::Object {

View File

@ -10,8 +10,9 @@
#include <appl/debug.hpp> #include <appl/debug.hpp>
#include <appl/global.hpp> #include <appl/global.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/tool.hpp> #include <etk/tool.hpp>
#include <etk/path/fileSystem.hpp>
#include <etk/theme/theme.hpp>
#include <unistd.h> #include <unistd.h>
//#include <ewol/config.hpp> //#include <ewol/config.hpp>
#include <gale/context/commandLine.hpp> #include <gale/context/commandLine.hpp>
@ -101,7 +102,6 @@ class MainApplication : public ewol::context::Application {
for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) { for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) {
etk::String tmpppp = _context.getCmd().get(iii); etk::String tmpppp = _context.getCmd().get(iii);
if (tmpppp.startWith("--ctags=") == true) { if (tmpppp.startWith("--ctags=") == true) {
etk::FSNode file(tmpppp);
etk::String name = tmpppp.extract(8); etk::String name = tmpppp.extract(8);
APPL_INFO("Load ctag file : \"" << name << "\"" ); APPL_INFO("Load ctag file : \"" << name << "\"" );
appl::setCtagsFileName(name); appl::setCtagsFileName(name);
@ -109,19 +109,16 @@ class MainApplication : public ewol::context::Application {
|| tmpppp == "--help") { || tmpppp == "--help") {
// nothing to do ... // nothing to do ...
} else { } else {
etk::FSNode file(tmpppp); etk::Path file(tmpppp);
if (file.getNodeType() == etk::typeNode_file) { if (etk::path::isFile(file) == true) {
etk::String name = file.getName(); APPL_INFO("need load file : \"" << file << "\"" );
APPL_INFO("need load file : \"" << name << "\"" ); m_bufferManager->open(file);
m_bufferManager->open(name); } else if (etk::path::isDirectory(file) == true) {
} else if (file.getNodeType() == etk::typeNode_folder) { etk::Vector<etk::Path> listOfFiles = etk::path::list(file, etk::path::LIST_FILE);
etk::Vector<etk::String> listOfFiles = file.folderGetSub(false, true, ".*");
for (auto &it: listOfFiles) { for (auto &it: listOfFiles) {
etk::FSNode file2(it); if (etk::path::isFile(it) == true) {
if (file2.getNodeType() == etk::typeNode_file) { APPL_INFO("need load file : \"" << it << "\"" );
etk::String name = file2.getName(); m_bufferManager->open(it);
APPL_INFO("need load file : \"" << name << "\"" );
m_bufferManager->open(name);
} }
} }
} }
@ -166,7 +163,6 @@ int main(int _argc, const char *_argv[]) {
for( int32_t iii=0 ; iii<_argc; iii++) { for( int32_t iii=0 ; iii<_argc; iii++) {
etk::String tmpppp = _argv[iii]; etk::String tmpppp = _argv[iii];
if (tmpppp.startWith("--ctags=") == true) { if (tmpppp.startWith("--ctags=") == true) {
etk::FSNode file(tmpppp);
etk::String name = tmpppp.extract(8); etk::String name = tmpppp.extract(8);
APPL_INFO("Load ctag file : \"" << name << "\"" ); APPL_INFO("Load ctag file : \"" << name << "\"" );
appl::setCtagsFileName(name); appl::setCtagsFileName(name);

View File

@ -19,7 +19,7 @@ static void SortElementList(etk::Vector<appl::dataBufferStruct>& _list) {
size_t findPos = 0; size_t findPos = 0;
for(size_t jjj=0; jjj<_list.size(); jjj++) { for(size_t jjj=0; jjj<_list.size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\""); //EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (tmpList[iii].m_bufferName.getNameFile() > _list[jjj].m_bufferName.getNameFile()) { if (tmpList[iii].m_bufferName.getFileName() > _list[jjj].m_bufferName.getFileName()) {
findPos = jjj+1; findPos = jjj+1;
} }
} }
@ -78,7 +78,7 @@ void appl::widget::BufferList::removeAllElement() {
void appl::widget::BufferList::insertAlphabetic(const appl::dataBufferStruct& _dataStruct, bool _selectNewPosition) { void appl::widget::BufferList::insertAlphabetic(const appl::dataBufferStruct& _dataStruct, bool _selectNewPosition) {
// alphabetical order: // alphabetical order:
for (size_t iii = 0; iii < m_list.size(); ++iii) { for (size_t iii = 0; iii < m_list.size(); ++iii) {
if (m_list[iii].m_bufferName.getNameFile().toLower() > _dataStruct.m_bufferName.getNameFile().toLower()) { if (m_list[iii].m_bufferName.getFileName().toLower() > _dataStruct.m_bufferName.getFileName().toLower()) {
m_list.insert(m_list.begin() + iii, _dataStruct); m_list.insert(m_list.begin() + iii, _dataStruct);
if (_selectNewPosition == true) { if (_selectNewPosition == true) {
m_selectedID = iii; m_selectedID = iii;
@ -92,16 +92,15 @@ void appl::widget::BufferList::insertAlphabetic(const appl::dataBufferStruct& _d
} }
} }
void appl::widget::BufferList::onCallbackNewBuffer(const etk::String& _value) { void appl::widget::BufferList::onCallbackNewBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) {
ememory::SharedPtr<appl::Buffer> buffer = m_bufferManager->get(_value); if (_buffer == null) {
if (buffer == null) {
APPL_ERROR("event on element nor exist : " << _value);
return; return;
} }
ememory::SharedPtr<appl::Buffer> buffer = _buffer;
buffer->signalIsSave.connect(sharedFromThis(), &BufferList::onCallbackIsSave); buffer->signalIsSave.connect(sharedFromThis(), &BufferList::onCallbackIsSave);
buffer->signalIsModify.connect(sharedFromThis(), &BufferList::onCallbackIsModify); buffer->signalIsModify.connect(sharedFromThis(), &BufferList::onCallbackIsModify);
buffer->signalChangeName.connect(sharedFromThis(), &BufferList::onCallbackChangeName); buffer->signalChangeName.connect(sharedFromThis(), &BufferList::onCallbackChangeName);
appl::dataBufferStruct tmp(_value, buffer); appl::dataBufferStruct tmp(_buffer->getFileName(), _buffer);
if (m_openOrderMode == true) { if (m_openOrderMode == true) {
m_list.pushBack(tmp); m_list.pushBack(tmp);
} else { } else {
@ -118,13 +117,13 @@ void appl::widget::BufferList::onCallbackNewBuffer(const etk::String& _value) {
} }
// TODO : Review this callback with the real shared_ptr on the buffer ... // TODO : Review this callback with the real shared_ptr on the buffer ...
void appl::widget::BufferList::onCallbackselectNewFile(const etk::String& _value) { void appl::widget::BufferList::onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _buffer) {
m_selectedID = -1; m_selectedID = -1;
for (size_t iii=0; iii<m_list.size(); iii++) { for (size_t iii=0; iii<m_list.size(); iii++) {
if (m_list[iii].m_buffer == null) { if (m_list[iii].m_buffer == null) {
continue; continue;
} }
if (m_list[iii].m_buffer->getFileName() != _value) { if (m_list[iii].m_buffer != _buffer) {
continue; continue;
} }
m_selectedID = iii; m_selectedID = iii;
@ -185,7 +184,7 @@ ivec2 appl::widget::BufferList::getMatrixSize() const {
fluorine::Variant appl::widget::BufferList::getData(int32_t _role, const ivec2& _pos) { fluorine::Variant appl::widget::BufferList::getData(int32_t _role, const ivec2& _pos) {
switch (_role) { switch (_role) {
case ewol::widget::ListRole::Text: case ewol::widget::ListRole::Text:
return m_list[_pos.y()].m_bufferName.getNameFile();; return m_list[_pos.y()].m_bufferName.getFileName();;
case ewol::widget::ListRole::FgColor: case ewol::widget::ListRole::FgColor:
if ( m_list[_pos.y()].m_buffer != null if ( m_list[_pos.y()].m_buffer != null
&& m_list[_pos.y()].m_buffer->isModify() == false) { && m_list[_pos.y()].m_buffer->isModify() == false) {

View File

@ -14,12 +14,12 @@
namespace appl { namespace appl {
class dataBufferStruct { class dataBufferStruct {
public: public:
etk::FSNode m_bufferName; etk::Path m_bufferName;
ememory::SharedPtr<appl::Buffer> m_buffer; ememory::SharedPtr<appl::Buffer> m_buffer;
dataBufferStruct() { dataBufferStruct() {
}; };
dataBufferStruct(const etk::String& _bufferName, const ememory::SharedPtr<appl::Buffer>& _buffer) : dataBufferStruct(const etk::Path& _bufferName, const ememory::SharedPtr<appl::Buffer>& _buffer) :
m_bufferName(_bufferName), m_bufferName(_bufferName),
m_buffer(_buffer) { m_buffer(_buffer) {
@ -74,8 +74,8 @@ namespace appl {
void onCallbackChangeName(); void onCallbackChangeName();
void onCallbackIsSave(); void onCallbackIsSave();
void onCallbackIsModify(); void onCallbackIsModify();
void onCallbackNewBuffer(const etk::String& _value); void onCallbackNewBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer);
void onCallbackselectNewFile(const etk::String& _value); void onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _buffer);
void onCallbackBufferRemoved(const ememory::SharedPtr<appl::Buffer>& _buffer); void onCallbackBufferRemoved(const ememory::SharedPtr<appl::Buffer>& _buffer);
void calculateMinMaxSize() override; void calculateMinMaxSize() override;
}; };

View File

@ -19,7 +19,7 @@ static void SortElementList(etk::Vector<appl::dataBufferStruct>& _list) {
size_t findPos = 0; size_t findPos = 0;
for(size_t jjj=0; jjj<_list.size(); jjj++) { for(size_t jjj=0; jjj<_list.size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\""); //EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (tmpList[iii].m_bufferName.getNameFile() > _list[jjj].m_bufferName.getNameFile()) { if (tmpList[iii].m_bufferName.getFileName() > _list[jjj].m_bufferName.getFileName()) {
findPos = jjj+1; findPos = jjj+1;
} }
} }
@ -53,17 +53,17 @@ void appl::widget::BufferTree::init() {
propertyCanFocus.set(true); propertyCanFocus.set(true);
propertyTextIsDecorated.set(false); propertyTextIsDecorated.set(false);
if (m_bufferManager != null) { if (m_bufferManager != null) {
m_bufferManager->signalNewBuffer2.connect(sharedFromThis(), &appl::widget::BufferTree::onNewBuffer); m_bufferManager->signalNewBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onNewBuffer);
m_bufferManager->signalSelectBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onSelectBuffer); m_bufferManager->signalSelectFile.connect(sharedFromThis(), &appl::widget::BufferTree::onSelectBuffer);
m_bufferManager->signalRemoveBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onRemoveBuffer); m_bufferManager->signalRemoveBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onRemoveBuffer);
} }
} }
static etk::String getCommonPathPart(const etk::String& _left, const etk::String& _right) { static etk::String getCommonPathPart(const etk::Path& _left, const etk::Path& _right) {
etk::String out; etk::String out;
for (size_t iii=0; iii < etk::min(_left.size(), _right.size()); ++iii) { for (size_t iii=0; iii < etk::min(_left.getString().size(), _right.getString().size()); ++iii) {
if (_left[iii] == _right[iii]) { if (_left.getString()[iii] == _right.getString()[iii]) {
out += _left[iii]; out += _left.getString()[iii];
continue; continue;
} }
break; break;
@ -75,11 +75,10 @@ static etk::String getCommonPathPart(const etk::String& _left, const etk::String
void appl::widget::BufferTree::generateFlatTree() { void appl::widget::BufferTree::generateFlatTree() {
// Brut Force Mode... // Brut Force Mode...
etk::String upperParent = getRootPath(); etk::Path upperParent = getRootPath();
// Now we have the root path... // Now we have the root path...
// Need to feed all elements needed. // Need to feed all elements needed.
etk::FSNode nodeRoot = upperParent; m_tree = etk::TreeNode<appl::TreeElement>::create(TreeElement(upperParent, true));
m_tree = etk::TreeNode<appl::TreeElement>::create(TreeElement(nodeRoot, true));
populateNodeIfNeeded(m_tree); populateNodeIfNeeded(m_tree);
updateFlatTree(); updateFlatTree();
} }
@ -97,11 +96,11 @@ void appl::widget::BufferTree::populateNodeIfNeeded(ememory::SharedPtr<etk::Tree
// already populated... // already populated...
return; return;
} }
etk::Vector<etk::FSNode*> child = etk::FSNode(value.m_path).folderGetSubList(false, true, true, false); etk::Vector<etk::Path> child = etk::path::list(value.m_path);
APPL_ERROR(" nbChilds: " << child.size() << " for path: " << value.m_path); APPL_ERROR(" nbChilds: " << child.size() << " for path: " << value.m_path);
for (auto& it: child) { for (auto& it: child) {
APPL_ERROR("add element: " << *it); APPL_ERROR("add element: " << it);
auto elem = etk::TreeNode<appl::TreeElement>::create(TreeElement(*it, false)); auto elem = etk::TreeNode<appl::TreeElement>::create(TreeElement(it, false));
_node->addChild(elem); _node->addChild(elem);
// TODO: ETK_FREE(etk::FSNode, it); // TODO: ETK_FREE(etk::FSNode, it);
} }
@ -114,8 +113,8 @@ void appl::widget::BufferTree::goUpper() {
return; return;
} }
// generate new futur root node ... // generate new futur root node ...
etk::FSNode node = etk::FSNode(m_tree->getData().m_path).folderGetParent(); etk::Path path = m_tree->getData().m_path.getParent();
auto treeElement = etk::TreeNode<appl::TreeElement>::create(TreeElement(node, true)); auto treeElement = etk::TreeNode<appl::TreeElement>::create(TreeElement(path, true));
// Add all sub-items // Add all sub-items
populateNodeIfNeeded(treeElement); populateNodeIfNeeded(treeElement);
// find old root node in the sublist: // find old root node in the sublist:
@ -163,8 +162,8 @@ void appl::widget::BufferTree::removeAllElement() {
//m_list.clear(); //m_list.clear();
} }
etk::String appl::widget::BufferTree::getRootPath() { etk::Path appl::widget::BufferTree::getRootPath() {
etk::String upperParent = ""; etk::Path upperParent = "";
etk::Vector<appl::BufferShared> tmpNewBuffer; etk::Vector<appl::BufferShared> tmpNewBuffer;
for (auto& it : *m_bufferManager) { for (auto& it : *m_bufferManager) {
if (it == null) { if (it == null) {
@ -174,18 +173,18 @@ etk::String appl::widget::BufferTree::getRootPath() {
tmpNewBuffer.pushBack(it); tmpNewBuffer.pushBack(it);
continue; continue;
} }
etk::FSNode nodeName = it->getFileName(); etk::Path nodeName = it->getFileName();
if (upperParent == "") { if (upperParent.isEmpty() == true) {
upperParent = nodeName.getNameFolder(); upperParent = nodeName.getParent();
APPL_ERROR("init root: " << nodeName.getFileSystemName() << " root=" << upperParent); APPL_ERROR("init root: " << nodeName << " root=" << upperParent);
continue; continue;
} }
upperParent = getCommonPathPart(upperParent, nodeName.getNameFolder()); upperParent = getCommonPathPart(upperParent, nodeName.getParent());
APPL_ERROR("Update: " << nodeName.getFileSystemName() << " " << nodeName.getNameFolder() << " root=" << upperParent); APPL_ERROR("Update: " << nodeName << " " << nodeName.getParent() << " root=" << upperParent);
} }
if (upperParent == "") { if (upperParent == "") {
APPL_ERROR("Nothing find ==> get home path..."); APPL_ERROR("Nothing find ==> get home path...");
upperParent = etk::FSNodeGetHomePath(); upperParent = etk::path::getHomePath();
} }
APPL_ERROR("update tree: " << upperParent); APPL_ERROR("update tree: " << upperParent);
return upperParent; return upperParent;
@ -196,7 +195,7 @@ void appl::widget::BufferTree::onNewBuffer(const ememory::SharedPtr<appl::Buffer
if (m_tree == null) { if (m_tree == null) {
generateFlatTree(); generateFlatTree();
} else { } else {
etk::String rootPath = getRootPath(); etk::Path rootPath = getRootPath();
while (rootPath != m_tree->getData().m_path ) { while (rootPath != m_tree->getData().m_path ) {
goUpper(); goUpper();
} }

View File

@ -11,20 +11,21 @@
#include <ewol/widget/TreeView.hpp> #include <ewol/widget/TreeView.hpp>
#include <ewol/widget/Windows.hpp> #include <ewol/widget/Windows.hpp>
#include <etk/FlatTree.hpp> #include <etk/FlatTree.hpp>
#include <etk/path/fileSystem.hpp>
namespace appl { namespace appl {
class TreeElement { class TreeElement {
public: public:
TreeElement(const etk::FSNode& _node, bool _isExpand=false): TreeElement(const etk::Path& _path, bool _isExpand = false):
m_path(_node.getFileSystemName()), m_path(_path),
m_nodeName(_node.getNameFile()), m_nodeName(_path.getFileName()),
m_isFolder(_node.getNodeType() == etk::typeNode_folder), m_isFolder(etk::path::isDirectory(_path) == true),
m_buffer(null), m_buffer(null),
m_isSelected(false), m_isSelected(false),
m_isExpand(_isExpand) { m_isExpand(_isExpand) {
} }
etk::String m_path; etk::Path m_path;
etk::String m_nodeName; // must be here ==> the buffer is optionnal.. etk::String m_nodeName; // must be here ==> the buffer is optionnal..
bool m_isFolder; bool m_isFolder;
ememory::SharedPtr<appl::Buffer> m_buffer; ememory::SharedPtr<appl::Buffer> m_buffer;
@ -54,7 +55,7 @@ namespace appl {
int32_t m_selectedID; int32_t m_selectedID;
void updateFlatTree(); void updateFlatTree();
void generateFlatTree(); void generateFlatTree();
etk::String getRootPath(); etk::Path getRootPath();
void populateNodeIfNeeded(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node); void populateNodeIfNeeded(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node);
void goUpper(); void goUpper();
ememory::SharedPtr<etk::TreeNode<TreeElement>> m_tree; ememory::SharedPtr<etk::TreeNode<TreeElement>> m_tree;