edn/sources/appl/TextPluginHistory.hpp

73 lines
2.4 KiB
C++
Raw Normal View History

2016-05-02 22:01:55 +02:00
/** @file
2013-10-22 22:01:31 +02:00
* @author Edouard DUPIN
* @copyright 2010, Edouard DUPIN, all right reserved
* @license GPL v3 (see license file)
*/
2016-05-02 22:01:55 +02:00
#pragma once
2016-10-03 22:01:55 +02:00
#include <etk/types.hpp>
#include <ewol/object/Object.hpp>
#include <appl/Gui/TextViewer.hpp>
#include <ewol/compositing/Text.hpp>
#include <appl/TextPluginData.hpp>
2013-10-22 22:01:31 +02:00
namespace appl {
class History {
public:
History() :
2013-10-22 22:01:31 +02:00
m_posAdded(0),
m_endPosAdded(0),
m_endPosRemoved(0) {
};
2013-11-14 21:57:10 +01:00
std::string m_addedText;
std::string m_removedText;
2013-11-23 18:30:52 +01:00
int64_t m_posAdded;
int64_t m_endPosAdded;
int64_t m_endPosRemoved;
2013-10-22 22:01:31 +02:00
};
class PluginHistoryData {
2013-10-22 22:01:31 +02:00
public:
2013-11-14 21:57:10 +01:00
std::vector<History*> m_undo; //!< History storing data
std::vector<History*> m_redo; //!< History storing data
};
class TextPluginHistory : public appl::TextViewerPluginData<appl::PluginHistoryData> {
2014-08-29 22:52:21 +02:00
private:
int32_t m_menuIdTitle;
int32_t m_menuIdUndo;
int32_t m_menuIdRedo;
protected:
TextPluginHistory();
public:
DECLARE_FACTORY(TextPluginHistory);
virtual ~TextPluginHistory() { };
private:
2013-10-22 22:01:31 +02:00
public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
virtual bool onDataReceiveShortCut(appl::TextViewer& _textDrawer,
const std::string& _shortCutName,
appl::PluginHistoryData& _data);
2014-08-21 21:00:13 +02:00
virtual bool onDataWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos,
const std::string& _strData,
appl::PluginHistoryData& _data);
virtual bool onDataReplace(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos,
const std::string& _strData,
const appl::Buffer::Iterator& _posEnd,
appl::PluginHistoryData& _data);
virtual bool onDataRemove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos,
const appl::Buffer::Iterator& _posEnd,
appl::PluginHistoryData& _data);
virtual void remove(appl::PluginHistoryData& _data) {
clearRedo(_data);
clearUndo(_data);
}
2013-10-22 22:01:31 +02:00
private:
void clearRedo(appl::PluginHistoryData& _data);
void clearUndo(appl::PluginHistoryData& _data);
2013-10-22 22:01:31 +02:00
};
2016-05-02 22:01:55 +02:00
}
2013-10-22 22:01:31 +02:00