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

View File

@ -6,7 +6,6 @@
#pragma once
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <ewol/ewol.hpp>
#include <etk/Buffer.hpp>
#include <ewol/object/Object.hpp>
@ -300,12 +299,12 @@ namespace appl {
virtual ~Buffer();
private:
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:
/**
* @brief get the curent filename of the Buffer
*/
const etk::String& getFileName() const {
const etk::Path& getFileName() const {
return m_fileName;
}
/**
@ -320,12 +319,12 @@ namespace appl {
* @param[in] _name name of the file.
* @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 ...)
* @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.
* @return true is saving well done

View File

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

View File

@ -16,13 +16,11 @@ namespace appl {
using BufferManagerWeak = ememory::WeakPtr<appl::BufferManager>;
// TODO: This is a service ...
class BufferManager : public ewol::Object {
public: // signals:
esignal::Signal<etk::String> signalNewBuffer;
esignal::Signal<etk::String> signalSelectFile;
public:
esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalNewBuffer;
esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalSelectFile;
esignal::Signal<> signalTextSelectionChange;
esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalRemoveBuffer;
esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalSelectBuffer;
esignal::Signal<ememory::SharedPtr<appl::Buffer>> signalNewBuffer2;
protected:
BufferManager();
public:
@ -37,18 +35,18 @@ namespace appl {
* @param[in] _createIfNeeded Create the buffer if not existed.
* @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:
* @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.
* @param[in] _fileName name of the file.
* @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.
* @return Number of buffer

View File

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

View File

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

View File

@ -331,14 +331,14 @@ void MainWindows::onCallbackMenuEvent(const etk::String& _value) {
APPL_TODO("Event from Menu : " << _value);
} else if ( _value == "menu:color:color/black/"
|| _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::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else if ( _value == "menu:shape:shape/square/"
|| _value == "menu:shape:shape/round/") {
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().forceRedrawAll();
} 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 ...)
ememory::SharedPtr<appl::Buffer> tmpBuffer = m_bufferManager->getBufferSelected();
if (tmpBuffer != null) {
etk::FSNode tmpFile = tmpBuffer->getFileName();
tmpWidget->propertyPath.set(tmpFile.getNameFolder());
tmpWidget->propertyPath.set(tmpBuffer->getFileName().getParent());
}
// apply widget pop-up ...
popUpWidgetPush(tmpWidget);
@ -467,8 +466,8 @@ void MainWindows::displayProperty() {
#endif
}
void MainWindows::onCallbackselectNewFile(const etk::String& _value) {
APPL_INFO("onCallbackselectNewFile(" << _value << ")");
void MainWindows::onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _value) {
APPL_INFO("onCallbackselectNewFile( ... )");
if (m_bufferManager == null) {
APPL_ERROR("can not call unexistant buffer manager ... ");
return;
@ -477,15 +476,15 @@ void MainWindows::onCallbackselectNewFile(const etk::String& _value) {
m_connectionModify.disconnect();
m_connectionSaveName.disconnect();
onCallbackTitleUpdate();
ememory::SharedPtr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp != null) {
m_connectionSave = tmpp->signalIsSave.connect(this, &MainWindows::onCallbackTitleUpdate);
m_connectionModify = tmpp->signalIsModify.connect(this, &MainWindows::onCallbackTitleUpdate);
m_connectionSaveName = tmpp->signalChangeName.connect(this, &MainWindows::onCallbackTitleUpdate);
if (_value != null) {
ememory::SharedPtr<appl::Buffer> tmp = _value;
m_connectionSave = tmp->signalIsSave.connect(this, &MainWindows::onCallbackTitleUpdate);
m_connectionModify = tmp->signalIsModify.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_DEBUG("Request opening the file : " << _value);
m_bufferManager->open(_value);
@ -505,10 +504,9 @@ void MainWindows::onCallbackTitleUpdate() {
m_widgetLabelFileName->propertyValue.set("");
}
} else {
etk::String nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName();
propertyTitle.set(etk::String("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem);
propertyTitle.set(etk::String("Edn : ") + (tmpp->isModify()==true?" *":"") + tmpp->getFileName().getString());
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;
}
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;
if (_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("_T{Save}", true);

View File

@ -44,11 +44,11 @@ class MainWindows : public ewol::widget::Windows {
void displayOpen();
void displayProperty();
private:
void onCallbackPopUpFileSelected(const etk::String& _value);
void onCallbackPopUpFileSelected(const etk::Path& _value);
void onCallbackTitleUpdate();
void onCallbackMenuEvent(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;
setMouseLimit(1);
// 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) {
m_colorIdText = m_colorProperty->request("text");
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()) {
return etk::toString(m_list[_pos.y()]->fileLine);
}
return m_list[_pos.y()]->filename;
return m_list[_pos.y()]->filename.getString();
}
return "ERROR";
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()
&& null != m_list[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 {
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 {
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] 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);
if (null != 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 {
class TagListElement {
public:
etk::String filename;
int32_t fileLine;
TagListElement(etk::String& _file, int32_t _line) :
etk::Path filename;
int32_t fileLine;
TagListElement(etk::Path& _file, int32_t _line) :
filename(_file),
fileLine(_line) {
@ -24,8 +24,8 @@ namespace appl {
};
class TagFileList : public ewol::widget::List {
public:
esignal::Signal<etk::String> signalSelect;
esignal::Signal<etk::String> signalValidate;
esignal::Signal<etk::Path, int32_t> signalSelect;
esignal::Signal<etk::Path, int32_t> signalValidate;
esignal::Signal<> signalUnSelect;
private:
int32_t m_selectedLine;
@ -53,7 +53,7 @@ namespace appl {
* @param[in] file Compleate file name
* @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() {
if (m_eventNamed != "") {
signalSelect.emit(m_eventNamed);
if (m_eventLine != -1) {
signalSelect.emit(m_eventPath, m_eventLine);
// == > Auto remove ...
autoDestroy();
}
@ -104,18 +104,20 @@ void appl::TagFileSelection::onCallbackCtagsCancel() {
autoDestroy();
}
void appl::TagFileSelection::onCallbackCtagsListValidate(const etk::String& _value) {
signalSelect.emit(_value);
void appl::TagFileSelection::onCallbackCtagsListValidate(const etk::Path& _path, const int32_t& _line) {
signalSelect.emit(_path, _line);
// == > Auto remove ...
autoDestroy();
}
void appl::TagFileSelection::onCallbackCtagsListSelect(const etk::String& _value) {
m_eventNamed = _value;
void appl::TagFileSelection::onCallbackCtagsListSelect(const etk::Path& _path, const int32_t& _line) {
m_eventPath = _path;
m_eventLine = _line;
}
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] 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) {
m_listTag->add(_file, _line);
}

View File

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

View File

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

View File

@ -415,7 +415,7 @@ namespace appl {
void onCallbackIsModify();
void onCallbackShortCut(const etk::String& _value);
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);
virtual ~WorkerCloseAllFile();
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::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // callback function

View File

@ -24,14 +24,14 @@ void appl::WorkerCloseFile::init() {
ewol::object::Worker::init();
}
void appl::WorkerCloseFile::startAction(const etk::String& _bufferName) {
void appl::WorkerCloseFile::startAction(const etk::Path& _bufferName) {
m_bufferName = _bufferName;
if (m_bufferManager == null) {
APPL_ERROR("can not call unexistant buffer manager ... ");
destroy();
return;
}
if (m_bufferName == "") {
if (m_bufferName.isEmpty() == true) {
// need to find the curent file ...
ememory::SharedPtr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp == null) {
@ -66,7 +66,7 @@ void appl::WorkerCloseFile::startAction(const etk::String& _bufferName) {
return;
}
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;
if (m_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("_T{Save}", true);
@ -132,7 +132,7 @@ void appl::WorkerCloseFile::onCallbackSaveValidate() {
return;
}
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();
} else {
m_buffer->destroy();

View File

@ -25,9 +25,9 @@ namespace appl {
/**
* @brief Action to do
*/
void startAction(const etk::String& _bufferName);
void startAction(const etk::Path& _bufferName);
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::WorkerSaveFile> m_worker; //! sub-worker element...
ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager

View File

@ -17,7 +17,7 @@ namespace appl {
DECLARE_FACTORY(WorkerSaveAllFile);
virtual ~WorkerSaveAllFile();
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::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // callback function

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,10 +8,10 @@
#include <ewol/object/Object.hpp>
#include <ewol/context/Context.hpp>
#include <gale/resource/Manager.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/theme/theme.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 {

View File

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

View File

@ -19,7 +19,7 @@ static void SortElementList(etk::Vector<appl::dataBufferStruct>& _list) {
size_t findPos = 0;
for(size_t jjj=0; jjj<_list.size(); 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;
}
}
@ -78,7 +78,7 @@ void appl::widget::BufferList::removeAllElement() {
void appl::widget::BufferList::insertAlphabetic(const appl::dataBufferStruct& _dataStruct, bool _selectNewPosition) {
// alphabetical order:
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);
if (_selectNewPosition == true) {
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) {
ememory::SharedPtr<appl::Buffer> buffer = m_bufferManager->get(_value);
if (buffer == null) {
APPL_ERROR("event on element nor exist : " << _value);
void appl::widget::BufferList::onCallbackNewBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) {
if (_buffer == null) {
return;
}
ememory::SharedPtr<appl::Buffer> buffer = _buffer;
buffer->signalIsSave.connect(sharedFromThis(), &BufferList::onCallbackIsSave);
buffer->signalIsModify.connect(sharedFromThis(), &BufferList::onCallbackIsModify);
buffer->signalChangeName.connect(sharedFromThis(), &BufferList::onCallbackChangeName);
appl::dataBufferStruct tmp(_value, buffer);
appl::dataBufferStruct tmp(_buffer->getFileName(), _buffer);
if (m_openOrderMode == true) {
m_list.pushBack(tmp);
} 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 ...
void appl::widget::BufferList::onCallbackselectNewFile(const etk::String& _value) {
void appl::widget::BufferList::onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _buffer) {
m_selectedID = -1;
for (size_t iii=0; iii<m_list.size(); iii++) {
if (m_list[iii].m_buffer == null) {
continue;
}
if (m_list[iii].m_buffer->getFileName() != _value) {
if (m_list[iii].m_buffer != _buffer) {
continue;
}
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) {
switch (_role) {
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:
if ( m_list[_pos.y()].m_buffer != null
&& m_list[_pos.y()].m_buffer->isModify() == false) {

View File

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

View File

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

View File

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