[DEV] update to readlog

This commit is contained in:
Edouard DUPIN 2020-08-16 13:58:27 +02:00
parent 626c9ba386
commit 8806c99613
3 changed files with 41 additions and 1 deletions

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", ""),
@ -146,6 +150,7 @@ bool appl::Buffer::loadFile(const etk::Path& _name) {
countNumberofLine(); countNumberofLine();
tryFindHighlightType(); tryFindHighlightType();
m_isModify = false; m_isModify = false;
m_fileIsModify = false;
return true; return true;
} }
return false; return false;
@ -165,6 +170,31 @@ void appl::Buffer::setFileName(const etk::Path& _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;
} }

View File

@ -287,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;
@ -297,6 +298,15 @@ namespace appl {
public: public:
DECLARE_FACTORY(Buffer); DECLARE_FACTORY(Buffer);
virtual ~Buffer(); virtual ~Buffer();
private:
bool m_fileIsModify = false; //!< The file has been modify and the buffer is not synchronous
public:
/**
* @brief get the curent filename of the Buffer
*/
bool getFileModify() const {
return m_fileIsModify;
}
private: private:
bool m_hasFileName; //!< When new file, the buffer has no name ==> but it might be reference with a single name ... bool m_hasFileName; //!< When new file, the buffer has no name ==> but it might be reference with a single name ...
etk::Path m_fileName; //!< name of the file (with his path) etk::Path m_fileName; //!< name of the file (with his path)