Compare commits

...

7 Commits

41 changed files with 583 additions and 424 deletions

View File

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<sizer mode="hori" expand="true,false" fill="true" lock="true"> <sizer mode="hori" expand="true,false" fill="true" lock="true">
<button name="[{ID}]SEARCH:close"> <button name="[{ID}]SEARCH:close">
<image src="THEME:GUI:Remove.svg" fill="true" size="7,7mm"/> <image src="THEME_GUI:///Remove.svg" fill="true" size="7,7mm"/>
</button> </button>
<entry name="[{ID}]SEARCH:search-entry" expand="true" fill="true"/> <entry name="[{ID}]SEARCH:search-entry" expand="true" fill="true"/>
<button name="[{ID}]SEARCH:search"> <button name="[{ID}]SEARCH:search">
<image src="THEME:GUI:Search.svg" fill="true" size="7,7mm"/> <image src="THEME_GUI:///Search.svg" fill="true" size="7,7mm"/>
</button> </button>
<entry name="[{ID}]SEARCH:replace-entry" expand="true" fill="true"/> <entry name="[{ID}]SEARCH:replace-entry" expand="true" fill="true"/>
<button name="[{ID}]SEARCH:replace"> <button name="[{ID}]SEARCH:replace">
<image src="{ewol}THEME:GUI:Replace.svg" fill="true" size="7,7mm"/> <image src="THEME_GUI:///Replace.svg?lib=ewol" fill="true" size="7,7mm"/>
</button> </button>
<button name="[{ID}]SEARCH:case" toggle="true"> <button name="[{ID}]SEARCH:case" toggle="true">
<image src="{ewol}THEME:GUI:CaseSensitive.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/> <image src="THEME_GUI:///CaseSensitive.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="{ewol}THEME:GUI:CaseSensitive.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/> <image src="THEME_GUI:///CaseSensitive.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
</button> </button>
<button name="[{ID}]SEARCH:wrap" toggle="true"> <button name="[{ID}]SEARCH:wrap" toggle="true">
<image src="{ewol}THEME:GUI:WrapAround.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/> <image src="THEME_GUI:///WrapAround.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="{ewol}THEME:GUI:WrapAround.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/> <image src="THEME_GUI:///WrapAround.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
</button> </button>
<button name="[{ID}]SEARCH:up-down" toggle="true"> <button name="[{ID}]SEARCH:up-down" toggle="true">
<image src="{ewol}THEME:GUI:Up.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/> <image src="THEME_GUI:///Up.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="{ewol}THEME:GUI:Down.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/> <image src="THEME_GUI:///Down.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
</button> </button>
</sizer> </sizer>

View File

@ -34,15 +34,19 @@
</rule> </rule>
<rule name="Résultat OK"> <rule name="Résultat OK">
<color>TestResultOK</color> <color>TestResultOK</color>
<regex>\[( )*(OK|Ok|ok)( )*\]</regex> <regex>\[(\t| )*(OK|Ok|ok|DONE|Done|done)(\t| )*\]</regex>
</rule> </rule>
<rule name="resultat en erreur"> <rule name="resultat en erreur">
<color>TestResultERROR</color> <color>TestResultERROR</color>
<regex>\[(ERREUR|Erreur|erreur)\]</regex> <regex>\[(\t| )*(ERREUR|Erreur|erreur)(\t| )*\]</regex>
</rule>
<rule name="to do">
<color>TestResultTODO</color>
<regex>\[(\t| )*(TODO|Todo|todo)(\t| )*\]</regex>
</rule> </rule>
<rule name="resultat vide"> <rule name="resultat vide">
<color>number</color> <color>number</color>
<regex>\[( )*\]</regex> <regex>\[(\t| )*\]</regex>
</rule> </rule>
<rule name="notes ... "> <rule name="notes ... ">
<color>macro</color> <color>macro</color>

View File

@ -90,7 +90,11 @@
</rule> </rule>
<rule name="etk type"> <rule name="etk type">
<color>type</color> <color>type</color>
<regex>\@etk::(Vector|Array|List|Function|String|UString|RegEx|Pair|NullPtr|Color|Exception|exception::(InvalidArgument|DomainError|LengthError|OutOfRange|RangeError|OverflowError|UnderflowError|CastError|AllocationError|RuntimeError))\@</regex> <regex>\@etk::(Map|Set|Path|Uri|Vector|Array|List|Function|String|UString|RegEx|Pair|NullPtr|Color|Exception|exception::(InvalidArgument|DomainError|LengthError|OutOfRange|RangeError|OverflowError|UnderflowError|CastError|AllocationError|RuntimeError))\@</regex>
</rule>
<rule name="ememory type">
<color>type</color>
<regex>\@ememory::(SharedPtr|WeakPtr|EnableSharedFromThis|Counter|RefCounter|RefPtr|UniquePtr)\@</regex>
</rule> </rule>
<rule name="my storage keyword"> <rule name="my storage keyword">
<color>storageKeyword</color> <color>storageKeyword</color>
@ -98,7 +102,7 @@
</rule> </rule>
<rule name="my common Define"> <rule name="my common Define">
<color>commonDefine</color> <color>commonDefine</color>
<regex>\@nullptr|__(LINE|DATA|FILE|func|TIME|STDC|PRETTY_FUNCTION|FUNCTION)__\@</regex> <regex>\@nullptr|null|__(LINE|DATA|FILE|func|TIME|STDC|PRETTY_FUNCTION|FUNCTION)__\@</regex>
</rule> </rule>
<rule name="numeric constant"> <rule name="numeric constant">
<color>number</color> <color>number</color>

View File

@ -18,19 +18,19 @@
</rule> </rule>
<rule name="documantation"> <rule name="documantation">
<color>commentDoxygen</color> <color>commentDoxygen</color>
<regex>#.*</regex> <regex>#.*$</regex>
<sub>docparse</sub> <sub>docparse</sub>
</rule> </rule>
<rule name="inline comment"> <rule name="inline comment">
<color>comment</color> <color>comment</color>
<regex>//.*</regex> <regex>//.*$</regex>
<sub>TODO</sub> <sub>TODO</sub>
</rule> </rule>
</pass1> </pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear --> <pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="my type"> <rule name="my type">
<color>type</color> <color>type</color>
<regex>\@import|void|bool|string|int(8|16|32|64)|uint(8|16|32|64)|float(32|64)|vector:(bool|string|int(8|16|32|64)|uint(8|16|32|64)|float(32|64))|time|duration|file|stream\@</regex> <regex>\@import|void|bool|path|uri|string|int(8|16|32|64)|uint(8|16|32|64)|float(32|64)|vector:(bool|string|int(8|16|32|64)|uint(8|16|32|64)|float(32|64))|time|duration|file|stream\@</regex>
</rule> </rule>
<rule name="numeric constant"> <rule name="numeric constant">
<color>number</color> <color>number</color>

View File

@ -29,7 +29,8 @@
{ name:"functionName", foreground:"#09857e", bold:true}, { name:"functionName", foreground:"#09857e", bold:true},
{ name:"functionNamePrivate", foreground:"#09854e", bold:true}, { name:"functionNamePrivate", foreground:"#09854e", bold:true},
{ name:"TestResultOK", foreground:"#000000", background:"#009c00", bold:true}, { name:"TestResultOK", foreground:"#000000", background:"#009c00", bold:true},
{ name:"TestResultERROR", foreground:"#000000", background:"#c20000", bold:true} { name:"TestResultERROR", foreground:"#000000", background:"#c20000", bold:true},
{ name:"TestResultTODO", foreground:"#000000", background:"#bf3e00", bold:true},
{ name:"doxygen-key-known", foreground:"#Fc4700", bold:true, italic:false}, { name:"doxygen-key-known", foreground:"#Fc4700", bold:true, italic:false},
{ name:"doxygen-key", foreground:"#dc3700", bold:true, italic:false}, { name:"doxygen-key", foreground:"#dc3700", bold:true, italic:false},

View File

@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.module as module import lutin.module as module
import lutin.tools as tools import lutin.tools as tools
import lutin.debug as debug import realog.debug as debug
import os import os
def get_type(): def get_type():

View File

@ -5,6 +5,9 @@
*/ */
#include <etk/types.hpp> #include <etk/types.hpp>
#include <etk/stdTools.hpp> #include <etk/stdTools.hpp>
#include <etk/system.hpp>
#include <etk/path/fileSystem.hpp>
#include <appl/Buffer.hpp> #include <appl/Buffer.hpp>
#include <appl/debug.hpp> #include <appl/debug.hpp>
#include <gale/context/clipBoard.hpp> #include <gale/context/clipBoard.hpp>
@ -108,6 +111,7 @@ appl::Buffer::Iterator appl::Buffer::selectStop() {
} }
appl::Buffer::Buffer() : appl::Buffer::Buffer() :
signalFileIsModify(this, "file-is-modify", ""),
signalIsModify(this, "is-modify", ""), signalIsModify(this, "is-modify", ""),
signalIsSave(this, "is-save", ""), signalIsSave(this, "is-save", ""),
signalSelectChange(this, "select-change", ""), signalSelectChange(this, "select-change", ""),
@ -122,7 +126,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,34 +138,30 @@ 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;
m_fileIsModify = false;
return true; return true;
} }
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);
@ -170,6 +170,31 @@ void appl::Buffer::setFileName(const etk::String& _name) {
bool appl::Buffer::storeFile() { bool appl::Buffer::storeFile() {
if (m_data.dumpIn(m_fileName) == true) { if (m_data.dumpIn(m_fileName) == true) {
APPL_INFO("saving file : " << m_fileName); APPL_INFO("saving file : " << m_fileName);
etk::String extention = m_fileName.getExtention();
if (etk::isIn(extention, {"cpp", "hpp", "h", "hpp"}) {
etk::Path clangFile = etk::path::findInParent(m_fileName, ".clang-format");
if (etk::path::isFile(clangFile) == true) {
etk::String output = etk::exec("clang-format " + m_fileName.getAbsolute());// + " -assume-filename=" + clangFile.getAbsolute() + "
etk::String tmp = m_data.getString();
/*
APPL_WARNING(" input = '" << tmp << "'");
APPL_ERROR(" output = '" << output << "'");
*/
if (tmp != output) {
/*
etk::io::File file(m_fileName + "_tmp");
file.open(etk::io::OpenMode::Write);
file.write(&tmp[0], 1, tmp.size());
file.close();
*/
APPL_ERROR(" ==> data is differents");
m_fileIsModify = true;
setModification(true);
signalFileIsModify();
return true;
}
}
}
setModification(false); setModification(false);
return true; return true;
} }
@ -675,8 +700,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 +1037,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 +1056,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>
@ -288,6 +287,7 @@ namespace appl {
friend class Buffer; friend class Buffer;
}; };
public: // signals public: // signals
esignal::Signal<> signalFileIsModify;
esignal::Signal<> signalIsModify; esignal::Signal<> signalIsModify;
esignal::Signal<> signalIsSave; esignal::Signal<> signalIsSave;
esignal::Signal<> signalSelectChange; esignal::Signal<> signalSelectChange;
@ -299,13 +299,22 @@ namespace appl {
DECLARE_FACTORY(Buffer); DECLARE_FACTORY(Buffer);
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_fileIsModify = false; //!< The file has been modify and the buffer is not synchronous
etk::String 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 { bool getFileModify() const {
return m_fileIsModify;
}
private:
bool m_hasFileName; //!< When new file, the buffer has no name ==> but it might be reference with a single name ...
etk::Path m_fileName; //!< name of the file (with his path)
public:
/**
* @brief get the curent filename of the Buffer
*/
const etk::Path& getFileName() const {
return m_fileName; return m_fileName;
} }
/** /**
@ -320,12 +329,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,21 @@ 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); etk::Path fileName = _fileName.getAbsolute();
etk::String fileName = file.getName();
if (exist(fileName) == true) { if (exist(fileName) == true) {
APPL_WARNING(" the element '" << fileName << "' already exist ... just reselect it ..."); APPL_WARNING(" the element '" << fileName << "' already exist ... just reselect it ...");
signalSelectFile.emit(fileName); signalSelectFile.emit(get(fileName));
signalSelectBuffer.emit(get(fileName)); propertySetOnWidgetNamed("appl-widget-display-name", "value", fileName.getString());
propertySetOnWidgetNamed("appl-widget-display-name", "value", etk::FSNodeGetRealName(fileName));
return; return;
} }
if (get(fileName, true) == null) { auto value = get(fileName, true);
if (value == null) {
APPL_ERROR("Error get '" << fileName << "' ... "); 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 +156,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

@ -99,8 +99,6 @@ void MainWindows::init() {
ewol::widget::SizerShared mySizerHori; ewol::widget::SizerShared mySizerHori;
ememory::SharedPtr<appl::TextViewer> myTextView; ememory::SharedPtr<appl::TextViewer> myTextView;
ememory::SharedPtr<appl::TextViewer> myTextView2; ememory::SharedPtr<appl::TextViewer> myTextView2;
appl::widget::BufferListShared myBufferList;
appl::widget::BufferTreeShared myBufferTree;
ewol::widget::MenuShared myMenu; ewol::widget::MenuShared myMenu;
// load buffer manager: // load buffer manager:
@ -115,28 +113,30 @@ void MainWindows::init() {
mySizerHori->propertyName.set("plop 222222222"); mySizerHori->propertyName.set("plop 222222222");
mySizerHori->propertyMode.set(ewol::widget::Sizer::modeHori); mySizerHori->propertyMode.set(ewol::widget::Sizer::modeHori);
mySizerVert->subWidgetAdd(mySizerHori); mySizerVert->subWidgetAdd(mySizerHori);
if (false) {
myBufferList = appl::widget::BufferList::create(); m_viewBuffer = appl::widget::BufferList::create();
myBufferList->propertyName.set("plop 3333333"); m_viewBuffer->propertyHide.set(true);
myBufferList->propertyExpand.set(bvec2(false,true)); m_viewBuffer->propertyName.set("appl-buffer-view");
myBufferList->propertyFill.set(bvec2(true,true)); m_viewBuffer->propertyExpand.set(bvec2(false,true));
//myBufferList->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel)); m_viewBuffer->propertyFill.set(bvec2(true,true));
mySizerHori->subWidgetAdd(myBufferList); //m_viewBuffer->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel));
} else { mySizerHori->subWidgetAdd(m_viewBuffer);
myBufferTree = appl::widget::BufferTree::create();
myBufferTree->propertyName.set("plop 3333333"); m_viewTree = appl::widget::BufferTree::create();
myBufferTree->propertyExpand.set(bvec2(false,true)); m_viewTree->propertyName.set("appl-tree-view");
myBufferTree->propertyFill.set(bvec2(true,true)); //m_viewTree->propertyHide.set(true);
myBufferTree->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel)); m_viewTree->propertyExpand.set(bvec2(false,true));
mySizerHori->subWidgetAdd(myBufferTree); m_viewTree->propertyFill.set(bvec2(true,true));
} m_viewTree->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel));
mySizerHori->subWidgetAdd(m_viewTree);
ewol::widget::SpacerShared mySpacer = ewol::widget::Spacer::create(); ewol::widget::SpacerShared mySpacer = ewol::widget::Spacer::create();
mySpacer->propertyName.set("appl-Buffer-viewer-separator"); mySpacer->propertyName.set("appl-Buffer-viewer-separator");
mySpacer->propertyColor.set(etk::color::black); mySpacer->propertyColor.set(etk::color::black);
mySpacer->propertyMinSize.set(gale::Dimension(vec2(2,2), gale::distance::pixel)); mySpacer->propertyMinSize.set(gale::Dimension(vec2(2,2), gale::distance::pixel));
mySpacer->propertyExpand.set(bvec2(false,true)); mySpacer->propertyExpand.set(bvec2(false,true));
mySpacer->propertyFill.set(bvec2(true,true)); mySpacer->propertyFill.set(bvec2(true,true));
mySpacer->propertyHide.set(true); //mySpacer->propertyHide.set(true);
mySizerHori->subWidgetAdd(mySpacer); mySizerHori->subWidgetAdd(mySpacer);
mySizerVert2 = ewol::widget::Sizer::create(); mySizerVert2 = ewol::widget::Sizer::create();
@ -188,27 +188,32 @@ void MainWindows::init() {
int32_t idMenuFile = myMenu->addTitle("_T{File}"); int32_t idMenuFile = myMenu->addTitle("_T{File}");
myMenu->add(idMenuFile, "_T{New}", "", "menu:new"); myMenu->add(idMenuFile, "_T{New}", "", "menu:new");
myMenu->addSpacer(idMenuFile); myMenu->addSpacer(idMenuFile);
myMenu->add(idMenuFile, "_T{Open}", "THEME:GUI:Load.svg", "menu:open"); myMenu->add(idMenuFile, "_T{Open}", "THEME_GUI:///Load.svg", "menu:open");
myMenu->add(idMenuFile, "_T{Close}", "THEME:GUI:Close.svg", "menu:close"); myMenu->add(idMenuFile, "_T{Close}", "THEME_GUI:///Close.svg", "menu:close");
myMenu->add(idMenuFile, "_T{Close (all)}", "", "menu:close-all"); myMenu->add(idMenuFile, "_T{Close (all)}", "", "menu:close-all");
myMenu->add(idMenuFile, "_T{Save}", "THEME:GUI:Save.svg", "menu:save"); myMenu->add(idMenuFile, "_T{Save}", "THEME_GUI:///Save.svg", "menu:save");
myMenu->add(idMenuFile, "_T{Save As ...}", "", "menu:save-as"); myMenu->add(idMenuFile, "_T{Save As ...}", "", "menu:save-as");
myMenu->addSpacer(idMenuFile); myMenu->addSpacer(idMenuFile);
myMenu->add(idMenuFile, "_T{Properties}", "THEME:GUI:Parameter.svg", "menu:property"); myMenu->add(idMenuFile, "_T{Properties}", "THEME_GUI:///Parameter.svg", "menu:property");
myMenu->addSpacer(idMenuFile); myMenu->addSpacer(idMenuFile);
myMenu->add(idMenuFile, "_T{Exit}", "", "menu:exit"); myMenu->add(idMenuFile, "_T{Exit}", "", "menu:exit");
int32_t idMenuEdit = myMenu->addTitle("_T{Edit}"); int32_t idMenuEdit = myMenu->addTitle("_T{Edit}");
myMenu->add(idMenuEdit, "_T{Goto line ...}","", "menu:goto-line"); myMenu->add(idMenuEdit, "_T{Goto line ...}","", "menu:goto-line");
myMenu->addSpacer(); myMenu->addSpacer();
int32_t idMenuSearch = myMenu->addTitle("_T{Search}"); int32_t idMenuSearch = myMenu->addTitle("_T{Search}");
myMenu->add(idMenuSearch, "_T{Search}", "THEME:GUI:Search.svg", "menu:search"); myMenu->add(idMenuSearch, "_T{Search}", "THEME_GUI:///Search.svg", "menu:search");
myMenu->add(idMenuSearch, "_T{Replace}", "THEME:GUI:Replace.svg", "menu:replace"); myMenu->add(idMenuSearch, "_T{Replace}", "THEME_GUI:///Replace.svg", "menu:replace");
myMenu->addSpacer(idMenuSearch); myMenu->addSpacer(idMenuSearch);
myMenu->add(idMenuSearch, "_T{Find (previous)}","", "menu:find:previous"); myMenu->add(idMenuSearch, "_T{Find (previous)}","", "menu:find:previous");
myMenu->add(idMenuSearch, "_T{Find (next)}", "", "menu:find:next"); myMenu->add(idMenuSearch, "_T{Find (next)}", "", "menu:find:next");
myMenu->add(idMenuSearch, "_T{Find (all)}", "", "menu:find:all"); myMenu->add(idMenuSearch, "_T{Find (all)}", "", "menu:find:all");
myMenu->add(idMenuSearch, "_T{Un-Select}", "", "menu:find:none"); myMenu->add(idMenuSearch, "_T{Un-Select}", "", "menu:find:none");
int32_t idMenugDisplay = myMenu->addTitle("_T{Display}"); int32_t idMenugDisplay = myMenu->addTitle("_T{Display}");
myMenu->add(idMenugDisplay, "_T{Tree view}", "", "menu:view:tree");
myMenu->add(idMenugDisplay, "_T{Buffer view}", "", "menu:view:buffer");
myMenu->add(idMenugDisplay, "_T{Tree view: Show un-needed}", "", "menu:view:tree:ShowUnneeded");
myMenu->add(idMenugDisplay, "_T{Tree view: Hide un-needed}", "", "menu:view:tree:HideUnneeded");
myMenu->addSpacer(idMenugDisplay);
myMenu->add(idMenugDisplay, "_T{Color Black}", "", "menu:color:color/black/"); myMenu->add(idMenugDisplay, "_T{Color Black}", "", "menu:color:color/black/");
myMenu->add(idMenugDisplay, "_T{Color White}", "", "menu:color:color/white/"); myMenu->add(idMenugDisplay, "_T{Color White}", "", "menu:color:color/white/");
myMenu->add(idMenugDisplay, "_T{Shape square}", "", "menu:shape:shape/square/"); myMenu->add(idMenugDisplay, "_T{Shape square}", "", "menu:shape:shape/square/");
@ -229,6 +234,8 @@ void MainWindows::init() {
mySizerHori->subWidgetAdd(m_widgetLabelFileName); mySizerHori->subWidgetAdd(m_widgetLabelFileName);
// add generic shortcut ... // add generic shortcut ...
shortCutAdd("ctrl+b", "menu:view:toggle");
shortCutAdd("ctrl+o", "menu:open"); shortCutAdd("ctrl+o", "menu:open");
shortCutAdd("ctrl+n", "menu:new"); shortCutAdd("ctrl+n", "menu:new");
@ -241,7 +248,7 @@ void MainWindows::init() {
shortCutAdd("ctrl+l", "menu:goto-line"); shortCutAdd("ctrl+l", "menu:goto-line");
shortCutAdd("ctrl+f", "menu:search"); shortCutAdd("ctrl+f", "menu:search");
shortCutAdd("F12", "menu:reloade-shader"); shortCutAdd("alt+F12", "menu:reloade-shader");
shortCutAdd("alt+F4", "menu:exit"); shortCutAdd("alt+F4", "menu:exit");
// TODO : auto-connect on shortcut event ==> maybe do beter later ... // TODO : auto-connect on shortcut event ==> maybe do beter later ...
signalShortcut.connect(sharedFromThis(), &MainWindows::onCallbackShortCut); signalShortcut.connect(sharedFromThis(), &MainWindows::onCallbackShortCut);
@ -321,6 +328,19 @@ void MainWindows::onCallbackMenuEvent(const etk::String& _value) {
m_widgetSearch->selectReplace(); m_widgetSearch->selectReplace();
} }
} }
} else if (_value == "menu:view:buffer") {
m_viewTree->propertyHide.set(true);
m_viewBuffer->propertyHide.set(false);
} else if (_value == "menu:view:tree") {
m_viewTree->propertyHide.set(false);
m_viewBuffer->propertyHide.set(true);
} else if (_value == "menu:view:toggle") {
m_viewTree->propertyHide.set(m_viewTree->propertyHide.get() == false);
m_viewBuffer->propertyHide.set(m_viewBuffer->propertyHide.get() == false);
} else if (_value == "menu:view:tree:ShowUnneeded") {
propertySetOnWidgetNamed("appl-tree-view", "show-un-needed", "true");
} else if (_value == "menu:view:tree:HideUnneeded") {
propertySetOnWidgetNamed("appl-tree-view", "show-un-needed", "false");
} else if (_value == "menu:find:previous") { } else if (_value == "menu:find:previous") {
APPL_TODO("Event from Menu : " << _value); APPL_TODO("Event from Menu : " << _value);
} else if (_value == "menu:find:next") { } else if (_value == "menu:find:next") {
@ -331,14 +351,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 +445,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 +486,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 +496,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 +524,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 +550,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

@ -14,10 +14,13 @@
#include <appl/BufferManager.hpp> #include <appl/BufferManager.hpp>
#include <appl/Gui/Search.hpp> #include <appl/Gui/Search.hpp>
#include <appl/Gui/ViewerManager.hpp> #include <appl/Gui/ViewerManager.hpp>
class MainWindows : public ewol::widget::Windows { class MainWindows : public ewol::widget::Windows {
private: private:
ewol::widget::LabelShared m_widgetLabelFileName; ewol::widget::LabelShared m_widgetLabelFileName;
appl::widget::SearchShared m_widgetSearch; appl::widget::SearchShared m_widgetSearch;
ewol::WidgetShared m_viewTree;
ewol::WidgetShared m_viewBuffer;
esignal::Connection m_connectionSave; esignal::Connection m_connectionSave;
esignal::Connection m_connectionModify; esignal::Connection m_connectionModify;
esignal::Connection m_connectionSaveName; esignal::Connection m_connectionSaveName;
@ -44,11 +47,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

@ -20,7 +20,7 @@ appl::widget::Search::Search() :
} }
void appl::widget::Search::init() { void appl::widget::Search::init() {
ewol::widget::Composer::init(); ewol::widget::Composer::init();
loadFromFile("DATA:GUI-Search.xml", getId()); loadFromFile("DATA:///GUI-Search.xml", getId());
m_viewerManager = appl::ViewerManager::create(); m_viewerManager = appl::ViewerManager::create();
// link event // link event
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]SEARCH:close", signalPressed, sharedFromThis(), &appl::widget::Search::OnCallbackHide); subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]SEARCH:close", signalPressed, sharedFromThis(), &appl::widget::Search::OnCallbackHide);

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

@ -49,13 +49,13 @@ void appl::TagFileSelection::init() {
" <spacer expand='true,false'/>\n" " <spacer expand='true,false'/>\n"
" <button name='PLUGIN-CTAGS-jump' expand='false' fill='true'>" " <button name='PLUGIN-CTAGS-jump' expand='false' fill='true'>"
" <sizer mode='hori'>\n" " <sizer mode='hori'>\n"
" <image src='THEME:GUI:Load.svg' fill='true' size='10,10mm'/>\n" " <image src='THEME_GUI:///Load.svg' fill='true' size='10,10mm'/>\n"
" <label>Jump</label>\n" " <label>Jump</label>\n"
" </sizer>\n" " </sizer>\n"
" </button>\n" " </button>\n"
" <button name='PLUGIN-CTAGS-cancel' expand='false' fill='true'>" " <button name='PLUGIN-CTAGS-cancel' expand='false' fill='true'>"
" <sizer mode='hori'>\n" " <sizer mode='hori'>\n"
" <image src='THEME:GUI:Remove.svg' fill='true' size='10,10mm'/>\n" " <image src='THEME_GUI:///Remove.svg' fill='true' size='10,10mm'/>\n"
" <label>Cancel</label>\n" " <label>Cancel</label>\n"
" </sizer>\n" " </sizer>\n"
" </button>\n" " </button>\n"
@ -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

@ -38,7 +38,7 @@ appl::TextViewer::TextViewer() :
m_viewerManager = appl::ViewerManager::create(); m_viewerManager = appl::ViewerManager::create();
// load color properties // load color properties
m_paintingProperties = appl::GlyphPainting::create("THEME:COLOR:textViewer.json"); m_paintingProperties = appl::GlyphPainting::create("THEME_COLOR:///textViewer.json");
// get all id properties ... // get all id properties ...
m_colorBackground = m_paintingProperties->request("CODE_basicBackgroung"); m_colorBackground = m_paintingProperties->request("CODE_basicBackgroung");
m_colorSpace = m_paintingProperties->request("CODE_space"); m_colorSpace = m_paintingProperties->request("CODE_space");
@ -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,29 @@ 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) { APPL_DEBUG("find " << list.size() << " element(s) in " << uri );
for (auto &it: list) {
APPL_DEBUG(" - " << it );
APPL_DEBUG(" " << it.getPath() << " " << etk::uri::isDirectory(it));
if (etk::uri::isDirectory(it) == false) {
continue; continue;
} }
if (it->getNodeType() != etk::typeNode_folder) { etk::Uri uriXml = uri;
continue; uriXml.setPath(it.getPath() / "highlight.xml");
} ememory::SharedPtr<appl::Highlight> myHightLight = appl::Highlight::create(uriXml);
etk::String filename = it->getName() + "/highlight.xml"; if (myHightLight != null) {
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 '" << uriXml << "' 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 +72,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 +108,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

@ -24,8 +24,8 @@ void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) {
if (menu != null) { if (menu != null) {
m_menuIdTitle = menu->addTitle("_T{Edit}"); m_menuIdTitle = menu->addTitle("_T{Edit}");
if (m_menuIdTitle != -1) { if (m_menuIdTitle != -1) {
m_menuIdUndo = menu->add(m_menuIdTitle, "_T{Undo}", "THEME:GUI:Undo.svg", "appl::TextPluginHistory::menu:undo"); m_menuIdUndo = menu->add(m_menuIdTitle, "_T{Undo}", "THEME_GUI:///Undo.svg", "appl::TextPluginHistory::menu:undo");
m_menuIdRedo = menu->add(m_menuIdTitle, "_T{Redo}", "THEME:GUI:Redo.svg", "appl::TextPluginHistory::menu:redo"); m_menuIdRedo = menu->add(m_menuIdTitle, "_T{Redo}", "THEME_GUI:///Redo.svg", "appl::TextPluginHistory::menu:redo");
} }
} }
// add event : // add event :

View File

@ -12,6 +12,7 @@ namespace appl {
}; };
#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data) #define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)
#define APPL_PRINT(data) APPL_BASE(-1, data)
#define APPL_CRITICAL(data) APPL_BASE(1, data) #define APPL_CRITICAL(data) APPL_BASE(1, data)
#define APPL_ERROR(data) APPL_BASE(2, data) #define APPL_ERROR(data) APPL_BASE(2, data)
#define APPL_WARNING(data) APPL_BASE(3, data) #define APPL_WARNING(data) APPL_BASE(3, data)

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 {
@ -137,7 +137,7 @@ globals::ParameterGlobalsGui::ParameterGlobalsGui() {
void globals::ParameterGlobalsGui::init() { void globals::ParameterGlobalsGui::init() {
ewol::widget::Composer::init(); ewol::widget::Composer::init();
loadFromFile("DATA:GUI-Parameter-global.xml", getId()); loadFromFile("DATA:///GUI-Parameter-global.xml", getId());
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-param:auto-indent", "value", etk::toString(isSetAutoIndent())); propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-param:auto-indent", "value", etk::toString(isSetAutoIndent()));
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-param:display-space-char", "value", etk::toString(isSetDisplaySpaceChar())); propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-param:display-space-char", "value", etk::toString(isSetDisplaySpaceChar()));

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>
@ -25,6 +26,7 @@
#include <appl/ctags/readtags.hpp> #include <appl/ctags/readtags.hpp>
#include <appl/globalMsg.hpp> #include <appl/globalMsg.hpp>
#include <appl/TextPluginCtags.hpp> #include <appl/TextPluginCtags.hpp>
#include <appl/debug.hpp>
class MainApplication : public ewol::context::Application { class MainApplication : public ewol::context::Application {
private: private:
@ -37,8 +39,8 @@ class MainApplication : public ewol::context::Application {
etk::String tmpppp = _context.getCmd().get(iii); etk::String tmpppp = _context.getCmd().get(iii);
if ( tmpppp == "-h" if ( tmpppp == "-h"
|| tmpppp == "--help") { || tmpppp == "--help") {
APPL_INFO(" --ctags=xxx c-flags-file-name" ); APPL_PRINT(" --ctags=xxx c-flags-file-name" );
APPL_INFO(" -h/--help display this help" ); APPL_PRINT(" -h/--help display this help" );
exit(0); exit(0);
} }
} }
@ -59,7 +61,7 @@ class MainApplication : public ewol::context::Application {
#endif #endif
// set the application icon ... // set the application icon ...
_context.setIcon("DATA:icon.png"); _context.setIcon("DATA:///icon.png");
APPL_INFO("==> CREATE ... " PROJECT_NAME " (END)"); APPL_INFO("==> CREATE ... " PROJECT_NAME " (END)");
} }
@ -101,7 +103,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 +110,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 +164,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

@ -11,23 +11,6 @@
#include <appl/Gui/MainWindows.hpp> #include <appl/Gui/MainWindows.hpp>
#include <ewol/object/Object.hpp> #include <ewol/object/Object.hpp>
// TODO : write it better
static void SortElementList(etk::Vector<appl::dataBufferStruct>& _list) {
etk::Vector<appl::dataBufferStruct> tmpList = _list;
_list.clear();
for(size_t iii=0; iii<tmpList.size(); iii++) {
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()) {
findPos = jjj+1;
}
}
//EWOL_DEBUG("position="<<findPos);
_list.insert(_list.begin()+findPos, tmpList[iii]);
}
}
appl::widget::BufferList::BufferList() : appl::widget::BufferList::BufferList() :
m_openOrderMode(false) { m_openOrderMode(false) {
addObjectType("appl::BufferList"); addObjectType("appl::BufferList");
@ -36,7 +19,7 @@ appl::widget::BufferList::BufferList() :
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::create(); m_bufferManager = appl::BufferManager::create();
// load color properties // load color properties
m_paintingProperties = appl::GlyphPainting::create("THEME:COLOR:bufferList.json"); m_paintingProperties = appl::GlyphPainting::create("THEME_COLOR:///bufferList.json");
// get all id properties ... // get all id properties ...
m_colorBackground1 = m_paintingProperties->request("backgroung1"); m_colorBackground1 = m_paintingProperties->request("backgroung1");
m_colorBackground2 = m_paintingProperties->request("backgroung2"); m_colorBackground2 = m_paintingProperties->request("backgroung2");
@ -47,7 +30,7 @@ appl::widget::BufferList::BufferList() :
void appl::widget::BufferList::init() { void appl::widget::BufferList::init() {
ewol::widget::List::init(); ewol::widget::List::init();
propertyHide.set(true); //propertyHide.set(true);
propertyCanFocus.set(true); propertyCanFocus.set(true);
if (m_bufferManager != null) { if (m_bufferManager != null) {
m_bufferManager->signalNewBuffer.connect(sharedFromThis(), &appl::widget::BufferList::onCallbackNewBuffer); m_bufferManager->signalNewBuffer.connect(sharedFromThis(), &appl::widget::BufferList::onCallbackNewBuffer);
@ -78,7 +61,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,21 +75,21 @@ 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 {
insertAlphabetic(tmp); insertAlphabetic(tmp);
} }
/*
if (m_list.size() <= 1) { if (m_list.size() <= 1) {
propertyHide.set(true); propertyHide.set(true);
propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "true"); propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "true");
@ -114,17 +97,18 @@ void appl::widget::BufferList::onCallbackNewBuffer(const etk::String& _value) {
propertyHide.set(false); propertyHide.set(false);
propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "false"); propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "false");
} }
*/
markToRedraw(); markToRedraw();
} }
// 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;
@ -150,7 +134,7 @@ void appl::widget::BufferList::onCallbackChangeName() {
} }
void appl::widget::BufferList::onCallbackBufferRemoved(const ememory::SharedPtr<appl::Buffer>& _buffer) { void appl::widget::BufferList::onCallbackBufferRemoved(const ememory::SharedPtr<appl::Buffer>& _buffer) {
APPL_ERROR("request remove buffer:"); APPL_DEBUG("request remove buffer:");
auto it = m_list.begin(); auto it = m_list.begin();
while (it != m_list.end()) { while (it != m_list.end()) {
if (it->m_buffer == _buffer) { if (it->m_buffer == _buffer) {
@ -160,11 +144,13 @@ void appl::widget::BufferList::onCallbackBufferRemoved(const ememory::SharedPtr<
++it; ++it;
} }
} }
/*
if (m_list.size() <= 1) { if (m_list.size() <= 1) {
propertyHide.set(true); propertyHide.set(true);
} else { } else {
propertyHide.set(false); propertyHide.set(false);
} }
*/
markToRedraw(); markToRedraw();
} }
void appl::widget::BufferList::onCallbackIsSave() { void appl::widget::BufferList::onCallbackIsSave() {
@ -185,7 +171,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) {
@ -194,7 +180,7 @@ fluorine::Variant appl::widget::BufferList::getData(int32_t _role, const ivec2&
return (*m_paintingProperties)[m_colorTextModify].getForeground(); return (*m_paintingProperties)[m_colorTextModify].getForeground();
} }
case ewol::widget::ListRole::BgColor: case ewol::widget::ListRole::BgColor:
APPL_ERROR( m_colorBackground1 << " => " << (*m_paintingProperties)[m_colorBackground1].getForeground()); APPL_VERBOSE( m_colorBackground1 << " => " << (*m_paintingProperties)[m_colorBackground1].getForeground());
if (m_selectedID == _pos.y()) { if (m_selectedID == _pos.y()) {
return (*m_paintingProperties)[m_colorBackgroundSelect].getForeground(); return (*m_paintingProperties)[m_colorBackgroundSelect].getForeground();
} }
@ -212,12 +198,12 @@ fluorine::Variant appl::widget::BufferList::getData(int32_t _role, const ivec2&
bool appl::widget::BufferList::onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) { bool appl::widget::BufferList::onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) {
if ( _event.getId() == 1 if ( _event.getId() == 1
&& _event.getStatus() == gale::key::status::pressSingle) { && _event.getStatus() == gale::key::status::pressSingle) {
APPL_INFO("Event on List: " << _event << " pos=" << _pos ); APPL_VERBOSE("Event on List: " << _event << " pos=" << _pos );
if( _pos.y() >= 0 if( _pos.y() >= 0
&& _pos.y() < (int64_t)m_list.size()) { && _pos.y() < (int64_t)m_list.size()) {
if (m_list[_pos.y()].m_buffer != null) { if (m_list[_pos.y()].m_buffer != null) {
if (m_bufferManager != null) { if (m_bufferManager != null) {
APPL_INFO("Select file: '" << m_list[_pos.y()].m_buffer->getFileName() << "' in list"); APPL_VERBOSE("Select file: '" << m_list[_pos.y()].m_buffer->getFileName() << "' in list");
m_bufferManager->open(m_list[_pos.y()].m_buffer->getFileName()); m_bufferManager->open(m_list[_pos.y()].m_buffer->getFileName());
} }
return true; return true;

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

@ -10,25 +10,14 @@
//#include <ColorizeManager.hpp> //#include <ColorizeManager.hpp>
#include <appl/Gui/MainWindows.hpp> #include <appl/Gui/MainWindows.hpp>
#include <ewol/object/Object.hpp> #include <ewol/object/Object.hpp>
#include <ewol/compositing/Image.hpp>
// TODO : write it better #include <etk/algorithm.hpp>
static void SortElementList(etk::Vector<appl::dataBufferStruct>& _list) {
etk::Vector<appl::dataBufferStruct> tmpList = _list;
_list.clear();
for(size_t iii=0; iii<tmpList.size(); iii++) {
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()) {
findPos = jjj+1;
}
}
//EWOL_DEBUG("position="<<findPos);
_list.insert(_list.begin()+findPos, tmpList[iii]);
}
}
appl::widget::BufferTree::BufferTree() : appl::widget::BufferTree::BufferTree() :
propertyShowUnNeeded(this, "show-un-needed",
true,
"show element that is not open",
&appl::widget::BufferTree::onChangePropertyShowUnNeeded),
m_openOrderMode(false) { m_openOrderMode(false) {
addObjectType("appl::BufferTree"); addObjectType("appl::BufferTree");
m_selectedID = -1; m_selectedID = -1;
@ -36,7 +25,7 @@ appl::widget::BufferTree::BufferTree() :
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::create(); m_bufferManager = appl::BufferManager::create();
// load color properties // load color properties
m_paintingProperties = appl::GlyphPainting::create("THEME:COLOR:bufferList.json"); m_paintingProperties = appl::GlyphPainting::create("THEME_COLOR:///bufferList.json");
// get all id properties ... // get all id properties ...
m_colorBackground1 = m_paintingProperties->request("backgroung1"); m_colorBackground1 = m_paintingProperties->request("backgroung1");
m_colorBackground2 = m_paintingProperties->request("backgroung2"); m_colorBackground2 = m_paintingProperties->request("backgroung2");
@ -53,21 +42,37 @@ 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);
} }
addComposeElemnent("image_folder", ememory::makeShared<ewol::compositing::Image>("THEME_GUI:///Folder.svg?lib=ewol"));
addComposeElemnent("image_file", ememory::makeShared<ewol::compositing::Image>("THEME_GUI:///File.svg?lib=ewol"));
} }
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) { etk::String left = _left.getString() + "/";
if (_left[iii] == _right[iii]) { etk::String right = _right.getString() + "/";
out += _left[iii]; APPL_VERBOSE("Common Part:");
APPL_VERBOSE(" _left = " << left);
APPL_VERBOSE(" _right = " << right);
for (size_t iii=0; iii < etk::min(left.size(), right.size()); ++iii) {
if (left[iii] == right[iii]) {
out += left[iii];
continue; continue;
} }
break; break;
} }
size_t pos = out.rfind('/');
if (pos != etk::String::npos) {
out = out.extract(0, pos);
}
if (out.isEmpty() == true) {
out = "/";
}
APPL_VERBOSE(" out = " << out);
return out; return out;
} }
@ -75,15 +80,18 @@ 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();
} }
static bool localSort(const etk::Path& _left, const etk::Path& _right) {
return _left.getString().toUpper() <= _right.getString().toUpper();
}
void appl::widget::BufferTree::populateNodeIfNeeded(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node) { void appl::widget::BufferTree::populateNodeIfNeeded(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node) {
if (_node == null) { if (_node == null) {
return; return;
@ -94,34 +102,74 @@ void appl::widget::BufferTree::populateNodeIfNeeded(ememory::SharedPtr<etk::Tree
return; return;
} }
if (_node->haveChild() == true) { if (_node->haveChild() == true) {
// already populated... // already populated... ==> updat list of elements: ...
etk::Vector<etk::Path> child = etk::path::list(value.m_path, etk::path::LIST_FOLDER|etk::path::LIST_FILE);
etk::algorithm::quickSort(child, localSort);
APPL_VERBOSE(" nbChilds: " << child.size() << " for path: " << value.m_path);
// Add missing element (at the end ...)
for (auto& it: child) {
bool find = false;
for (auto &nodeIt: _node->getChilds()) {
if (nodeIt->getData().m_path == it) {
find = true;
break;
}
}
if (find == false) {
auto elem = etk::TreeNode<appl::TreeElement>::create(TreeElement(it, false));
_node->addChild(elem);
}
}
// remove destroyed elements:
size_t iii = 0;
while (iii < _node->getChilds().size()) {
auto node = _node->getChilds()[iii];
bool find = false;
for (auto& it: child) {
if (node->getData().m_path == it) {
find = true;
break;
}
}
if (find == false) {
_node->rmChild(node);
} else {
++iii;
}
}
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, etk::path::LIST_FOLDER|etk::path::LIST_FILE);
APPL_ERROR(" nbChilds: " << child.size() << " for path: " << value.m_path); etk::algorithm::quickSort(child, localSort);
APPL_VERBOSE(" nbChilds: " << child.size() << " for path: " << value.m_path);
for (auto& it: child) { for (auto& it: child) {
APPL_ERROR("add element: " << *it); APPL_VERBOSE("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);
} }
} }
void appl::widget::BufferTree::goUpper() { void appl::widget::BufferTree::goUpper() {
APPL_ERROR("Go upper ..."); APPL_VERBOSE("Go upper ...");
if (m_tree == null) { if (m_tree == null) {
generateFlatTree(); generateFlatTree();
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)); if (path == m_tree->getData().m_path) {
APPL_ERROR("No more parent in upper ... '" << path << "'");
return;
}
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:
for (auto& it: treeElement->getChilds()) { for (auto& it: treeElement->getChilds()) {
if (it->getData().m_nodeName == m_tree->getData().m_nodeName) { if (it->getData().m_nodeName == m_tree->getData().m_nodeName) {
it = m_tree; it = m_tree;
it->setParent(treeElement);
break; break;
} }
} }
@ -131,18 +179,76 @@ void appl::widget::BufferTree::goUpper() {
updateFlatTree(); updateFlatTree();
} }
bool appl::widget::BufferTree::updateChildOpen(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node) {
if (_node == null) {
return false;
}
appl::TreeElement& value = _node->getData();
if (value.m_isFolder == false) {
// nothing to reset...
return value.m_buffer != null;
}
value.m_haveChildOpen = false;
for (auto& it: _node->getChilds()) {
if (updateChildOpen(it) == true) {
value.m_haveChildOpen = true;
}
}
return value.m_haveChildOpen;
}
void appl::widget::BufferTree::updateFlatTree() { void appl::widget::BufferTree::updateFlatTree() {
m_flatTree.setRoot(m_tree, // Enable parent with child open:
[&](const TreeElement& _value){ updateChildOpen(m_tree);
return true; // flat tree element enable
}, if (propertyShowUnNeeded.get() == false) {
[&](const TreeElement& _value){ m_flatTree.setRoot(m_tree,
return _value.m_isExpand; [&](const TreeElement& _value){
}); if ( _value.m_isFolder == true
&& _value.m_haveChildOpen == true) {
return true;
}
if ( _value.m_buffer != null) {
return true;
}
return false;
},
[&](const TreeElement& _value){
return _value.m_isExpand;
});
} else {
m_flatTree.setRoot(m_tree,
[&](const TreeElement& _value){
return true;
},
[&](const TreeElement& _value){
return _value.m_isExpand;
});
}
markToRedraw(); markToRedraw();
} }
void appl::widget::BufferTree::expandToPath(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node, const etk::Path& _path) {
if (_node == null) {
return;
}
appl::TreeElement& value = _node->getData();
if (value.m_isFolder == false) {
return;
}
if (_path.getString().startWith(value.m_path.getString() + "/") == false) {
return;
}
// force expand
value.m_isExpand = true;
populateNodeIfNeeded(_node);
for (auto& it: _node->getChilds()) {
expandToPath(it, _path);
}
}
appl::widget::BufferTree::~BufferTree() { appl::widget::BufferTree::~BufferTree() {
removeAllElement(); removeAllElement();
@ -163,8 +269,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,35 +280,50 @@ 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_DEBUG("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_DEBUG("Update: " << nodeName << " " << nodeName.getParent() << " root=" << upperParent);
} }
if (upperParent == "") { if (upperParent == "") {
APPL_ERROR("Nothing find ==> get home path..."); APPL_DEBUG("Nothing find ==> get home path...");
upperParent = etk::FSNodeGetHomePath(); upperParent = etk::path::getHomePath();
} }
APPL_ERROR("update tree: " << upperParent); APPL_DEBUG("update tree: " << upperParent);
return upperParent; return upperParent;
} }
void appl::widget::BufferTree::onNewBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) { void appl::widget::BufferTree::onNewBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) {
APPL_ERROR("New Buffer open: '" << _buffer->getFileName() << "'"); APPL_INFO("New Buffer open: '" << _buffer->getFileName() << "'");
ememory::SharedPtr<appl::Buffer> buffer = _buffer;
buffer->signalIsSave.connect(sharedFromThis(), &appl::widget::BufferTree::onCallbackIsSave);
buffer->signalIsModify.connect(sharedFromThis(), &appl::widget::BufferTree::onCallbackIsModify);
buffer->signalChangeName.connect(sharedFromThis(), &appl::widget::BufferTree::onCallbackChangeName);
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 ) { APPL_VERBOSE("=============================================================================================================");
goUpper(); APPL_VERBOSE("== file: " << _buffer->getFileName());
APPL_VERBOSE("== root: " << rootPath);
APPL_VERBOSE("== tree: " << m_tree->getData().m_path);
APPL_VERBOSE("=============================================================================================================");
if (rootPath.getString().startWith(m_tree->getData().m_path.getString()) == false) {
APPL_VERBOSE(" ==> not contained");
while ( rootPath != m_tree->getData().m_path
&& m_tree->getData().m_path.getString() != "/") {
APPL_VERBOSE("rootPath=" << rootPath << " != " << m_tree->getData().m_path);
goUpper();
}
} }
} }
expandToPath(m_tree, _buffer->getFileName());
auto listElements = m_tree->findIf([&](const etk::TreeNode<TreeElement>& _node) { auto listElements = m_tree->findIf([&](const etk::TreeNode<TreeElement>& _node) {
APPL_WARNING("Compare : '" << _node.getData().m_path << "' =?= '" << _buffer->getFileName() << "'"); APPL_VERBOSE("Compare : '" << _node.getData().m_path << "' =?= '" << _buffer->getFileName() << "'");
if (_node.getData().m_path == _buffer->getFileName()) { if (_node.getData().m_path == _buffer->getFileName()) {
return true; return true;
} }
@ -213,32 +334,7 @@ void appl::widget::BufferTree::onNewBuffer(const ememory::SharedPtr<appl::Buffer
} else { } else {
listElements[0]->getData().m_buffer = _buffer; listElements[0]->getData().m_buffer = _buffer;
} }
updateFlatTree(); updateFlatTree();
/*
ememory::SharedPtr<appl::Buffer> buffer = m_bufferManager->get(_value);
if (buffer == null) {
APPL_ERROR("event on element nor exist : " << _value);
return;
}
buffer->signalIsSave.connect(sharedFromThis(), &BufferTree::onCallbackIsSave);
buffer->signalIsModify.connect(sharedFromThis(), &BufferTree::onCallbackIsModify);
buffer->signalChangeName.connect(sharedFromThis(), &BufferTree::onCallbackChangeName);
appl::dataBufferStruct tmp(_value, buffer);
if (m_openOrderMode == true) {
m_list.pushBack(tmp);
} else {
insertAlphabetic(tmp);
}
if (m_list.size() <= 1) {
propertyHide.set(true);
propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "true");
} else {
propertyHide.set(false);
propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "false");
}
markToRedraw();
*/
} }
void appl::widget::BufferTree::onSelectBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) { void appl::widget::BufferTree::onSelectBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) {
@ -279,7 +375,7 @@ void appl::widget::BufferTree::onCallbackChangeName() {
} }
void appl::widget::BufferTree::onRemoveBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) { void appl::widget::BufferTree::onRemoveBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) {
APPL_ERROR("request remove buffer:"); APPL_DEBUG("request remove buffer:");
auto elem = m_tree->findIf([&](const etk::TreeNode<TreeElement>& _element) { auto elem = m_tree->findIf([&](const etk::TreeNode<TreeElement>& _element) {
if (_element.getData().m_buffer == _buffer) { if (_element.getData().m_buffer == _buffer) {
return true; return true;
@ -310,7 +406,7 @@ ivec2 appl::widget::BufferTree::getMatrixSize() const {
} }
void appl::widget::BufferTree::onItemExpandEvent(const ivec2& _pos) { void appl::widget::BufferTree::onItemExpandEvent(const ivec2& _pos) {
APPL_WARNING("Event on expand on " << _pos); APPL_DEBUG("Event on expand on " << _pos);
m_flatTree[_pos.y()]->getData().m_isExpand = m_flatTree[_pos.y()]->getData().m_isExpand?false:true; m_flatTree[_pos.y()]->getData().m_isExpand = m_flatTree[_pos.y()]->getData().m_isExpand?false:true;
updateFlatTree(); updateFlatTree();
} }
@ -322,8 +418,12 @@ fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2&
case ewol::widget::ListRole::Text: case ewol::widget::ListRole::Text:
return value.m_nodeName; return value.m_nodeName;
case ewol::widget::ListRole::FgColor: case ewol::widget::ListRole::FgColor:
// Folder with child open element
if (value.m_haveChildOpen == true) {
return (*m_paintingProperties)[m_colorTextNormal].getForeground();
}
if (value.m_buffer == null) { if (value.m_buffer == null) {
//APPL_ERROR( m_colorBackgroundHide << " => " << (*m_paintingProperties)[m_colorBackgroundHide].getForeground()); APPL_VERBOSE( m_colorBackgroundHide << " => " << (*m_paintingProperties)[m_colorBackgroundHide].getForeground());
return (*m_paintingProperties)[m_colorTextNotOpen].getForeground(); return (*m_paintingProperties)[m_colorTextNotOpen].getForeground();
} }
if (value.m_buffer->isModify() == false) { if (value.m_buffer->isModify() == false) {
@ -332,7 +432,11 @@ fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2&
return (*m_paintingProperties)[m_colorTextModify].getForeground(); return (*m_paintingProperties)[m_colorTextModify].getForeground();
case ewol::widget::ListRole::BgColor: case ewol::widget::ListRole::BgColor:
//return fluorine::Variant(); //return fluorine::Variant();
//APPL_ERROR( m_colorBackground1 << " => " << (*m_paintingProperties)[m_colorBackground1].getForeground()); APPL_VERBOSE( m_colorBackground1 << " => " << (*m_paintingProperties)[m_colorBackground1].getForeground());
if ( value.m_buffer == m_selection
&& m_selection != null) {
return (*m_paintingProperties)[m_colorBackgroundSelect].getForeground();
}
if (_pos.y() % 2) { if (_pos.y() % 2) {
return (*m_paintingProperties)[m_colorBackground1].getForeground(); return (*m_paintingProperties)[m_colorBackground1].getForeground();
} }
@ -340,19 +444,22 @@ fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2&
case ewol::widget::ListRole::Icon: case ewol::widget::ListRole::Icon:
/* /*
if (elem->countToRoot() == 0) { if (elem->countToRoot() == 0) {
return "{ewol}THEME:GUI:Home.svg"; return "THEME_GUI:///Home.svg?lib=ewol";
}*/ }*/
if (value.m_isFolder == true) { if (value.m_isFolder == true) {
return "{ewol}THEME:GUI:Folder.svg"; return "image_folder";
} else { } else {
return "{ewol}THEME:GUI:File.svg"; return "image_file";
} }
return ""; return "";
case ewol::widget::ListRole::DistanceToRoot: case ewol::widget::ListRole::DistanceToRoot:
return uint_t(elem->countToRoot()); return uint_t(elem->countToRoot());
case ewol::widget::ListRole::HaveChild: case ewol::widget::ListRole::HaveChild:
return elem->haveChild(); if (elem->haveChild() == true) {
return true;
}
return value.m_haveChild;
case ewol::widget::ListRole::IsExpand: case ewol::widget::ListRole::IsExpand:
return value.m_isExpand; return value.m_isExpand;
case ewol::widget::ListRole::IsSelected: case ewol::widget::ListRole::IsSelected:
@ -380,14 +487,21 @@ bool appl::widget::BufferTree::onItemEvent(const ewol::event::Input& _event, con
updateFlatTree(); updateFlatTree();
return true; return true;
} else if (value.m_buffer == null) { } else if (value.m_buffer == null) {
// TODO: Open the file... if (m_bufferManager != null) {
APPL_VERBOSE("Select file: '" << value.m_path << "' in list");
m_bufferManager->open(value.m_path);
value.m_buffer = m_bufferManager->get(value.m_path);
}
return true; return true;
} }
} }
if (_event.getStatus() == gale::key::status::pressSingle) { if (_event.getStatus() == gale::key::status::pressSingle) {
APPL_INFO("Event on List: " << _event << " pos=" << _pos ); APPL_VERBOSE("Event on List: " << _event << " pos=" << _pos );
if (value.m_buffer != null) { if (value.m_buffer != null) {
// TODO: Display the current buffer... if (m_bufferManager != null) {
APPL_VERBOSE("Select file: '" << value.m_path << "' in list");
m_bufferManager->open(value.m_path);
}
return true; return true;
} }
} }
@ -407,4 +521,7 @@ bool appl::widget::BufferTree::onItemEvent(const ewol::event::Input& _event, con
return false; return false;
} }
void appl::widget::BufferTree::onChangePropertyShowUnNeeded() {
updateFlatTree();
markToRedraw();
}

View File

@ -11,22 +11,25 @@
#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) {
m_haveChild = etk::path::haveChild(_path);
} }
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;
bool m_haveChildOpen = false;
bool m_haveChild = false;
ememory::SharedPtr<appl::Buffer> m_buffer; ememory::SharedPtr<appl::Buffer> m_buffer;
bool m_isSelected = false; bool m_isSelected = false;
bool m_isExpand = false; bool m_isExpand = false;
@ -38,6 +41,8 @@ namespace appl {
using BufferTreeWeak = ememory::WeakPtr<BufferTree>; using BufferTreeWeak = ememory::WeakPtr<BufferTree>;
class BufferTree : public ewol::widget::TreeView { class BufferTree : public ewol::widget::TreeView {
public:
eproperty::Value<bool> propertyShowUnNeeded; //!< Size of the icon.
private: private:
ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
private: private:
@ -54,8 +59,11 @@ namespace appl {
int32_t m_selectedID; int32_t m_selectedID;
void updateFlatTree(); void updateFlatTree();
void generateFlatTree(); void generateFlatTree();
etk::String getRootPath(); // Recursive update of the child opening or not
bool updateChildOpen(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node);
etk::Path getRootPath();
void populateNodeIfNeeded(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node); void populateNodeIfNeeded(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node);
void expandToPath(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node, const etk::Path& _path);
void goUpper(); void goUpper();
ememory::SharedPtr<etk::TreeNode<TreeElement>> m_tree; ememory::SharedPtr<etk::TreeNode<TreeElement>> m_tree;
etk::FlatTree<TreeElement> m_flatTree; etk::FlatTree<TreeElement> m_flatTree;
@ -86,6 +94,7 @@ namespace appl {
void onSelectBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer); void onSelectBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer);
void onRemoveBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer); void onRemoveBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer);
void calculateMinMaxSize() override; void calculateMinMaxSize() override;
void onChangePropertyShowUnNeeded();
}; };
} }
} }