[DEV] undo & redo implemented
This commit is contained in:
@@ -10,9 +10,12 @@
|
||||
#include <appl/Buffer/TextPlugin.h>
|
||||
#include <appl/Debug.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "TextViewerPlugin"
|
||||
|
||||
|
||||
appl::TextViewerPlugin::TextViewerPlugin(void) :
|
||||
m_isEnable(false),
|
||||
m_isEnable(true),
|
||||
m_activateOnEventEntry(false),
|
||||
m_activateOnEventInput(false),
|
||||
m_activateOnWrite(false),
|
||||
|
@@ -11,6 +11,9 @@
|
||||
#include <ewol/clipBoard.h>
|
||||
#include <appl/Gui/TextViewer.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "TextPluginAutoIndent"
|
||||
|
||||
|
||||
appl::TextPluginAutoIndent::TextPluginAutoIndent(void) {
|
||||
m_activateOnEventEntry = true;
|
||||
@@ -18,32 +21,32 @@ appl::TextPluginAutoIndent::TextPluginAutoIndent(void) {
|
||||
|
||||
bool appl::TextPluginAutoIndent::onEventEntry(appl::TextViewer& _textDrawer,
|
||||
const ewol::EventEntry& _event) {
|
||||
/*
|
||||
if (enable == false) {
|
||||
if (isEnable() == false) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
//APPL_DEBUG("KB EVENT : " << _event);
|
||||
// just forward event == > manage directly in the buffer
|
||||
if (_event.getType() != ewol::keyEvent::keyboardChar) {
|
||||
return false;
|
||||
}
|
||||
//APPL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
|
||||
if (_event.getStatus() != ewol::keyEvent::statusDown) {
|
||||
return false;
|
||||
}
|
||||
if (_event.getChar() != etk::UChar::Return) {
|
||||
return false;
|
||||
}
|
||||
if (_event.getSpecialKey().isSetShift() == false) {
|
||||
if (_event.getSpecialKey().isSetShift() == true) {
|
||||
return false;
|
||||
}
|
||||
appl::Buffer::Iterator startLine = _textDrawer.m_buffer->cursor();
|
||||
if (_textDrawer.m_buffer->hasTextSelected() == true) {
|
||||
startLine = _textDrawer.m_buffer->selectStart();
|
||||
}
|
||||
startLine = _textDrawer.m_buffer->getStartLine(startLine);
|
||||
etk::UString data = etk::UChar::Return;
|
||||
|
||||
for (appl::Buffer::Iterator it = startLine;
|
||||
|
||||
for (appl::Buffer::Iterator it = startLine+1;
|
||||
it != _textDrawer.m_buffer->end();
|
||||
++it) {
|
||||
if (*it == etk::UChar::Space) {
|
||||
@@ -54,7 +57,6 @@ bool appl::TextPluginAutoIndent::onEventEntry(appl::TextViewer& _textDrawer,
|
||||
break;
|
||||
}
|
||||
}
|
||||
APPL_DEBUG("kjhkjhkjhkjh : '" << data << "'");
|
||||
_textDrawer.write(data);
|
||||
return true;
|
||||
}
|
||||
|
@@ -11,6 +11,9 @@
|
||||
#include <ewol/clipBoard.h>
|
||||
#include <appl/Gui/TextViewer.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "TextPluginCopy"
|
||||
|
||||
|
||||
appl::TextPluginCopy::TextPluginCopy(void) {
|
||||
m_activateOnReceiveMessage = true;
|
||||
@@ -30,7 +33,11 @@ void appl::TextPluginCopy::onPluginDisable(appl::TextViewer& _textDrawer) {
|
||||
// TODO : unknow function ...
|
||||
}
|
||||
|
||||
bool appl::TextPluginCopy::onReceiveMessage(appl::TextViewer& _textDrawer, const ewol::EMessage& _msg) {
|
||||
bool appl::TextPluginCopy::onReceiveMessage(appl::TextViewer& _textDrawer,
|
||||
const ewol::EMessage& _msg) {
|
||||
if (isEnable() == false) {
|
||||
return false;
|
||||
}
|
||||
if ( _msg.getMessage() == ednMsgGuiCopy
|
||||
|| _msg.getMessage() == ednMsgGuiCut) {
|
||||
if (_textDrawer.m_buffer != NULL) {
|
||||
|
@@ -11,6 +11,10 @@
|
||||
#include <appl/Buffer/TextPluginCopy.h>
|
||||
#include <appl/Buffer/TextPluginMultiLineTab.h>
|
||||
#include <appl/Buffer/TextPluginAutoIndent.h>
|
||||
#include <appl/Buffer/TextPluginHistory.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "textPluginManager"
|
||||
|
||||
static etk::Vector<appl::TextViewerPlugin *>& getList(void) {
|
||||
static etk::Vector<appl::TextViewerPlugin *> s_list;
|
||||
@@ -73,6 +77,7 @@ void appl::textPluginManager::addDefaultPlugin(void) {
|
||||
appl::textPluginManager::addPlugin(new appl::TextPluginCopy());
|
||||
appl::textPluginManager::addPlugin(new appl::TextPluginMultiLineTab());
|
||||
appl::textPluginManager::addPlugin(new appl::TextPluginAutoIndent());
|
||||
appl::textPluginManager::addPlugin(new appl::TextPluginHistory());
|
||||
}
|
||||
|
||||
void appl::textPluginManager::addPlugin(appl::TextViewerPlugin* _plugin) {
|
||||
|
@@ -11,13 +11,18 @@
|
||||
#include <ewol/clipBoard.h>
|
||||
#include <appl/Gui/TextViewer.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "TextPluginMultiLineTab"
|
||||
|
||||
appl::TextPluginMultiLineTab::TextPluginMultiLineTab(void) {
|
||||
m_activateOnEventEntry = true;
|
||||
}
|
||||
|
||||
bool appl::TextPluginMultiLineTab::onEventEntry(appl::TextViewer& _textDrawer,
|
||||
const ewol::EventEntry& _event) {
|
||||
const ewol::EventEntry& _event) {
|
||||
if (isEnable() == false) {
|
||||
return false;
|
||||
}
|
||||
if (_event.getType() != ewol::keyEvent::keyboardChar) {
|
||||
return false;
|
||||
}
|
||||
@@ -84,7 +89,6 @@ bool appl::TextPluginMultiLineTab::onEventEntry(appl::TextViewer& _textDrawer,
|
||||
}
|
||||
// Real replace of DATA :
|
||||
_textDrawer.replace(data, itStart, itStop);
|
||||
//_textDrawer.moveCursor(itStart);
|
||||
_textDrawer.m_buffer->setSelectionPos(itStart+1);
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user