[DEV] add ctags and select all plugin and correct the undo/redo plugin
This commit is contained in:
parent
b79578b7e1
commit
4d999bbb67
@ -261,7 +261,7 @@ MainWindows::MainWindows(void) {
|
|||||||
shortCutAdd("ctrl+f", ednMsgGuiSearch, "", true);
|
shortCutAdd("ctrl+f", ednMsgGuiSearch, "", true);
|
||||||
shortCutAdd("F12", ednMsgGuiReloadShader, "", true);
|
shortCutAdd("F12", ednMsgGuiReloadShader, "", true);
|
||||||
|
|
||||||
shortCutAdd("ctrl+d", ednMsgGuiCtags, "Jump", true);
|
//shortCutAdd("ctrl+d", ednMsgGuiCtags, "Jump", true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,16 +35,12 @@ appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) :
|
|||||||
addObjectType("appl::TextViewer");
|
addObjectType("appl::TextViewer");
|
||||||
setCanHaveFocus(true);
|
setCanHaveFocus(true);
|
||||||
registerMultiCast(ednMsgBufferId);
|
registerMultiCast(ednMsgBufferId);
|
||||||
registerMultiCast(ednMsgGuiSelect);
|
|
||||||
registerMultiCast(ednMsgGuiFind);
|
registerMultiCast(ednMsgGuiFind);
|
||||||
registerMultiCast(ednMsgGuiReplace);
|
registerMultiCast(ednMsgGuiReplace);
|
||||||
registerMultiCast(ednMsgGuiGotoLine);
|
registerMultiCast(ednMsgGuiGotoLine);
|
||||||
registerMultiCast(appl::MsgSelectNewFile);
|
registerMultiCast(appl::MsgSelectNewFile);
|
||||||
setLimitScrolling(0.2);
|
setLimitScrolling(0.2);
|
||||||
|
|
||||||
shortCutAdd("ctrl+a", ednMsgGuiSelect, "ALL");
|
|
||||||
shortCutAdd("ctrl+shift+a", ednMsgGuiSelect, "NONE");
|
|
||||||
|
|
||||||
// load buffer manager:
|
// load buffer manager:
|
||||||
m_bufferManager = appl::BufferManager::keep();
|
m_bufferManager = appl::BufferManager::keep();
|
||||||
m_viewerManager = appl::ViewerManager::keep();
|
m_viewerManager = appl::ViewerManager::keep();
|
||||||
@ -60,15 +56,6 @@ appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) :
|
|||||||
m_colorSelection = m_paintingProperties->request("SelectedText");
|
m_colorSelection = m_paintingProperties->request("SelectedText");
|
||||||
m_colorNormal = m_paintingProperties->request("normal");
|
m_colorNormal = m_paintingProperties->request("normal");
|
||||||
|
|
||||||
// by default we load an example object:
|
|
||||||
/*
|
|
||||||
m_buffer = new appl::Buffer();
|
|
||||||
if (m_buffer == NULL) {
|
|
||||||
APPL_ERROR("can not create buffer ... ");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_buffer->loadFile("./example.txt");
|
|
||||||
*/
|
|
||||||
appl::textPluginManager::connect(*this);
|
appl::textPluginManager::connect(*this);
|
||||||
// last created has focus ...
|
// last created has focus ...
|
||||||
setCurrentSelect();
|
setCurrentSelect();
|
||||||
|
@ -37,8 +37,9 @@ namespace appl {
|
|||||||
public:
|
public:
|
||||||
TextViewer(const std::string& _fontName="", int32_t _fontSize=-1);
|
TextViewer(const std::string& _fontName="", int32_t _fontSize=-1);
|
||||||
virtual ~TextViewer(void);
|
virtual ~TextViewer(void);
|
||||||
private:
|
public:
|
||||||
appl::Buffer* m_buffer; //!< pointer on the current buffer to display (can be null if the buffer is remover or in state of changing buffer)
|
appl::Buffer* m_buffer; //!< pointer on the current buffer to display (can be null if the buffer is remover or in state of changing buffer)
|
||||||
|
private:
|
||||||
ewol::Text m_displayText; //!< Text display properties.
|
ewol::Text m_displayText; //!< Text display properties.
|
||||||
ewol::Drawing m_displayDrawing; //!< Other diaplay requested.
|
ewol::Drawing m_displayDrawing; //!< Other diaplay requested.
|
||||||
std::vector<std::pair<appl::Buffer*, vec2>> m_drawingRemenber;
|
std::vector<std::pair<appl::Buffer*, vec2>> m_drawingRemenber;
|
||||||
@ -266,6 +267,21 @@ namespace appl {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the position of selection around (select word).
|
||||||
|
* @param[in] _pos Position to start the selection.
|
||||||
|
* @param[out] _beginPos Position where the element start.
|
||||||
|
* @param[out] _endPos Position where the element stop.
|
||||||
|
* @return true if we find a selection around.
|
||||||
|
*/
|
||||||
|
bool getPosAround(const appl::Buffer::Iterator& _pos,
|
||||||
|
appl::Buffer::Iterator &_beginPos,
|
||||||
|
appl::Buffer::Iterator &_endPos) {
|
||||||
|
if (m_buffer==NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return m_buffer->getPosAround(_pos, _beginPos, _endPos);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Get an iterator an an specific position
|
* @brief Get an iterator an an specific position
|
||||||
* @param[in] _pos Requested position of the iterator.
|
* @param[in] _pos Requested position of the iterator.
|
||||||
|
@ -19,7 +19,7 @@ namespace appl {
|
|||||||
friend class appl::TextViewer;
|
friend class appl::TextViewer;
|
||||||
public:
|
public:
|
||||||
TextViewerPlugin(void);
|
TextViewerPlugin(void);
|
||||||
~TextViewerPlugin(void);
|
virtual ~TextViewerPlugin(void);
|
||||||
private:
|
private:
|
||||||
bool m_isEnable; //!< The plugin is enable or not (for all viewer).
|
bool m_isEnable; //!< The plugin is enable or not (for all viewer).
|
||||||
public:
|
public:
|
||||||
|
67
sources/appl/TextPluginCtags.cpp
Normal file
67
sources/appl/TextPluginCtags.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license GPL v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <appl/TextPluginCtags.h>
|
||||||
|
#include <ewol/clipBoard.h>
|
||||||
|
#include <appl/Gui/TextViewer.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "TextPluginCtags"
|
||||||
|
|
||||||
|
|
||||||
|
appl::TextPluginCtags::TextPluginCtags(void) {
|
||||||
|
m_activateOnReceiveMessage = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* eventJumpDestination = "event-plugin-ctags-jump-destination";
|
||||||
|
const char* eventJumpBack = "event-plugin-ctags-jump-back";
|
||||||
|
|
||||||
|
void appl::TextPluginCtags::onPluginEnable(appl::TextViewer& _textDrawer) {
|
||||||
|
// add event :
|
||||||
|
_textDrawer.ext_registerMultiCast(eventJumpDestination);
|
||||||
|
_textDrawer.ext_registerMultiCast(eventJumpBack);
|
||||||
|
_textDrawer.ext_shortCutAdd("ctrl+d", eventJumpDestination);
|
||||||
|
_textDrawer.ext_shortCutAdd("ctrl+shift+d", eventJumpBack);
|
||||||
|
}
|
||||||
|
|
||||||
|
void appl::TextPluginCtags::onPluginDisable(appl::TextViewer& _textDrawer) {
|
||||||
|
// TODO : unknow function ...
|
||||||
|
}
|
||||||
|
|
||||||
|
bool appl::TextPluginCtags::onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||||
|
const ewol::EMessage& _msg) {
|
||||||
|
if (isEnable() == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_msg.getMessage() == eventJumpDestination) {
|
||||||
|
if (_textDrawer.hasBuffer() == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::string textToSearch;
|
||||||
|
if (_textDrawer.hasTextSelected() == true) {
|
||||||
|
_textDrawer.copy(textToSearch, _textDrawer.selectStart(), _textDrawer.selectStop() );
|
||||||
|
} else {
|
||||||
|
appl::Buffer::Iterator _beginPos;
|
||||||
|
appl::Buffer::Iterator _endPos;
|
||||||
|
if (_textDrawer.getPosAround(_textDrawer.cursor(), _beginPos, _endPos) == false) {
|
||||||
|
APPL_WARNING("Can not get data around...");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
_textDrawer.copy(textToSearch, _beginPos, _endPos);
|
||||||
|
}
|
||||||
|
APPL_ERROR("CTAGS might search : '" << textToSearch << "'");
|
||||||
|
return true;
|
||||||
|
} else if (_msg.getMessage() == eventJumpBack) {
|
||||||
|
if (_textDrawer.hasBuffer() == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
33
sources/appl/TextPluginCtags.h
Normal file
33
sources/appl/TextPluginCtags.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license GPL v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __APPL_TEXT_PLUGIN_CTAGS_H__
|
||||||
|
#define __APPL_TEXT_PLUGIN_CTAGS_H__
|
||||||
|
|
||||||
|
#include <etk/types.h>
|
||||||
|
#include <ewol/renderer/EObject.h>
|
||||||
|
#include <appl/Gui/TextViewer.h>
|
||||||
|
#include <ewol/compositing/Text.h>
|
||||||
|
#include <appl/TextPlugin.h>
|
||||||
|
|
||||||
|
namespace appl {
|
||||||
|
class TextPluginCtags : public appl::TextViewerPlugin {
|
||||||
|
public:
|
||||||
|
TextPluginCtags(void);
|
||||||
|
~TextPluginCtags(void) {
|
||||||
|
// nothing to do ...
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
|
||||||
|
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
|
||||||
|
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer, const ewol::EMessage& _msg);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
0
sources/appl/TextPluginData.cpp
Normal file
0
sources/appl/TextPluginData.cpp
Normal file
149
sources/appl/TextPluginData.h
Normal file
149
sources/appl/TextPluginData.h
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license GPL v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __APPL_TEXT_PLUGIN_DATA_H__
|
||||||
|
#define __APPL_TEXT_PLUGIN_DATA_H__
|
||||||
|
|
||||||
|
#include <etk/types.h>
|
||||||
|
#include <ewol/renderer/EObject.h>
|
||||||
|
#include <appl/Gui/TextViewer.h>
|
||||||
|
#include <ewol/compositing/Text.h>
|
||||||
|
#include <appl/TextPlugin.h>
|
||||||
|
|
||||||
|
namespace appl {
|
||||||
|
template <typename TYPE> class TextViewerPluginData : public appl::TextViewerPlugin {
|
||||||
|
public:
|
||||||
|
TextViewerPluginData(void) {
|
||||||
|
// nothing to do ...
|
||||||
|
}
|
||||||
|
virtual ~TextViewerPluginData(void) {
|
||||||
|
for (size_t iii = 0; iii < m_specificData.size() ; ++iii) {
|
||||||
|
if (m_specificData[iii].second != NULL) {
|
||||||
|
remove(*m_specificData[iii].second);
|
||||||
|
delete(m_specificData[iii].second);
|
||||||
|
m_specificData[iii].second = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_specificData.clear();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::vector<std::pair<appl::Buffer* ,TYPE* >> m_specificData;
|
||||||
|
protected:
|
||||||
|
TYPE* getDataRef(appl::TextViewer& _textDrawer) {
|
||||||
|
for (size_t iii = 0; iii < m_specificData.size() ; ++iii) {
|
||||||
|
APPL_DEBUG("compare " << (int64_t)m_specificData[iii].first << " && " << (int64_t)&_textDrawer);
|
||||||
|
if (m_specificData[iii].first == _textDrawer.m_buffer) {
|
||||||
|
APPL_DEBUG("find data : " << iii);
|
||||||
|
return m_specificData[iii].second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TYPE* data = new TYPE();
|
||||||
|
if (data == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
m_specificData.push_back(std::make_pair(_textDrawer.m_buffer, data));
|
||||||
|
// create a new one ...
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
protected: // Wrap all element with their internal data: (do not use theses function)
|
||||||
|
void onPluginEnable(appl::TextViewer& _textDrawer) {
|
||||||
|
TYPE* data = getDataRef(_textDrawer);
|
||||||
|
if (data == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return onPluginEnable(_textDrawer, *data);
|
||||||
|
}
|
||||||
|
void onPluginDisable(appl::TextViewer& _textDrawer) {
|
||||||
|
TYPE* data = getDataRef(_textDrawer);
|
||||||
|
if (data == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return onPluginDisable(_textDrawer, *data);
|
||||||
|
}
|
||||||
|
bool onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||||
|
const ewol::EMessage& _msg) {
|
||||||
|
TYPE* data = getDataRef(_textDrawer);
|
||||||
|
if (data == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return onReceiveMessage(_textDrawer, _msg, *data);
|
||||||
|
}
|
||||||
|
bool onWrite(appl::TextViewer& _textDrawer,
|
||||||
|
const appl::Buffer::Iterator& _pos,
|
||||||
|
const std::string& _data) {
|
||||||
|
TYPE* data = getDataRef(_textDrawer);
|
||||||
|
if (data == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return onWrite(_textDrawer, _pos, _data, *data);
|
||||||
|
}
|
||||||
|
bool onReplace(appl::TextViewer& _textDrawer,
|
||||||
|
const appl::Buffer::Iterator& _pos,
|
||||||
|
const std::string& _data,
|
||||||
|
const appl::Buffer::Iterator& _posEnd) {
|
||||||
|
TYPE* data = getDataRef(_textDrawer);
|
||||||
|
if (data == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return onReplace(_textDrawer, _pos, _data, _posEnd, *data);
|
||||||
|
}
|
||||||
|
bool onRemove(appl::TextViewer& _textDrawer,
|
||||||
|
const appl::Buffer::Iterator& _pos,
|
||||||
|
const appl::Buffer::Iterator& _posEnd) {
|
||||||
|
TYPE* data = getDataRef(_textDrawer);
|
||||||
|
if (data == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return onRemove(_textDrawer, _pos, _posEnd, *data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void onPluginEnable(appl::TextViewer& _textDrawer,
|
||||||
|
TYPE& _data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
virtual void onPluginDisable(appl::TextViewer& _textDrawer,
|
||||||
|
TYPE& _data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||||
|
const ewol::EMessage& _msg,
|
||||||
|
TYPE& _data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
virtual bool onWrite(appl::TextViewer& _textDrawer,
|
||||||
|
const appl::Buffer::Iterator& _pos,
|
||||||
|
const std::string& _strData,
|
||||||
|
TYPE& _data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
virtual bool onReplace(appl::TextViewer& _textDrawer,
|
||||||
|
const appl::Buffer::Iterator& _pos,
|
||||||
|
const std::string& _strData,
|
||||||
|
const appl::Buffer::Iterator& _posEnd,
|
||||||
|
TYPE& _data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
virtual bool onRemove(appl::TextViewer& _textDrawer,
|
||||||
|
const appl::Buffer::Iterator& _pos,
|
||||||
|
const appl::Buffer::Iterator& _posEnd,
|
||||||
|
TYPE& _data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
virtual void remove(TYPE& _data) {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
virtual void onObjectRemove(ewol::EObject* _removeObject) {
|
||||||
|
// TODO : plop
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -22,11 +22,6 @@ appl::TextPluginHistory::TextPluginHistory(void) {
|
|||||||
m_activateOnRemove = true;
|
m_activateOnRemove = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
appl::TextPluginHistory::~TextPluginHistory(void) {
|
|
||||||
clearUndo();
|
|
||||||
clearRedo();
|
|
||||||
};
|
|
||||||
|
|
||||||
void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) {
|
void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) {
|
||||||
// add event :
|
// add event :
|
||||||
_textDrawer.ext_registerMultiCast(ednMsgGuiRedo);
|
_textDrawer.ext_registerMultiCast(ednMsgGuiRedo);
|
||||||
@ -40,37 +35,38 @@ void appl::TextPluginHistory::onPluginDisable(appl::TextViewer& _textDrawer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool appl::TextPluginHistory::onReceiveMessage(appl::TextViewer& _textDrawer,
|
bool appl::TextPluginHistory::onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||||
const ewol::EMessage& _msg) {
|
const ewol::EMessage& _msg,
|
||||||
|
appl::PluginHistoryData& _data) {
|
||||||
if (isEnable() == false) {
|
if (isEnable() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_msg.getMessage() == ednMsgGuiRedo) {
|
if (_msg.getMessage() == ednMsgGuiRedo) {
|
||||||
if (m_redo.size() == 0) {
|
if (_data.m_redo.size() == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (m_redo[m_redo.size()-1] == NULL) {
|
if (_data.m_redo[_data.m_redo.size()-1] == NULL) {
|
||||||
m_redo.pop_back();
|
_data.m_redo.pop_back();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
appl::History *tmpElement = m_redo[m_redo.size()-1];
|
appl::History *tmpElement = _data.m_redo[_data.m_redo.size()-1];
|
||||||
m_redo.pop_back();
|
_data.m_redo.pop_back();
|
||||||
m_undo.push_back(tmpElement);
|
_data.m_undo.push_back(tmpElement);
|
||||||
_textDrawer.replaceDirect(tmpElement->m_addedText,
|
_textDrawer.replaceDirect(tmpElement->m_addedText,
|
||||||
_textDrawer.position(tmpElement->m_posAdded),
|
_textDrawer.position(tmpElement->m_posAdded),
|
||||||
_textDrawer.position(tmpElement->m_endPosRemoved) );
|
_textDrawer.position(tmpElement->m_endPosRemoved) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (_msg.getMessage() == ednMsgGuiUndo) {
|
} else if (_msg.getMessage() == ednMsgGuiUndo) {
|
||||||
if (m_undo.size() == 0) {
|
if (_data.m_undo.size() == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (m_undo[m_undo.size()-1] == NULL) {
|
if (_data.m_undo[_data.m_undo.size()-1] == NULL) {
|
||||||
m_undo.pop_back();
|
_data.m_undo.pop_back();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
appl::History *tmpElement = m_undo[m_undo.size()-1];
|
appl::History *tmpElement = _data.m_undo[_data.m_undo.size()-1];
|
||||||
m_undo.pop_back();
|
_data.m_undo.pop_back();
|
||||||
m_redo.push_back(tmpElement);
|
_data.m_redo.push_back(tmpElement);
|
||||||
_textDrawer.replaceDirect(tmpElement->m_removedText,
|
_textDrawer.replaceDirect(tmpElement->m_removedText,
|
||||||
_textDrawer.position(tmpElement->m_posAdded),
|
_textDrawer.position(tmpElement->m_posAdded),
|
||||||
_textDrawer.position(tmpElement->m_endPosAdded) );
|
_textDrawer.position(tmpElement->m_endPosAdded) );
|
||||||
@ -80,52 +76,53 @@ bool appl::TextPluginHistory::onReceiveMessage(appl::TextViewer& _textDrawer,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::TextPluginHistory::clearRedo(void) {
|
void appl::TextPluginHistory::clearRedo(appl::PluginHistoryData& _data) {
|
||||||
if (m_redo.size() == 0) {
|
if (_data.m_redo.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (size_t iii=0; iii<m_redo.size(); ++iii) {
|
for (size_t iii=0; iii<_data.m_redo.size(); ++iii) {
|
||||||
if (m_redo[iii] == NULL) {
|
if (_data.m_redo[iii] == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
delete(m_redo[iii]);
|
delete(_data.m_redo[iii]);
|
||||||
m_redo[iii] = NULL;
|
_data.m_redo[iii] = NULL;
|
||||||
}
|
}
|
||||||
m_redo.clear();
|
_data.m_redo.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::TextPluginHistory::clearUndo(void) {
|
void appl::TextPluginHistory::clearUndo(appl::PluginHistoryData& _data) {
|
||||||
if (m_undo.size() == 0) {
|
if (_data.m_undo.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (size_t iii=0; iii<m_undo.size(); ++iii) {
|
for (size_t iii=0; iii<_data.m_undo.size(); ++iii) {
|
||||||
if (m_undo[iii] == NULL) {
|
if (_data.m_undo[iii] == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
delete(m_undo[iii]);
|
delete(_data.m_undo[iii]);
|
||||||
m_undo[iii] = NULL;
|
_data.m_undo[iii] = NULL;
|
||||||
}
|
}
|
||||||
m_undo.clear();
|
_data.m_undo.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool appl::TextPluginHistory::onWrite(appl::TextViewer& _textDrawer,
|
bool appl::TextPluginHistory::onWrite(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const std::string& _data) {
|
const std::string& _strData,
|
||||||
|
appl::PluginHistoryData& _data) {
|
||||||
if (isEnable() == false) {
|
if (isEnable() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
appl::History *tmpElement = new appl::History();
|
appl::History *tmpElement = new appl::History();
|
||||||
if (tmpElement != NULL) {
|
if (tmpElement != NULL) {
|
||||||
tmpElement->m_addedText = _data;
|
tmpElement->m_addedText = _strData;
|
||||||
tmpElement->m_posAdded = (int64_t)_pos;
|
tmpElement->m_posAdded = (int64_t)_pos;
|
||||||
tmpElement->m_endPosRemoved = (int64_t)_pos;
|
tmpElement->m_endPosRemoved = (int64_t)_pos;
|
||||||
}
|
}
|
||||||
_textDrawer.writeDirect(_data, _pos);
|
_textDrawer.writeDirect(_strData, _pos);
|
||||||
if (tmpElement != NULL) {
|
if (tmpElement != NULL) {
|
||||||
tmpElement->m_endPosAdded = (int64_t)_textDrawer.cursor();
|
tmpElement->m_endPosAdded = (int64_t)_textDrawer.cursor();
|
||||||
clearRedo();
|
clearRedo(_data);
|
||||||
m_undo.push_back(tmpElement);
|
_data.m_undo.push_back(tmpElement);
|
||||||
}
|
}
|
||||||
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor());
|
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor());
|
||||||
return true;
|
return true;
|
||||||
@ -133,23 +130,24 @@ bool appl::TextPluginHistory::onWrite(appl::TextViewer& _textDrawer,
|
|||||||
|
|
||||||
bool appl::TextPluginHistory::onReplace(appl::TextViewer& _textDrawer,
|
bool appl::TextPluginHistory::onReplace(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const std::string& _data,
|
const std::string& _strData,
|
||||||
const appl::Buffer::Iterator& _posEnd) {
|
const appl::Buffer::Iterator& _posEnd,
|
||||||
|
appl::PluginHistoryData& _data) {
|
||||||
if (isEnable() == false) {
|
if (isEnable() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
appl::History *tmpElement = new appl::History();
|
appl::History *tmpElement = new appl::History();
|
||||||
if (tmpElement != NULL) {
|
if (tmpElement != NULL) {
|
||||||
tmpElement->m_posAdded = (int64_t)_pos;
|
tmpElement->m_posAdded = (int64_t)_pos;
|
||||||
tmpElement->m_addedText = _data;
|
tmpElement->m_addedText = _strData;
|
||||||
tmpElement->m_endPosRemoved = (int64_t)_posEnd;
|
tmpElement->m_endPosRemoved = (int64_t)_posEnd;
|
||||||
_textDrawer.copy(tmpElement->m_removedText, _pos, _posEnd);
|
_textDrawer.copy(tmpElement->m_removedText, _pos, _posEnd);
|
||||||
}
|
}
|
||||||
_textDrawer.replaceDirect(_data, _pos, _posEnd);
|
_textDrawer.replaceDirect(_strData, _pos, _posEnd);
|
||||||
if (tmpElement != NULL) {
|
if (tmpElement != NULL) {
|
||||||
tmpElement->m_endPosAdded = (int64_t)_textDrawer.cursor();
|
tmpElement->m_endPosAdded = (int64_t)_textDrawer.cursor();
|
||||||
clearRedo();
|
clearRedo(_data);
|
||||||
m_undo.push_back(tmpElement);
|
_data.m_undo.push_back(tmpElement);
|
||||||
}
|
}
|
||||||
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor());
|
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor());
|
||||||
return true;
|
return true;
|
||||||
@ -157,7 +155,8 @@ bool appl::TextPluginHistory::onReplace(appl::TextViewer& _textDrawer,
|
|||||||
|
|
||||||
bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer,
|
bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const appl::Buffer::Iterator& _posEnd) {
|
const appl::Buffer::Iterator& _posEnd,
|
||||||
|
appl::PluginHistoryData& _data) {
|
||||||
if (isEnable() == false) {
|
if (isEnable() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -168,8 +167,8 @@ bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer,
|
|||||||
tmpElement->m_endPosAdded = tmpElement->m_posAdded;
|
tmpElement->m_endPosAdded = tmpElement->m_posAdded;
|
||||||
tmpElement->m_endPosRemoved = (int64_t)_posEnd;
|
tmpElement->m_endPosRemoved = (int64_t)_posEnd;
|
||||||
_textDrawer.copy(tmpElement->m_removedText, _pos, _posEnd);
|
_textDrawer.copy(tmpElement->m_removedText, _pos, _posEnd);
|
||||||
clearRedo();
|
clearRedo(_data);
|
||||||
m_undo.push_back(tmpElement);
|
_data.m_undo.push_back(tmpElement);
|
||||||
}
|
}
|
||||||
_textDrawer.removeDirect();
|
_textDrawer.removeDirect();
|
||||||
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor());
|
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor());
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <ewol/renderer/EObject.h>
|
#include <ewol/renderer/EObject.h>
|
||||||
#include <appl/Gui/TextViewer.h>
|
#include <appl/Gui/TextViewer.h>
|
||||||
#include <ewol/compositing/Text.h>
|
#include <ewol/compositing/Text.h>
|
||||||
#include <appl/TextPlugin.h>
|
#include <appl/TextPluginData.h>
|
||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
class History {
|
class History {
|
||||||
@ -30,31 +30,42 @@ namespace appl {
|
|||||||
int64_t m_endPosAdded;
|
int64_t m_endPosAdded;
|
||||||
int64_t m_endPosRemoved;
|
int64_t m_endPosRemoved;
|
||||||
};
|
};
|
||||||
class TextPluginHistory : public appl::TextViewerPlugin {
|
class PluginHistoryData {
|
||||||
public:
|
public:
|
||||||
TextPluginHistory(void);
|
|
||||||
~TextPluginHistory(void);
|
|
||||||
private:
|
|
||||||
std::vector<History*> m_undo; //!< History storing data
|
std::vector<History*> m_undo; //!< History storing data
|
||||||
std::vector<History*> m_redo; //!< History storing data
|
std::vector<History*> m_redo; //!< History storing data
|
||||||
|
};
|
||||||
|
class TextPluginHistory : public appl::TextViewerPluginData<appl::PluginHistoryData> {
|
||||||
|
public:
|
||||||
|
TextPluginHistory(void);
|
||||||
|
virtual ~TextPluginHistory(void) { };
|
||||||
|
private:
|
||||||
public:
|
public:
|
||||||
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
|
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
|
||||||
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
|
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
|
||||||
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer,
|
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||||
const ewol::EMessage& _msg);
|
const ewol::EMessage& _msg,
|
||||||
|
appl::PluginHistoryData& _data);
|
||||||
virtual bool onWrite(appl::TextViewer& _textDrawer,
|
virtual bool onWrite(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const std::string& _data);
|
const std::string& _strData,
|
||||||
|
appl::PluginHistoryData& _data);
|
||||||
virtual bool onReplace(appl::TextViewer& _textDrawer,
|
virtual bool onReplace(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const std::string& _data,
|
const std::string& _strData,
|
||||||
const appl::Buffer::Iterator& _posEnd);
|
const appl::Buffer::Iterator& _posEnd,
|
||||||
|
appl::PluginHistoryData& _data);
|
||||||
virtual bool onRemove(appl::TextViewer& _textDrawer,
|
virtual bool onRemove(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const appl::Buffer::Iterator& _posEnd);
|
const appl::Buffer::Iterator& _posEnd,
|
||||||
|
appl::PluginHistoryData& _data);
|
||||||
|
virtual void remove(appl::PluginHistoryData& _data) {
|
||||||
|
clearRedo(_data);
|
||||||
|
clearUndo(_data);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
void clearRedo(void);
|
void clearRedo(appl::PluginHistoryData& _data);
|
||||||
void clearUndo(void);
|
void clearUndo(appl::PluginHistoryData& _data);
|
||||||
public:
|
public:
|
||||||
virtual void onObjectRemove(ewol::EObject* _removeObject);
|
virtual void onObjectRemove(ewol::EObject* _removeObject);
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include <appl/TextPluginAutoIndent.h>
|
#include <appl/TextPluginAutoIndent.h>
|
||||||
#include <appl/TextPluginHistory.h>
|
#include <appl/TextPluginHistory.h>
|
||||||
#include <appl/TextPluginRmLine.h>
|
#include <appl/TextPluginRmLine.h>
|
||||||
|
#include <appl/TextPluginSelectAll.h>
|
||||||
|
#include <appl/TextPluginCtags.h>
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "textPluginManager"
|
#define __class__ "textPluginManager"
|
||||||
@ -80,6 +82,8 @@ void appl::textPluginManager::addDefaultPlugin(void) {
|
|||||||
appl::textPluginManager::addPlugin(new appl::TextPluginAutoIndent());
|
appl::textPluginManager::addPlugin(new appl::TextPluginAutoIndent());
|
||||||
appl::textPluginManager::addPlugin(new appl::TextPluginHistory());
|
appl::textPluginManager::addPlugin(new appl::TextPluginHistory());
|
||||||
appl::textPluginManager::addPlugin(new appl::TextPluginRmLine());
|
appl::textPluginManager::addPlugin(new appl::TextPluginRmLine());
|
||||||
|
appl::textPluginManager::addPlugin(new appl::TextPluginSelectAll());
|
||||||
|
appl::textPluginManager::addPlugin(new appl::TextPluginCtags());
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::textPluginManager::addPlugin(appl::TextViewerPlugin* _plugin) {
|
void appl::textPluginManager::addPlugin(appl::TextViewerPlugin* _plugin) {
|
||||||
|
47
sources/appl/TextPluginSelectAll.cpp
Normal file
47
sources/appl/TextPluginSelectAll.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license GPL v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <appl/TextPluginSelectAll.h>
|
||||||
|
#include <ewol/clipBoard.h>
|
||||||
|
#include <appl/Gui/TextViewer.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "TextPluginSelectAll"
|
||||||
|
|
||||||
|
|
||||||
|
appl::TextPluginSelectAll::TextPluginSelectAll(void) {
|
||||||
|
m_activateOnReceiveMessage = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* eventSelectAll = "plugin-select-all";
|
||||||
|
|
||||||
|
void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) {
|
||||||
|
// add event :
|
||||||
|
_textDrawer.ext_registerMultiCast(eventSelectAll);
|
||||||
|
_textDrawer.ext_shortCutAdd("ctrl+a", eventSelectAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
void appl::TextPluginSelectAll::onPluginDisable(appl::TextViewer& _textDrawer) {
|
||||||
|
// TODO : unknow function ...
|
||||||
|
}
|
||||||
|
|
||||||
|
bool appl::TextPluginSelectAll::onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||||
|
const ewol::EMessage& _msg) {
|
||||||
|
if (isEnable() == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_msg.getMessage() == eventSelectAll) {
|
||||||
|
if (_textDrawer.hasBuffer() == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_textDrawer.select(_textDrawer.begin(), _textDrawer.end());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
33
sources/appl/TextPluginSelectAll.h
Normal file
33
sources/appl/TextPluginSelectAll.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license GPL v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __APPL_TEXT_PLUGIN_SELECT_ALL_H__
|
||||||
|
#define __APPL_TEXT_PLUGIN_SELECT_ALL_H__
|
||||||
|
|
||||||
|
#include <etk/types.h>
|
||||||
|
#include <ewol/renderer/EObject.h>
|
||||||
|
#include <appl/Gui/TextViewer.h>
|
||||||
|
#include <ewol/compositing/Text.h>
|
||||||
|
#include <appl/TextPlugin.h>
|
||||||
|
|
||||||
|
namespace appl {
|
||||||
|
class TextPluginSelectAll : public appl::TextViewerPlugin {
|
||||||
|
public:
|
||||||
|
TextPluginSelectAll(void);
|
||||||
|
~TextPluginSelectAll(void) {
|
||||||
|
// nothing to do ...
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
|
||||||
|
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
|
||||||
|
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer, const ewol::EMessage& _msg);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -41,6 +41,8 @@ def Create(target):
|
|||||||
'appl/TextPluginAutoIndent.cpp',
|
'appl/TextPluginAutoIndent.cpp',
|
||||||
'appl/TextPluginHistory.cpp',
|
'appl/TextPluginHistory.cpp',
|
||||||
'appl/TextPluginRmLine.cpp',
|
'appl/TextPluginRmLine.cpp',
|
||||||
|
'appl/TextPluginSelectAll.cpp',
|
||||||
|
'appl/TextPluginCtags.cpp',
|
||||||
'appl/TextPluginManager.cpp'])
|
'appl/TextPluginManager.cpp'])
|
||||||
|
|
||||||
# Generic color management for the text editor :
|
# Generic color management for the text editor :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user