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"?>
<sizer mode="hori" expand="true,false" fill="true" lock="true">
<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>
<entry name="[{ID}]SEARCH:search-entry" expand="true" fill="true"/>
<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>
<entry name="[{ID}]SEARCH:replace-entry" expand="true" fill="true"/>
<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 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="{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="THEME_GUI:///CaseSensitive.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
</button>
<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="{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="THEME_GUI:///WrapAround.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
</button>
<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="{ewol}THEME:GUI:Down.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="THEME_GUI:///Down.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
</button>
</sizer>

View File

@ -34,15 +34,19 @@
</rule>
<rule name="Résultat OK">
<color>TestResultOK</color>
<regex>\[( )*(OK|Ok|ok)( )*\]</regex>
<regex>\[(\t| )*(OK|Ok|ok|DONE|Done|done)(\t| )*\]</regex>
</rule>
<rule name="resultat en erreur">
<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 name="resultat vide">
<color>number</color>
<regex>\[( )*\]</regex>
<regex>\[(\t| )*\]</regex>
</rule>
<rule name="notes ... ">
<color>macro</color>

View File

@ -90,7 +90,11 @@
</rule>
<rule name="etk type">
<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 name="my storage keyword">
<color>storageKeyword</color>
@ -98,7 +102,7 @@
</rule>
<rule name="my common Define">
<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 name="numeric constant">
<color>number</color>

View File

@ -18,19 +18,19 @@
</rule>
<rule name="documantation">
<color>commentDoxygen</color>
<regex>#.*</regex>
<regex>#.*$</regex>
<sub>docparse</sub>
</rule>
<rule name="inline comment">
<color>comment</color>
<regex>//.*</regex>
<regex>//.*$</regex>
<sub>TODO</sub>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="my type">
<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 name="numeric constant">
<color>number</color>

View File

@ -29,7 +29,8 @@
{ name:"functionName", foreground:"#09857e", bold:true},
{ name:"functionNamePrivate", foreground:"#09854e", 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", foreground:"#dc3700", bold:true, italic:false},

View File

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

View File

@ -5,6 +5,9 @@
*/
#include <etk/types.hpp>
#include <etk/stdTools.hpp>
#include <etk/system.hpp>
#include <etk/path/fileSystem.hpp>
#include <appl/Buffer.hpp>
#include <appl/debug.hpp>
#include <gale/context/clipBoard.hpp>
@ -108,6 +111,7 @@ appl::Buffer::Iterator appl::Buffer::selectStop() {
}
appl::Buffer::Buffer() :
signalFileIsModify(this, "file-is-modify", ""),
signalIsModify(this, "is-modify", ""),
signalIsSave(this, "is-save", ""),
signalSelectChange(this, "select-change", ""),
@ -122,7 +126,7 @@ appl::Buffer::Buffer() :
m_highlight(null) {
addObjectType("appl::Buffer");
static int32_t bufferBaseId = 0;
m_fileName = etk::FSNode("REL:No Name " + etk::toString(bufferBaseId)).getFileSystemName();
m_fileName = "No Name " + etk::toString(bufferBaseId);
bufferBaseId++;
}
@ -134,34 +138,30 @@ appl::Buffer::~Buffer() {
APPL_ERROR("REAL remove buffer : '" << propertyName << "'");
}
bool appl::Buffer::loadFile(const etk::String& _name) {
bool appl::Buffer::loadFile(const etk::Path& _name) {
APPL_DEBUG("Convert filename :'" << _name << "'");
etk::FSNode file(_name);
etk::String name = file.getName();
APPL_INFO("Load file : '" << name << "'");
m_fileName = file.getFileSystemName();
m_fileName = _name;
m_hasFileName = true;
m_isModify = true;
m_cursorPos = 0;
setHighlightType("");
m_nbLines = 0;
if (m_data.dumpFrom(m_fileName) == true ) {
if (m_data.dumpFrom(_name) == true ) {
countNumberofLine();
tryFindHighlightType();
m_isModify = false;
m_fileIsModify = false;
return true;
}
return false;
}
void appl::Buffer::setFileName(const etk::String& _name) {
void appl::Buffer::setFileName(const etk::Path& _name) {
APPL_DEBUG("Convert filename :'" << _name << "'");
etk::FSNode file(_name);
etk::String name = file.getName();
if (m_fileName == file.getFileSystemName()) {
if (m_fileName == _name) {
return;
}
m_fileName = file.getFileSystemName();
m_fileName = _name;
m_hasFileName = true;
signalChangeName.emit();
setModification(true);
@ -170,6 +170,31 @@ void appl::Buffer::setFileName(const etk::String& _name) {
bool appl::Buffer::storeFile() {
if (m_data.dumpIn(m_fileName) == true) {
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);
return true;
}
@ -675,8 +700,7 @@ void appl::Buffer::removeSelection() {
}
void appl::Buffer::tryFindHighlightType() {
etk::FSNode file(m_fileName);
etk::String type = appl::highlightManager::getTypeFile(file.getNameFile());
etk::String type = appl::highlightManager::getTypeFile(m_fileName.getFileName());
if (type.size() == 0) {
return;
}
@ -1013,7 +1037,7 @@ uint32_t appl::Buffer::getCursorLinesId() {
namespace etk {
template<> etk::String toString<ememory::SharedPtr<appl::Buffer>>(const ememory::SharedPtr<appl::Buffer>& _obj) {
if (_obj != null) {
return _obj->getFileName();
return _obj->getFileName().getString();
}
return "";
}
@ -1032,7 +1056,7 @@ namespace etk {
return from_string(_variableRet, etk::toString(_value));
}
template<> etk::String toString<appl::Buffer>(const appl::Buffer& _obj) {
return _obj.getFileName();
return _obj.getFileName().getString();
}
template<> etk::UString toUString<appl::Buffer>(const appl::Buffer& _obj) {
return etk::toUString(etk::toString(_obj));

View File

@ -6,7 +6,6 @@
#pragma once
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <ewol/ewol.hpp>
#include <etk/Buffer.hpp>
#include <ewol/object/Object.hpp>
@ -288,6 +287,7 @@ namespace appl {
friend class Buffer;
};
public: // signals
esignal::Signal<> signalFileIsModify;
esignal::Signal<> signalIsModify;
esignal::Signal<> signalIsSave;
esignal::Signal<> signalSelectChange;
@ -299,13 +299,22 @@ namespace appl {
DECLARE_FACTORY(Buffer);
virtual ~Buffer();
private:
bool m_hasFileName; //!< When new file, the buffer has no name ==> but it might be reference with a single name ...
etk::String m_fileName; //!< name of the file (with his path)
bool m_fileIsModify = false; //!< The file has been modify and the buffer is not synchronous
public:
/**
* @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;
}
/**
@ -320,12 +329,12 @@ namespace appl {
* @param[in] _name name of the file.
* @return true if file corectly opened.
*/
bool loadFile(const etk::String& _name);
bool loadFile(const etk::Path& _name);
/**
* @brief Set a file name at this buffer (no saving ...)
* @param[in] _name name of the file.
*/
void setFileName(const etk::String& _name);
void setFileName(const etk::Path& _name);
/**
* @brief save the file in the specify path.
* @return true is saving well done

View File

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

View File

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

View File

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

View File

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

View File

@ -99,8 +99,6 @@ void MainWindows::init() {
ewol::widget::SizerShared mySizerHori;
ememory::SharedPtr<appl::TextViewer> myTextView;
ememory::SharedPtr<appl::TextViewer> myTextView2;
appl::widget::BufferListShared myBufferList;
appl::widget::BufferTreeShared myBufferTree;
ewol::widget::MenuShared myMenu;
// load buffer manager:
@ -115,28 +113,30 @@ void MainWindows::init() {
mySizerHori->propertyName.set("plop 222222222");
mySizerHori->propertyMode.set(ewol::widget::Sizer::modeHori);
mySizerVert->subWidgetAdd(mySizerHori);
if (false) {
myBufferList = appl::widget::BufferList::create();
myBufferList->propertyName.set("plop 3333333");
myBufferList->propertyExpand.set(bvec2(false,true));
myBufferList->propertyFill.set(bvec2(true,true));
//myBufferList->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel));
mySizerHori->subWidgetAdd(myBufferList);
} else {
myBufferTree = appl::widget::BufferTree::create();
myBufferTree->propertyName.set("plop 3333333");
myBufferTree->propertyExpand.set(bvec2(false,true));
myBufferTree->propertyFill.set(bvec2(true,true));
myBufferTree->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel));
mySizerHori->subWidgetAdd(myBufferTree);
}
m_viewBuffer = appl::widget::BufferList::create();
m_viewBuffer->propertyHide.set(true);
m_viewBuffer->propertyName.set("appl-buffer-view");
m_viewBuffer->propertyExpand.set(bvec2(false,true));
m_viewBuffer->propertyFill.set(bvec2(true,true));
//m_viewBuffer->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel));
mySizerHori->subWidgetAdd(m_viewBuffer);
m_viewTree = appl::widget::BufferTree::create();
m_viewTree->propertyName.set("appl-tree-view");
//m_viewTree->propertyHide.set(true);
m_viewTree->propertyExpand.set(bvec2(false,true));
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();
mySpacer->propertyName.set("appl-Buffer-viewer-separator");
mySpacer->propertyColor.set(etk::color::black);
mySpacer->propertyMinSize.set(gale::Dimension(vec2(2,2), gale::distance::pixel));
mySpacer->propertyExpand.set(bvec2(false,true));
mySpacer->propertyFill.set(bvec2(true,true));
mySpacer->propertyHide.set(true);
//mySpacer->propertyHide.set(true);
mySizerHori->subWidgetAdd(mySpacer);
mySizerVert2 = ewol::widget::Sizer::create();
@ -188,27 +188,32 @@ void MainWindows::init() {
int32_t idMenuFile = myMenu->addTitle("_T{File}");
myMenu->add(idMenuFile, "_T{New}", "", "menu:new");
myMenu->addSpacer(idMenuFile);
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{Open}", "THEME_GUI:///Load.svg", "menu:open");
myMenu->add(idMenuFile, "_T{Close}", "THEME_GUI:///Close.svg", "menu:close");
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->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->add(idMenuFile, "_T{Exit}", "", "menu:exit");
int32_t idMenuEdit = myMenu->addTitle("_T{Edit}");
myMenu->add(idMenuEdit, "_T{Goto line ...}","", "menu:goto-line");
myMenu->addSpacer();
int32_t idMenuSearch = myMenu->addTitle("_T{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{Search}", "THEME_GUI:///Search.svg", "menu:search");
myMenu->add(idMenuSearch, "_T{Replace}", "THEME_GUI:///Replace.svg", "menu:replace");
myMenu->addSpacer(idMenuSearch);
myMenu->add(idMenuSearch, "_T{Find (previous)}","", "menu:find:previous");
myMenu->add(idMenuSearch, "_T{Find (next)}", "", "menu:find:next");
myMenu->add(idMenuSearch, "_T{Find (all)}", "", "menu:find:all");
myMenu->add(idMenuSearch, "_T{Un-Select}", "", "menu:find:none");
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 White}", "", "menu:color:color/white/");
myMenu->add(idMenugDisplay, "_T{Shape square}", "", "menu:shape:shape/square/");
@ -229,6 +234,8 @@ void MainWindows::init() {
mySizerHori->subWidgetAdd(m_widgetLabelFileName);
// add generic shortcut ...
shortCutAdd("ctrl+b", "menu:view:toggle");
shortCutAdd("ctrl+o", "menu:open");
shortCutAdd("ctrl+n", "menu:new");
@ -241,7 +248,7 @@ void MainWindows::init() {
shortCutAdd("ctrl+l", "menu:goto-line");
shortCutAdd("ctrl+f", "menu:search");
shortCutAdd("F12", "menu:reloade-shader");
shortCutAdd("alt+F12", "menu:reloade-shader");
shortCutAdd("alt+F4", "menu:exit");
// TODO : auto-connect on shortcut event ==> maybe do beter later ...
signalShortcut.connect(sharedFromThis(), &MainWindows::onCallbackShortCut);
@ -321,6 +328,19 @@ void MainWindows::onCallbackMenuEvent(const etk::String& _value) {
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") {
APPL_TODO("Event from Menu : " << _value);
} else if (_value == "menu:find:next") {
@ -331,14 +351,14 @@ void MainWindows::onCallbackMenuEvent(const etk::String& _value) {
APPL_TODO("Event from Menu : " << _value);
} else if ( _value == "menu:color:color/black/"
|| _value == "menu:color:color/white/") {
etk::theme::setName("COLOR", etk::String(_value, 11));
EWOL_TODO("etk::theme::setName(\"COLOR\", etk::String(_value, 11));");
EWOL_ERROR("Select Shape or Color : 'COLOR'='" << etk::String(_value, 11) << "'");
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else if ( _value == "menu:shape:shape/square/"
|| _value == "menu:shape:shape/round/") {
EWOL_ERROR("Select Shape or Color : 'GUI'='" << etk::String(_value, 11) << "'");
etk::theme::setName("GUI", etk::String(_value, 11));
EWOL_TODO("etk::theme::setName(\"GUI\", etk::String(_value, 11));");
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else if (_value == "menu:reloadShape") {
@ -425,8 +445,7 @@ void MainWindows::displayOpen() {
// Get a ref on the buffer selected (if null, no buffer was selected ...)
ememory::SharedPtr<appl::Buffer> tmpBuffer = m_bufferManager->getBufferSelected();
if (tmpBuffer != null) {
etk::FSNode tmpFile = tmpBuffer->getFileName();
tmpWidget->propertyPath.set(tmpFile.getNameFolder());
tmpWidget->propertyPath.set(tmpBuffer->getFileName().getParent());
}
// apply widget pop-up ...
popUpWidgetPush(tmpWidget);
@ -467,8 +486,8 @@ void MainWindows::displayProperty() {
#endif
}
void MainWindows::onCallbackselectNewFile(const etk::String& _value) {
APPL_INFO("onCallbackselectNewFile(" << _value << ")");
void MainWindows::onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _value) {
APPL_INFO("onCallbackselectNewFile( ... )");
if (m_bufferManager == null) {
APPL_ERROR("can not call unexistant buffer manager ... ");
return;
@ -477,15 +496,15 @@ void MainWindows::onCallbackselectNewFile(const etk::String& _value) {
m_connectionModify.disconnect();
m_connectionSaveName.disconnect();
onCallbackTitleUpdate();
ememory::SharedPtr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp != null) {
m_connectionSave = tmpp->signalIsSave.connect(this, &MainWindows::onCallbackTitleUpdate);
m_connectionModify = tmpp->signalIsModify.connect(this, &MainWindows::onCallbackTitleUpdate);
m_connectionSaveName = tmpp->signalChangeName.connect(this, &MainWindows::onCallbackTitleUpdate);
if (_value != null) {
ememory::SharedPtr<appl::Buffer> tmp = _value;
m_connectionSave = tmp->signalIsSave.connect(this, &MainWindows::onCallbackTitleUpdate);
m_connectionModify = tmp->signalIsModify.connect(this, &MainWindows::onCallbackTitleUpdate);
m_connectionSaveName = tmp->signalChangeName.connect(this, &MainWindows::onCallbackTitleUpdate);
}
}
void MainWindows::onCallbackPopUpFileSelected(const etk::String& _value) {
void MainWindows::onCallbackPopUpFileSelected(const etk::Path& _value) {
APPL_INFO("onCallbackPopUpFileSelected(" << _value << ")");
APPL_DEBUG("Request opening the file : " << _value);
m_bufferManager->open(_value);
@ -505,10 +524,9 @@ void MainWindows::onCallbackTitleUpdate() {
m_widgetLabelFileName->propertyValue.set("");
}
} else {
etk::String nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName();
propertyTitle.set(etk::String("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem);
propertyTitle.set(etk::String("Edn : ") + (tmpp->isModify()==true?" *":"") + tmpp->getFileName().getString());
if (m_widgetLabelFileName != null) {
m_widgetLabelFileName->propertyValue.set(nameFileSystem + (tmpp->isModify()==true?" *":""));
m_widgetLabelFileName->propertyValue.set(tmpp->getFileName().getString() + (tmpp->isModify()==true?" *":""));
}
}
}
@ -532,7 +550,7 @@ void MainWindows::closeNotSavedFile(const ememory::SharedPtr<appl::Buffer>& _buf
return;
}
tmpPopUp->propertyTitle.set("<bold>_T{Close un-saved file:}</bold>");
tmpPopUp->propertyComment.set("_T{The file named:} <i>\"" + _buffer->getFileName() + "\"</i> _T{is curently modify.} <br/>_T{If you don't saves these modifications,<br/>they will be definitly lost...}");
tmpPopUp->propertyComment.set("_T{The file named:} <i>\"" + _buffer->getFileName().getString() + "\"</i> _T{is curently modify.} <br/>_T{If you don't saves these modifications,<br/>they will be definitly lost...}");
ememory::SharedPtr<ewol::widget::Button> bt = null;
if (_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("_T{Save}", true);

View File

@ -14,10 +14,13 @@
#include <appl/BufferManager.hpp>
#include <appl/Gui/Search.hpp>
#include <appl/Gui/ViewerManager.hpp>
class MainWindows : public ewol::widget::Windows {
private:
ewol::widget::LabelShared m_widgetLabelFileName;
appl::widget::SearchShared m_widgetSearch;
ewol::WidgetShared m_viewTree;
ewol::WidgetShared m_viewBuffer;
esignal::Connection m_connectionSave;
esignal::Connection m_connectionModify;
esignal::Connection m_connectionSaveName;
@ -44,11 +47,11 @@ class MainWindows : public ewol::widget::Windows {
void displayOpen();
void displayProperty();
private:
void onCallbackPopUpFileSelected(const etk::String& _value);
void onCallbackPopUpFileSelected(const etk::Path& _value);
void onCallbackTitleUpdate();
void onCallbackMenuEvent(const etk::String& _value);
void onCallbackShortCut(const etk::String& _value);
void onCallbackselectNewFile(const etk::String& _value);
void onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _value);
};

View File

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

View File

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

View File

@ -49,13 +49,13 @@ void appl::TagFileSelection::init() {
" <spacer expand='true,false'/>\n"
" <button name='PLUGIN-CTAGS-jump' expand='false' fill='true'>"
" <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"
" </sizer>\n"
" </button>\n"
" <button name='PLUGIN-CTAGS-cancel' expand='false' fill='true'>"
" <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"
" </sizer>\n"
" </button>\n"
@ -91,8 +91,8 @@ appl::TagFileSelection::~TagFileSelection() {
}
void appl::TagFileSelection::onCallbackCtagsSelection() {
if (m_eventNamed != "") {
signalSelect.emit(m_eventNamed);
if (m_eventLine != -1) {
signalSelect.emit(m_eventPath, m_eventLine);
// == > Auto remove ...
autoDestroy();
}
@ -104,18 +104,20 @@ void appl::TagFileSelection::onCallbackCtagsCancel() {
autoDestroy();
}
void appl::TagFileSelection::onCallbackCtagsListValidate(const etk::String& _value) {
signalSelect.emit(_value);
void appl::TagFileSelection::onCallbackCtagsListValidate(const etk::Path& _path, const int32_t& _line) {
signalSelect.emit(_path, _line);
// == > Auto remove ...
autoDestroy();
}
void appl::TagFileSelection::onCallbackCtagsListSelect(const etk::String& _value) {
m_eventNamed = _value;
void appl::TagFileSelection::onCallbackCtagsListSelect(const etk::Path& _path, const int32_t& _line) {
m_eventPath = _path;
m_eventLine = _line;
}
void appl::TagFileSelection::onCallbackCtagsListUnSelect() {
m_eventNamed = "";
m_eventPath = "";
m_eventLine = -1;
}
@ -125,7 +127,7 @@ void appl::TagFileSelection::onCallbackCtagsListUnSelect() {
* @param[in] file Compleate file name
* @param[in] jump line id
*/
void appl::TagFileSelection::addCtagsNewItem(etk::String _file, int32_t _line) {
void appl::TagFileSelection::addCtagsNewItem(etk::Path _file, int32_t _line) {
if (m_listTag != null) {
m_listTag->add(_file, _line);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,8 +24,8 @@ void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) {
if (menu != null) {
m_menuIdTitle = menu->addTitle("_T{Edit}");
if (m_menuIdTitle != -1) {
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_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");
}
}
// add event :

View File

@ -12,6 +12,7 @@ namespace appl {
};
#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_ERROR(data) APPL_BASE(2, data)
#define APPL_WARNING(data) APPL_BASE(3, data)

View File

@ -8,10 +8,10 @@
#include <ewol/object/Object.hpp>
#include <ewol/context/Context.hpp>
#include <gale/resource/Manager.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/theme/theme.hpp>
#include <ejson/ejson.hpp>
static etk::String g_baseDBName = "USERDATA:genericConfig.json";
static etk::Uri g_baseDBName = "USER_DATA:///genericConfig.json";
class myParamGlobal : public ewol::Object {
@ -137,7 +137,7 @@ globals::ParameterGlobalsGui::ParameterGlobalsGui() {
void globals::ParameterGlobalsGui::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:display-space-char", "value", etk::toString(isSetDisplaySpaceChar()));

View File

@ -10,8 +10,9 @@
#include <appl/debug.hpp>
#include <appl/global.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/tool.hpp>
#include <etk/path/fileSystem.hpp>
#include <etk/theme/theme.hpp>
#include <unistd.h>
//#include <ewol/config.hpp>
#include <gale/context/commandLine.hpp>
@ -25,6 +26,7 @@
#include <appl/ctags/readtags.hpp>
#include <appl/globalMsg.hpp>
#include <appl/TextPluginCtags.hpp>
#include <appl/debug.hpp>
class MainApplication : public ewol::context::Application {
private:
@ -37,8 +39,8 @@ class MainApplication : public ewol::context::Application {
etk::String tmpppp = _context.getCmd().get(iii);
if ( tmpppp == "-h"
|| tmpppp == "--help") {
APPL_INFO(" --ctags=xxx c-flags-file-name" );
APPL_INFO(" -h/--help display this help" );
APPL_PRINT(" --ctags=xxx c-flags-file-name" );
APPL_PRINT(" -h/--help display this help" );
exit(0);
}
}
@ -59,7 +61,7 @@ class MainApplication : public ewol::context::Application {
#endif
// set the application icon ...
_context.setIcon("DATA:icon.png");
_context.setIcon("DATA:///icon.png");
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++) {
etk::String tmpppp = _context.getCmd().get(iii);
if (tmpppp.startWith("--ctags=") == true) {
etk::FSNode file(tmpppp);
etk::String name = tmpppp.extract(8);
APPL_INFO("Load ctag file : \"" << name << "\"" );
appl::setCtagsFileName(name);
@ -109,19 +110,16 @@ class MainApplication : public ewol::context::Application {
|| tmpppp == "--help") {
// nothing to do ...
} else {
etk::FSNode file(tmpppp);
if (file.getNodeType() == etk::typeNode_file) {
etk::String name = file.getName();
APPL_INFO("need load file : \"" << name << "\"" );
m_bufferManager->open(name);
} else if (file.getNodeType() == etk::typeNode_folder) {
etk::Vector<etk::String> listOfFiles = file.folderGetSub(false, true, ".*");
etk::Path file(tmpppp);
if (etk::path::isFile(file) == true) {
APPL_INFO("need load file : \"" << file << "\"" );
m_bufferManager->open(file);
} else if (etk::path::isDirectory(file) == true) {
etk::Vector<etk::Path> listOfFiles = etk::path::list(file, etk::path::LIST_FILE);
for (auto &it: listOfFiles) {
etk::FSNode file2(it);
if (file2.getNodeType() == etk::typeNode_file) {
etk::String name = file2.getName();
APPL_INFO("need load file : \"" << name << "\"" );
m_bufferManager->open(name);
if (etk::path::isFile(it) == true) {
APPL_INFO("need load file : \"" << it << "\"" );
m_bufferManager->open(it);
}
}
}
@ -166,7 +164,6 @@ int main(int _argc, const char *_argv[]) {
for( int32_t iii=0 ; iii<_argc; iii++) {
etk::String tmpppp = _argv[iii];
if (tmpppp.startWith("--ctags=") == true) {
etk::FSNode file(tmpppp);
etk::String name = tmpppp.extract(8);
APPL_INFO("Load ctag file : \"" << name << "\"" );
appl::setCtagsFileName(name);

View File

@ -11,23 +11,6 @@
#include <appl/Gui/MainWindows.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() :
m_openOrderMode(false) {
addObjectType("appl::BufferList");
@ -36,7 +19,7 @@ appl::widget::BufferList::BufferList() :
// load buffer manager:
m_bufferManager = appl::BufferManager::create();
// 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 ...
m_colorBackground1 = m_paintingProperties->request("backgroung1");
m_colorBackground2 = m_paintingProperties->request("backgroung2");
@ -47,7 +30,7 @@ appl::widget::BufferList::BufferList() :
void appl::widget::BufferList::init() {
ewol::widget::List::init();
propertyHide.set(true);
//propertyHide.set(true);
propertyCanFocus.set(true);
if (m_bufferManager != null) {
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) {
// alphabetical order:
for (size_t iii = 0; iii < m_list.size(); ++iii) {
if (m_list[iii].m_bufferName.getNameFile().toLower() > _dataStruct.m_bufferName.getNameFile().toLower()) {
if (m_list[iii].m_bufferName.getFileName().toLower() > _dataStruct.m_bufferName.getFileName().toLower()) {
m_list.insert(m_list.begin() + iii, _dataStruct);
if (_selectNewPosition == true) {
m_selectedID = iii;
@ -92,21 +75,21 @@ void appl::widget::BufferList::insertAlphabetic(const appl::dataBufferStruct& _d
}
}
void appl::widget::BufferList::onCallbackNewBuffer(const etk::String& _value) {
ememory::SharedPtr<appl::Buffer> buffer = m_bufferManager->get(_value);
if (buffer == null) {
APPL_ERROR("event on element nor exist : " << _value);
void appl::widget::BufferList::onCallbackNewBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) {
if (_buffer == null) {
return;
}
ememory::SharedPtr<appl::Buffer> buffer = _buffer;
buffer->signalIsSave.connect(sharedFromThis(), &BufferList::onCallbackIsSave);
buffer->signalIsModify.connect(sharedFromThis(), &BufferList::onCallbackIsModify);
buffer->signalChangeName.connect(sharedFromThis(), &BufferList::onCallbackChangeName);
appl::dataBufferStruct tmp(_value, buffer);
appl::dataBufferStruct tmp(_buffer->getFileName(), _buffer);
if (m_openOrderMode == true) {
m_list.pushBack(tmp);
} else {
insertAlphabetic(tmp);
}
/*
if (m_list.size() <= 1) {
propertyHide.set(true);
propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "true");
@ -114,17 +97,18 @@ void appl::widget::BufferList::onCallbackNewBuffer(const etk::String& _value) {
propertyHide.set(false);
propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "false");
}
*/
markToRedraw();
}
// TODO : Review this callback with the real shared_ptr on the buffer ...
void appl::widget::BufferList::onCallbackselectNewFile(const etk::String& _value) {
void appl::widget::BufferList::onCallbackselectNewFile(const ememory::SharedPtr<appl::Buffer>& _buffer) {
m_selectedID = -1;
for (size_t iii=0; iii<m_list.size(); iii++) {
if (m_list[iii].m_buffer == null) {
continue;
}
if (m_list[iii].m_buffer->getFileName() != _value) {
if (m_list[iii].m_buffer != _buffer) {
continue;
}
m_selectedID = iii;
@ -150,7 +134,7 @@ void appl::widget::BufferList::onCallbackChangeName() {
}
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();
while (it != m_list.end()) {
if (it->m_buffer == _buffer) {
@ -160,11 +144,13 @@ void appl::widget::BufferList::onCallbackBufferRemoved(const ememory::SharedPtr<
++it;
}
}
/*
if (m_list.size() <= 1) {
propertyHide.set(true);
} else {
propertyHide.set(false);
}
*/
markToRedraw();
}
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) {
switch (_role) {
case ewol::widget::ListRole::Text:
return m_list[_pos.y()].m_bufferName.getNameFile();;
return m_list[_pos.y()].m_bufferName.getFileName();;
case ewol::widget::ListRole::FgColor:
if ( m_list[_pos.y()].m_buffer != null
&& m_list[_pos.y()].m_buffer->isModify() == false) {
@ -194,7 +180,7 @@ fluorine::Variant appl::widget::BufferList::getData(int32_t _role, const ivec2&
return (*m_paintingProperties)[m_colorTextModify].getForeground();
}
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()) {
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) {
if ( _event.getId() == 1
&& _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
&& _pos.y() < (int64_t)m_list.size()) {
if (m_list[_pos.y()].m_buffer != 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());
}
return true;

View File

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

View File

@ -10,25 +10,14 @@
//#include <ColorizeManager.hpp>
#include <appl/Gui/MainWindows.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]);
}
}
#include <ewol/compositing/Image.hpp>
#include <etk/algorithm.hpp>
appl::widget::BufferTree::BufferTree() :
propertyShowUnNeeded(this, "show-un-needed",
true,
"show element that is not open",
&appl::widget::BufferTree::onChangePropertyShowUnNeeded),
m_openOrderMode(false) {
addObjectType("appl::BufferTree");
m_selectedID = -1;
@ -36,7 +25,7 @@ appl::widget::BufferTree::BufferTree() :
// load buffer manager:
m_bufferManager = appl::BufferManager::create();
// 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 ...
m_colorBackground1 = m_paintingProperties->request("backgroung1");
m_colorBackground2 = m_paintingProperties->request("backgroung2");
@ -53,21 +42,37 @@ void appl::widget::BufferTree::init() {
propertyCanFocus.set(true);
propertyTextIsDecorated.set(false);
if (m_bufferManager != null) {
m_bufferManager->signalNewBuffer2.connect(sharedFromThis(), &appl::widget::BufferTree::onNewBuffer);
m_bufferManager->signalSelectBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onSelectBuffer);
m_bufferManager->signalNewBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onNewBuffer);
m_bufferManager->signalSelectFile.connect(sharedFromThis(), &appl::widget::BufferTree::onSelectBuffer);
m_bufferManager->signalRemoveBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onRemoveBuffer);
}
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;
for (size_t iii=0; iii < etk::min(_left.size(), _right.size()); ++iii) {
if (_left[iii] == _right[iii]) {
out += _left[iii];
etk::String left = _left.getString() + "/";
etk::String right = _right.getString() + "/";
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;
}
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;
}
@ -75,15 +80,18 @@ static etk::String getCommonPathPart(const etk::String& _left, const etk::String
void appl::widget::BufferTree::generateFlatTree() {
// Brut Force Mode...
etk::String upperParent = getRootPath();
etk::Path upperParent = getRootPath();
// Now we have the root path...
// Need to feed all elements needed.
etk::FSNode nodeRoot = upperParent;
m_tree = etk::TreeNode<appl::TreeElement>::create(TreeElement(nodeRoot, true));
m_tree = etk::TreeNode<appl::TreeElement>::create(TreeElement(upperParent, true));
populateNodeIfNeeded(m_tree);
updateFlatTree();
}
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) {
if (_node == null) {
return;
@ -94,34 +102,74 @@ void appl::widget::BufferTree::populateNodeIfNeeded(ememory::SharedPtr<etk::Tree
return;
}
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;
}
etk::Vector<etk::FSNode*> child = etk::FSNode(value.m_path).folderGetSubList(false, true, true, false);
APPL_ERROR(" nbChilds: " << child.size() << " for path: " << value.m_path);
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);
for (auto& it: child) {
APPL_ERROR("add element: " << *it);
auto elem = etk::TreeNode<appl::TreeElement>::create(TreeElement(*it, false));
APPL_VERBOSE("add element: " << it);
auto elem = etk::TreeNode<appl::TreeElement>::create(TreeElement(it, false));
_node->addChild(elem);
// TODO: ETK_FREE(etk::FSNode, it);
}
}
void appl::widget::BufferTree::goUpper() {
APPL_ERROR("Go upper ...");
APPL_VERBOSE("Go upper ...");
if (m_tree == null) {
generateFlatTree();
return;
}
// generate new futur root node ...
etk::FSNode node = etk::FSNode(m_tree->getData().m_path).folderGetParent();
auto treeElement = etk::TreeNode<appl::TreeElement>::create(TreeElement(node, true));
etk::Path path = m_tree->getData().m_path.getParent();
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
populateNodeIfNeeded(treeElement);
// find old root node in the sublist:
for (auto& it: treeElement->getChilds()) {
if (it->getData().m_nodeName == m_tree->getData().m_nodeName) {
it = m_tree;
it->setParent(treeElement);
break;
}
}
@ -131,18 +179,76 @@ void appl::widget::BufferTree::goUpper() {
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() {
m_flatTree.setRoot(m_tree,
[&](const TreeElement& _value){
return true;
},
[&](const TreeElement& _value){
return _value.m_isExpand;
});
// Enable parent with child open:
updateChildOpen(m_tree);
// flat tree element enable
if (propertyShowUnNeeded.get() == false) {
m_flatTree.setRoot(m_tree,
[&](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();
}
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() {
removeAllElement();
@ -163,8 +269,8 @@ void appl::widget::BufferTree::removeAllElement() {
//m_list.clear();
}
etk::String appl::widget::BufferTree::getRootPath() {
etk::String upperParent = "";
etk::Path appl::widget::BufferTree::getRootPath() {
etk::Path upperParent = "";
etk::Vector<appl::BufferShared> tmpNewBuffer;
for (auto& it : *m_bufferManager) {
if (it == null) {
@ -174,35 +280,50 @@ etk::String appl::widget::BufferTree::getRootPath() {
tmpNewBuffer.pushBack(it);
continue;
}
etk::FSNode nodeName = it->getFileName();
if (upperParent == "") {
upperParent = nodeName.getNameFolder();
APPL_ERROR("init root: " << nodeName.getFileSystemName() << " root=" << upperParent);
etk::Path nodeName = it->getFileName();
if (upperParent.isEmpty() == true) {
upperParent = nodeName.getParent();
APPL_DEBUG("init root: " << nodeName << " root=" << upperParent);
continue;
}
upperParent = getCommonPathPart(upperParent, nodeName.getNameFolder());
APPL_ERROR("Update: " << nodeName.getFileSystemName() << " " << nodeName.getNameFolder() << " root=" << upperParent);
upperParent = getCommonPathPart(upperParent, nodeName.getParent());
APPL_DEBUG("Update: " << nodeName << " " << nodeName.getParent() << " root=" << upperParent);
}
if (upperParent == "") {
APPL_ERROR("Nothing find ==> get home path...");
upperParent = etk::FSNodeGetHomePath();
APPL_DEBUG("Nothing find ==> get home path...");
upperParent = etk::path::getHomePath();
}
APPL_ERROR("update tree: " << upperParent);
APPL_DEBUG("update tree: " << upperParent);
return upperParent;
}
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) {
generateFlatTree();
} else {
etk::String rootPath = getRootPath();
while (rootPath != m_tree->getData().m_path ) {
goUpper();
etk::Path rootPath = getRootPath();
APPL_VERBOSE("=============================================================================================================");
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) {
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()) {
return true;
}
@ -213,32 +334,7 @@ void appl::widget::BufferTree::onNewBuffer(const ememory::SharedPtr<appl::Buffer
} else {
listElements[0]->getData().m_buffer = _buffer;
}
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) {
@ -279,7 +375,7 @@ void appl::widget::BufferTree::onCallbackChangeName() {
}
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) {
if (_element.getData().m_buffer == _buffer) {
return true;
@ -310,7 +406,7 @@ ivec2 appl::widget::BufferTree::getMatrixSize() const {
}
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;
updateFlatTree();
}
@ -322,8 +418,12 @@ fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2&
case ewol::widget::ListRole::Text:
return value.m_nodeName;
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) {
//APPL_ERROR( m_colorBackgroundHide << " => " << (*m_paintingProperties)[m_colorBackgroundHide].getForeground());
APPL_VERBOSE( m_colorBackgroundHide << " => " << (*m_paintingProperties)[m_colorBackgroundHide].getForeground());
return (*m_paintingProperties)[m_colorTextNotOpen].getForeground();
}
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();
case ewol::widget::ListRole::BgColor:
//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) {
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:
/*
if (elem->countToRoot() == 0) {
return "{ewol}THEME:GUI:Home.svg";
return "THEME_GUI:///Home.svg?lib=ewol";
}*/
if (value.m_isFolder == true) {
return "{ewol}THEME:GUI:Folder.svg";
return "image_folder";
} else {
return "{ewol}THEME:GUI:File.svg";
return "image_file";
}
return "";
case ewol::widget::ListRole::DistanceToRoot:
return uint_t(elem->countToRoot());
case ewol::widget::ListRole::HaveChild:
return elem->haveChild();
if (elem->haveChild() == true) {
return true;
}
return value.m_haveChild;
case ewol::widget::ListRole::IsExpand:
return value.m_isExpand;
case ewol::widget::ListRole::IsSelected:
@ -380,14 +487,21 @@ bool appl::widget::BufferTree::onItemEvent(const ewol::event::Input& _event, con
updateFlatTree();
return true;
} 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;
}
}
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) {
// 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;
}
}
@ -407,4 +521,7 @@ bool appl::widget::BufferTree::onItemEvent(const ewol::event::Input& _event, con
return false;
}
void appl::widget::BufferTree::onChangePropertyShowUnNeeded() {
updateFlatTree();
markToRedraw();
}

View File

@ -11,22 +11,25 @@
#include <ewol/widget/TreeView.hpp>
#include <ewol/widget/Windows.hpp>
#include <etk/FlatTree.hpp>
#include <etk/path/fileSystem.hpp>
namespace appl {
class TreeElement {
public:
TreeElement(const etk::FSNode& _node, bool _isExpand=false):
m_path(_node.getFileSystemName()),
m_nodeName(_node.getNameFile()),
m_isFolder(_node.getNodeType() == etk::typeNode_folder),
TreeElement(const etk::Path& _path, bool _isExpand = false):
m_path(_path),
m_nodeName(_path.getFileName()),
m_isFolder(etk::path::isDirectory(_path) == true),
m_buffer(null),
m_isSelected(false),
m_isExpand(_isExpand) {
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..
bool m_isFolder;
bool m_haveChildOpen = false;
bool m_haveChild = false;
ememory::SharedPtr<appl::Buffer> m_buffer;
bool m_isSelected = false;
bool m_isExpand = false;
@ -38,6 +41,8 @@ namespace appl {
using BufferTreeWeak = ememory::WeakPtr<BufferTree>;
class BufferTree : public ewol::widget::TreeView {
public:
eproperty::Value<bool> propertyShowUnNeeded; //!< Size of the icon.
private:
ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
private:
@ -54,8 +59,11 @@ namespace appl {
int32_t m_selectedID;
void updateFlatTree();
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 expandToPath(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node, const etk::Path& _path);
void goUpper();
ememory::SharedPtr<etk::TreeNode<TreeElement>> m_tree;
etk::FlatTree<TreeElement> m_flatTree;
@ -86,6 +94,7 @@ namespace appl {
void onSelectBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer);
void onRemoveBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer);
void calculateMinMaxSize() override;
void onChangePropertyShowUnNeeded();
};
}
}