[DEV] buffer manager better work

This commit is contained in:
2013-10-29 21:13:45 +01:00
parent 7ddaa68bb0
commit 50c1830696
12 changed files with 176 additions and 55 deletions

View File

@@ -68,10 +68,10 @@ void BufferView::onReceiveMessage(const ewol::EMessage& _msg) {
// clean The list
removeAllElement();
// get all the buffer name and properties:
int32_t nbBufferOpen = BufferManager::size();
int32_t nbBufferOpen = 0; // BufferManager::size();
for (int32_t iii=0; iii<nbBufferOpen; iii++) {
/*
if (BufferManager::exist(iii)) {
/*
BufferText* tmpBuffer = BufferManager::get(iii);
if (NULL != tmpBuffer) {
bool isModify = tmpBuffer->isModify();
@@ -83,15 +83,15 @@ void BufferView::onReceiveMessage(const ewol::EMessage& _msg) {
APPL_ERROR("Allocation error of the tmp buffer list element");
}
}
*/
}
*/
}
if (true == globals::OrderTheBufferList() ) {
SortElementList(m_list);
}
markToRedraw();
}else if (_msg.getMessage() == ednMsgBufferId) {
m_selectedIdRequested = BufferManager::getSelected();
m_selectedIdRequested = 0; //BufferManager::getSelected();
markToRedraw();
}else if (_msg.getMessage() == ednMsgBufferState) {
// update list of modify section ...

View File

@@ -282,15 +282,15 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
widget::FileChooser* tmpWidget = new widget::FileChooser();
tmpWidget->setTitle("Open files ...");
tmpWidget->setValidateLabel("Open");
/*
if (BufferManager::getSelected()!=-1) {
/*
BufferText * myBuffer = BufferManager::get(BufferManager::getSelected());
if (NULL!=myBuffer) {
etk::FSNode tmpFile = myBuffer->getFileName();
tmpWidget->setFolder(tmpFile.getNameFolder());
}
*/
}
*/
popUpWidgetPush(tmpWidget);
tmpWidget->registerOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSelected);
} else if (_msg.getMessage() == ednEventPopUpFileSelected) {
@@ -302,15 +302,14 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
} else {
m_currentSavingAsIdBuffer = -1;
if (_msg.getData() == "current") {
m_currentSavingAsIdBuffer = BufferManager::getSelected();
m_currentSavingAsIdBuffer = -1;//BufferManager::getSelected();
} else {
sscanf(_msg.getData().c_str(), "%d", &m_currentSavingAsIdBuffer);
}
/*
if (false == BufferManager::exist(m_currentSavingAsIdBuffer)) {
APPL_ERROR("Request saveAs on non existant Buffer ID=" << m_currentSavingAsIdBuffer);
} else {
/*
BufferText* myBuffer = BufferManager::get(m_currentSavingAsIdBuffer);
widget::FileChooser* tmpWidget = new widget::FileChooser();
if (NULL == tmpWidget) {
@@ -330,16 +329,17 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
popUpWidgetPush(tmpWidget);
tmpWidget->registerOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSaveAs);
}
*/
}
*/
}
} else if (_msg.getMessage() == ednEventPopUpFileSaveAs) {
// get the filename :
etk::UString tmpData = _msg.getData();
APPL_DEBUG("Request Saving As file : " << tmpData);
/*
BufferManager::get(m_currentSavingAsIdBuffer)->setFileName(tmpData);
sendMultiCast(ednMsgGuiSave, m_currentSavingAsIdBuffer);
*/
} else if( _msg.getMessage() == ednMsgBufferState
|| _msg.getMessage() == ednMsgBufferId) {
// the buffer change we need to update the widget string

View File

@@ -33,6 +33,7 @@ appl::TextViewer::TextViewer(const etk::UString& _fontName, int32_t _fontSize) :
registerMultiCast(ednMsgGuiFind);
registerMultiCast(ednMsgGuiReplace);
registerMultiCast(ednMsgGuiGotoLine);
registerMultiCast(appl::MsgSelectNewFile);
setLimitScrolling(0.2);
shortCutAdd("ctrl+w", ednMsgGuiRm, "Line");
@@ -40,6 +41,9 @@ appl::TextViewer::TextViewer(const etk::UString& _fontName, int32_t _fontSize) :
shortCutAdd("ctrl+a", ednMsgGuiSelect, "ALL");
shortCutAdd("ctrl+shift+a", ednMsgGuiSelect, "NONE");
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();
// load color properties
m_paintingProperties = appl::GlyphPainting::keep("THEME:COLOR:textViewer.json");
// get all id properties ...
@@ -65,6 +69,12 @@ appl::TextViewer::TextViewer(const etk::UString& _fontName, int32_t _fontSize) :
appl::TextViewer::~TextViewer(void) {
appl::textPluginManager::disconnect(*this);
if (m_paintingProperties != NULL) {
appl::GlyphPainting::release(m_paintingProperties);
}
if (m_bufferManager != NULL) {
appl::BufferManager::release(m_bufferManager);
}
}
bool appl::TextViewer::calculateMinSize(void) {
@@ -519,13 +529,24 @@ void appl::TextViewer::onEventClipboard(ewol::clipBoard::clipboardListe_te _clip
void appl::TextViewer::onReceiveMessage(const ewol::EMessage& _msg) {
// First call plugin
//APPL_DEBUG("receive msg: " << _msg);
if (appl::textPluginManager::onReceiveMessage(*this, _msg) == true) {
markToRedraw();
return;
}
if (_msg.getMessage() == appl::MsgSelectNewFile) {
m_buffer = m_bufferManager->get(_msg.getData());
}
markToRedraw();
}
void appl::TextViewer::onObjectRemove(ewol::EObject* _removeObject) {
if (m_buffer == _removeObject) {
m_buffer = NULL;
markToRedraw();
}
}
void appl::TextViewer::onGetFocus(void) {
showKeyboard();
APPL_INFO("Focus - In");

View File

@@ -16,6 +16,7 @@
#include <ewol/widget/WidgetScrolled.h>
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Drawing.h>
#include <appl/BufferManager.h>
namespace appl {
class TextViewerPlugin;
@@ -38,6 +39,8 @@ namespace appl {
esize_t m_colorLineNumber;
esize_t m_colorSelection;
esize_t m_colorNormal;
private:
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
public:
TextViewer(const etk::UString& _fontName="", int32_t _fontSize=-1);
virtual ~TextViewer(void);
@@ -55,6 +58,7 @@ namespace appl {
virtual bool calculateMinSize(void);
virtual void onRegenerateDisplay(void);
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool onEventEntry(const ewol::EventEntry& _event);
virtual void onEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID);