work on the copy/past on ewol

This commit is contained in:
Edouard Dupin 2012-04-04 18:18:27 +02:00
parent f2bcd9052b
commit c75fb80736
8 changed files with 100 additions and 83 deletions

View File

@ -2,6 +2,7 @@
<EdnLang version="0.1" lang="c"> <EdnLang version="0.1" lang="c">
<ext>*.c</ext> <ext>*.c</ext>
<ext>*.cpp</ext> <ext>*.cpp</ext>
<ext>*.cc</ext>
<ext>*.h</ext> <ext>*.h</ext>
<ext>*.hpp</ext> <ext>*.hpp</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification --> <pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->

View File

@ -5,7 +5,15 @@ include $(CLEAR_VARS)
# load the common sources file of the platform # load the common sources file of the platform
include $(LOCAL_PATH)/file.mk include $(LOCAL_PATH)/file.mk
# name of the librairy
LOCAL_MODULE := ednpackage LOCAL_MODULE := ednpackage
# get the tag of the current project :
LOCAL_VERSION_TAG=$(shell cd $(LOCAL_PATH) ; git describe --tags)
LOCAL_VERSION_TAG_SHORT=$(shell cd $(LOCAL_PATH) ; git describe --tags --abbrev=0)
$(info $(LOCAL_MODULE) version TAG : $(LOCAL_VERSION_TAG))
# name of the dependency
LOCAL_STATIC_LIBRARIES := ewol etk tinyxml libzip libpng libfreetype libparsersvg libagg LOCAL_STATIC_LIBRARIES := ewol etk tinyxml libzip libpng libfreetype libparsersvg libagg
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST)))) LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))

View File

@ -8,7 +8,6 @@ include $(LOCAL_PATH)/file.mk
# name of the librairy # name of the librairy
LOCAL_MODULE := ednn LOCAL_MODULE := ednn
# get the tag of the current project : # get the tag of the current project :
LOCAL_VERSION_TAG=$(shell cd $(LOCAL_PATH) ; git describe --tags) LOCAL_VERSION_TAG=$(shell cd $(LOCAL_PATH) ; git describe --tags)
LOCAL_VERSION_TAG_SHORT=$(shell cd $(LOCAL_PATH) ; git describe --tags --abbrev=0) LOCAL_VERSION_TAG_SHORT=$(shell cd $(LOCAL_PATH) ; git describe --tags --abbrev=0)

View File

@ -25,7 +25,6 @@
#include <tools_debug.h> #include <tools_debug.h>
#include <tools_globals.h> #include <tools_globals.h>
#include <ClipBoard.h>
#include <BufferText.h> #include <BufferText.h>
#include <toolsMemory.h> #include <toolsMemory.h>
#include <etk/RegExp.h> #include <etk/RegExp.h>
@ -36,6 +35,7 @@
#include <ewol/WidgetManager.h> #include <ewol/WidgetManager.h>
#include <ewol/Widget.h> #include <ewol/Widget.h>
#include <ewol/Font.h> #include <ewol/Font.h>
#include <ewol/ClipBoard.h>
#undef __class__ #undef __class__
@ -1180,14 +1180,15 @@ void BufferText::Replace(etk::UString &data)
*/ */
void BufferText::Copy(int8_t clipboardID) void BufferText::Copy(int8_t clipboardID)
{ {
etk::VectorType<uniChar_t> mVect; //etk::VectorType<uniChar_t> mVect;
etk::UString mVect;
// get the curent selected data // get the curent selected data
if (true == m_EdnBuf.SelectHasSelection(SELECTION_PRIMARY) ) { if (true == m_EdnBuf.SelectHasSelection(SELECTION_PRIMARY) ) {
//m_EdnBuf.GetSelectionText(SELECTION_PRIMARY, mVect); m_EdnBuf.GetSelectionText(SELECTION_PRIMARY, mVect);
EDN_TODO("Remove for now ..."); EDN_TODO("Remove for now ...");
} }
// copy data in the click board : // copy data in the click board :
//ClipBoard::Set(clipboardID, mVect); ewol::clipBoard::Set(clipboardID, mVect);
EDN_TODO("Remove for now ..."); EDN_TODO("Remove for now ...");
} }
@ -1230,12 +1231,12 @@ void BufferText::Cut(int8_t clipboardID)
*/ */
void BufferText::Paste(int8_t clipboardID) void BufferText::Paste(int8_t clipboardID)
{ {
etk::VectorType<uniChar_t> mVect; //etk::VectorType<uniChar_t> mVect;
etk::UString mVect;
EDN_TODO("Remove for now ..."); EDN_TODO("Remove for now ...");
/* /*
// copy data from the click board : // copy data from the click board :
ClipBoard::Get(clipboardID, mVect); ewol::clipBoard::Get(clipboardID, mVect);
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd; int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect; bool SelectionIsRect;

View File

@ -32,7 +32,7 @@
#include <CodeView.h> #include <CodeView.h>
#include <BufferManager.h> #include <BufferManager.h>
#include <ColorizeManager.h> #include <ColorizeManager.h>
#include <ClipBoard.h> #include <ewol/ClipBoard.h>
#include <SearchData.h> #include <SearchData.h>
#include <ewol/WidgetManager.h> #include <ewol/WidgetManager.h>
@ -68,6 +68,9 @@ CodeView::CodeView(void)
m_textColorBg.alpha = 0.25; m_textColorBg.alpha = 0.25;
SetCanHaveFocus(true); SetCanHaveFocus(true);
RegisterMultiCast(ednMsgBufferId); RegisterMultiCast(ednMsgBufferId);
RegisterMultiCast(ednMsgGuiCopy);
RegisterMultiCast(ednMsgGuiPaste);
RegisterMultiCast(ednMsgGuiCut);
} }
CodeView::~CodeView(void) CodeView::~CodeView(void)
@ -222,7 +225,7 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent,
MarkToReedraw(); MarkToReedraw();
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { } else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
m_buttunOneSelected = false; m_buttunOneSelected = false;
BufferManager::Get(m_bufferID)->Copy(COPY_MIDDLE_BUTTON); BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_SELECTION);
MarkToReedraw(); MarkToReedraw();
} else } else
#endif #endif
@ -259,7 +262,7 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent,
} else if (2 == IdInput) { } else if (2 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y); BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
BufferManager::Get(m_bufferID)->Paste(COPY_MIDDLE_BUTTON); BufferManager::Get(m_bufferID)->Paste(ewol::clipBoard::CLIPBOARD_SELECTION);
MarkToReedraw(); MarkToReedraw();
ewol::widgetManager::FocusKeep(this); ewol::widgetManager::FocusKeep(this);
} }
@ -289,59 +292,13 @@ void CodeView::OnReceiveMessage(ewol::EObject * CallerObject, const char * event
EDN_INFO("Select a new Buffer ... " << bufferID); EDN_INFO("Select a new Buffer ... " << bufferID);
m_bufferID = bufferID; m_bufferID = bufferID;
// TODO : need to update the state of the file and the filenames ... // TODO : need to update the state of the file and the filenames ...
} else if (eventId == ednMsgGuiCopy) {
BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_STD);
} else if (eventId == ednMsgGuiCut) {
BufferManager::Get(m_bufferID)->Cut(ewol::clipBoard::CLIPBOARD_STD);
} else if (eventId == ednMsgGuiPaste) {
BufferManager::Get(m_bufferID)->Paste(ewol::clipBoard::CLIPBOARD_STD);
} }
// old
/*
else if( ednMsgCodeViewCurrentChangeBufferId == generateEventId) {
int32_t bufferID = 0;
sscanf(data, "%d", &bufferID);
EDN_INFO("Select a new Buffer ... " << bufferID);
m_bufferID = bufferID;
BufferManager::Get(m_bufferID)->ForceReDraw(true);
// request the display of the curent Editor
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferChangeCurrent, (char*)data);
}
*/
/*
else if (ednMsgCodeViewCurrentSave == generateEventId) {
} else if (ednMsgCodeViewCurrentSaveAs == generateEventId) {
} else if (ednMsgCodeViewCurrentSelectAll == generateEventId) {
} else if (ednMsgCodeViewCurrentRemoveLine == generateEventId) {
} else if (ednMsgCodeViewCurrentUnSelect == generateEventId) {
} else if (ednMsgCodeViewCurrentCopy == generateEventId) {
} else if (ednMsgCodeViewCurrentCut == generateEventId) {
} else if (ednMsgCodeViewCurrentPaste == generateEventId) {
} else if (ednMsgCodeViewCurrentFindPrevious == generateEventId) {
} else if (ednMsgCodeViewCurrentFindNext == generateEventId) {
} else if (ednMsgCodeViewCurrentFindOldNext == generateEventId) {
} else if (ednMsgCodeViewCurrentReplace == generateEventId) {
} else if (ednMsgCodeViewCurrentReplaceAll == generateEventId) {
} else if (ednMsgCodeViewCurrentClose == generateEventId) {
} else if (ednMsgCodeViewCurrentUndo == generateEventId) {
} else if (ednMsgCodeViewCurrentRedo == generateEventId) {
} else if (ednMsgCodeViewCurrentGotoLine == generateEventId) {
} else if (ednMsgCodeViewCurrentSetCharset == generateEventId) {
}
*/
else { else {
} }
@ -371,24 +328,6 @@ void CodeView::OnReceiveMessage(ewol::EObject * CallerObject, const char * event
case EDN_MSG__CURRENT_UN_SELECT: case EDN_MSG__CURRENT_UN_SELECT:
BufferManager::Get(m_bufferID)->SelectNone(); BufferManager::Get(m_bufferID)->SelectNone();
break; break;
case EDN_MSG__CURRENT_COPY:
if (dataID == -1) {
dataID = COPY_STD;
}
BufferManager::Get(m_bufferID)->Copy(dataID);
break;
case EDN_MSG__CURRENT_CUT:
if (dataID == -1) {
dataID = COPY_STD;
}
BufferManager::Get(m_bufferID)->Cut(dataID);
break;
case EDN_MSG__CURRENT_PASTE:
if (dataID == -1) {
dataID = COPY_STD;
}
BufferManager::Get(m_bufferID)->Paste(dataID);
break;
case EDN_MSG__CURRENT_FIND_PREVIOUS: case EDN_MSG__CURRENT_FIND_PREVIOUS:
{ {
etk::UString myDataString; etk::UString myDataString;

View File

@ -164,6 +164,18 @@ void EdnBuf::GetRange(int32_t start, int32_t end, etk::VectorType<int8_t> &outpu
//EDN_DEBUG("request start=" << start << " end="<< end << " size="<< end-start << " result size=" << output.Size() ); //EDN_DEBUG("request start=" << start << " end="<< end << " size="<< end-start << " result size=" << output.Size() );
} }
void EdnBuf::GetRange(int32_t start, int32_t end, etk::Ustring &output)
{
// Remove all data ...
output = "";
// import data :
etk::VectorType<int8_t> &localOutput;
m_data.Get(start, end-start, localOutput);
// transcript in UNICODE ...
// TODO : ldkjqlsdjfqslkjd
//EDN_DEBUG("request start=" << start << " end="<< end << " size="<< end-start << " result size=" << output.Size() );
}
/** /**
* @brief Get an element at the selected position * @brief Get an element at the selected position
@ -220,6 +232,17 @@ void EdnBuf::Replace(int32_t start, int32_t end, etk::VectorType<int8_t> &insert
// update internal elements // update internal elements
eventModification(start, insertText.Size(), deletedText); eventModification(start, insertText.Size(), deletedText);
} }
void EdnBuf::Replace(int32_t start, int32_t end, etk::UString &insertText)
{
etk::VectorType<int8_t> deletedText;
GetRange(start, end, deletedText);
etk::VectorType<int8_t> tmpInsertText;
insertText
// TODO : Unicode to utf8 ...
m_data.Replace(start, end-start, tmpInsertText);
// update internal elements
eventModification(start, tmpInsertText.Size(), deletedText);
}
/** /**

View File

@ -85,12 +85,14 @@ class EdnBuf {
void GetAll( etk::VectorType<int8_t> &text); void GetAll( etk::VectorType<int8_t> &text);
void SetAll( etk::VectorType<int8_t> &text); void SetAll( etk::VectorType<int8_t> &text);
void GetRange( int32_t start, int32_t end, etk::VectorType<int8_t> &output); void GetRange( int32_t start, int32_t end, etk::VectorType<int8_t> &output);
void GetRange( int32_t start, int32_t end, etk::UString &output);
bool DumpIn( FILE *myFile); bool DumpIn( FILE *myFile);
bool DumpFrom( FILE *myFile); bool DumpFrom( FILE *myFile);
// replace with operator [] ... // replace with operator [] ...
int8_t operator[] (int32_t); int8_t operator[] (int32_t);
void Insert( int32_t pos, etk::VectorType<int8_t> &insertText); void Insert( int32_t pos, etk::VectorType<int8_t> &insertText);
void Replace( int32_t start, int32_t end, etk::VectorType<int8_t> &insertText); void Insert( int32_t pos, etk::UString &insertText);
void Replace( int32_t start, int32_t end, etk::UString &insertText);
void Remove( int32_t start, int32_t end); void Remove( int32_t start, int32_t end);
int32_t Indent( selectionType_te select); int32_t Indent( selectionType_te select);
int32_t UnIndent( selectionType_te select); int32_t UnIndent( selectionType_te select);
@ -132,8 +134,10 @@ class EdnBuf {
void RectSelect( selectionType_te select, int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd); void RectSelect( selectionType_te select, int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd);
bool GetSelectionPos( selectionType_te select, int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd); bool GetSelectionPos( selectionType_te select, int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd);
void GetSelectionText( selectionType_te select, etk::VectorType<int8_t> &text); void GetSelectionText( selectionType_te select, etk::VectorType<int8_t> &text);
void GetSelectionText( selectionType_te select, etk::UString &text);
void RemoveSelected( selectionType_te select); void RemoveSelected( selectionType_te select);
void ReplaceSelected( selectionType_te select, etk::VectorType<int8_t> &text); void ReplaceSelected( selectionType_te select, etk::VectorType<int8_t> &text);
void ReplaceSelected( selectionType_te select, etk::UString &text);
private: private:
// current selection of the buffer // current selection of the buffer
selection m_selectionList[SELECTION_SIZE]; //!< Selection area of the buffer selection m_selectionList[SELECTION_SIZE]; //!< Selection area of the buffer

View File

@ -158,6 +158,28 @@ void EdnBuf::GetSelectionText(selectionType_te select, etk::VectorType<int8_t> &
GetRange(start, end, text); GetRange(start, end, text);
} }
} }
void EdnBuf::GetSelectionText(selectionType_te select, etk::UString &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
// remove output data
text = "";
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//GetTextInRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
GetRange(start, end, text);
}
}
/** /**
@ -218,6 +240,26 @@ void EdnBuf::ReplaceSelected(selectionType_te select, etk::VectorType<int8_t> &t
// Clean selection // Clean selection
m_selectionList[select].selected = false; m_selectionList[select].selected = false;
} }
void EdnBuf::ReplaceSelected(selectionType_te select, etk::UString &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//ReplaceRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
Replace(start, end, text);
}
// Clean selection
m_selectionList[select].selected = false;
}