try to simplify 'buffer' manager

This commit is contained in:
Edouard Dupin 2012-07-01 21:43:57 +02:00
parent 2e974251fa
commit 7146a00371
4 changed files with 134 additions and 164 deletions

View File

@ -309,7 +309,7 @@ int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal,
m_displaySize.y = (sizeY/letterHeight) + 1;
APPL_VERBOSE("main DIPLAY " << m_displaySize.x << " char * " << m_displaySize.y << " char");
selHave = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, selStart, selEnd, selIsRect, selRectStart, selRectEnd);
selHave = m_EdnBuf.GetSelectionPos(selStart, selEnd, selIsRect, selRectStart, selRectEnd);
colorInformation_ts * HLColor = NULL;
@ -553,7 +553,7 @@ void BufferText::MouseEvent(int32_t fontId, int32_t width, int32_t height)
/*if (m_cursorPreferredCol < 0) {
m_cursorPreferredCol = posX;
}*/
m_EdnBuf.Unselect(SELECTION_PRIMARY);
m_EdnBuf.Unselect();
RequestUpdateOfThePosition();
}
@ -577,7 +577,7 @@ void BufferText::MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t
int32_t selStart, selEnd, selRectStart, selRectEnd;
bool selIsRect;
int32_t selHave = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, selStart, selEnd, selIsRect, selRectStart, selRectEnd);
int32_t selHave = m_EdnBuf.GetSelectionPos(selStart, selEnd, selIsRect, selRectStart, selRectEnd);
//APPL_DEBUG("BufferText:: " << selHave << " = BufGetSelectionPos(SELECTION_PRIMARY," << selStart << "," << selEnd << "," << selIsRect << "," << selRectStart << "," << selRectEnd << ");" );
int32_t rememberCursorPos = m_cursorPos;
// move the cursor
@ -589,12 +589,12 @@ void BufferText::MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t
}*/
if (false == selHave) {
m_EdnBuf.Select(SELECTION_PRIMARY, rememberCursorPos, m_cursorPos);
m_EdnBuf.Select(rememberCursorPos, m_cursorPos);
} else {
if (rememberCursorPos == selStart) {
m_EdnBuf.Select(SELECTION_PRIMARY, m_cursorPos, selEnd);
m_EdnBuf.Select(m_cursorPos, selEnd);
} else {
m_EdnBuf.Select(SELECTION_PRIMARY, selStart, m_cursorPos);
m_EdnBuf.Select(selStart, m_cursorPos);
}
}
Copy(ewol::clipBoard::CLIPBOARD_SELECTION);
@ -615,7 +615,7 @@ void BufferText::MouseEventDouble(void)
{
int32_t beginPos, endPos;
if (true == m_EdnBuf.SelectAround(m_cursorPos, beginPos, endPos)) {
m_EdnBuf.Select(SELECTION_PRIMARY, beginPos, endPos);
m_EdnBuf.Select(beginPos, endPos);
m_cursorPos = endPos;
}
Copy(ewol::clipBoard::CLIPBOARD_SELECTION);
@ -632,7 +632,7 @@ void BufferText::MouseEventDouble(void)
*/
void BufferText::MouseEventTriple(void)
{
m_EdnBuf.Select(SELECTION_PRIMARY, m_EdnBuf.StartOfLine(m_cursorPos), m_EdnBuf.EndOfLine(m_cursorPos));
m_EdnBuf.Select(m_EdnBuf.StartOfLine(m_cursorPos), m_EdnBuf.EndOfLine(m_cursorPos));
m_cursorPos = m_EdnBuf.EndOfLine(m_cursorPos);
Copy(ewol::clipBoard::CLIPBOARD_SELECTION);
}
@ -648,14 +648,14 @@ void BufferText::RemoveLine(void)
void BufferText::SelectAll(void)
{
m_EdnBuf.Select(SELECTION_PRIMARY, 0, m_EdnBuf.Size());
m_EdnBuf.Select(0, m_EdnBuf.Size());
m_cursorPos = m_EdnBuf.Size();
Copy(ewol::clipBoard::CLIPBOARD_SELECTION);
}
void BufferText::SelectNone(void)
{
m_EdnBuf.Unselect(SELECTION_PRIMARY);
m_EdnBuf.Unselect();
}
@ -671,13 +671,13 @@ void BufferText::SetInsertPosition(int32_t newPos, bool insertChar)
{
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
int32_t rememberCursorPos = m_cursorPos;
//APPL_DEBUG("newPos=" << newPos);
// unselect buffer:
m_EdnBuf.Unselect(SELECTION_PRIMARY);
m_EdnBuf.Unselect();
/* make sure new position is ok, do nothing if it hasn't changed */
if (newPos != m_cursorPos) {
if (newPos < 0){
@ -699,15 +699,15 @@ void BufferText::SetInsertPosition(int32_t newPos, bool insertChar)
&& true == ewol::IsSetShift() )
{
// new selection
m_EdnBuf.Select(SELECTION_PRIMARY, rememberCursorPos, m_cursorPos);
m_EdnBuf.Select(rememberCursorPos, m_cursorPos);
} else if( true == ewol::IsSetShift()
&& true == haveSelectionActive)
{
// update selection
if (rememberCursorPos == SelectionStart) {
m_EdnBuf.Select(SELECTION_PRIMARY, m_cursorPos, SelectionEnd);
m_EdnBuf.Select(m_cursorPos, SelectionEnd);
} else {
m_EdnBuf.Select(SELECTION_PRIMARY, SelectionStart, m_cursorPos);
m_EdnBuf.Select(SelectionStart, m_cursorPos);
}
}
}
@ -907,7 +907,7 @@ void BufferText::AddChar(uniChar_t unicodeData)
{
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (unicodeData == 0x09) {
if (false == haveSelectionActive) {
etk::VectorType<int8_t> tmpVect;
@ -921,13 +921,13 @@ void BufferText::AddChar(uniChar_t unicodeData)
if (0 == nbSelectedLines) {
etk::VectorType<int8_t> tmpVect;
tmpVect.PushBack(0x09);
m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect);
m_EdnBuf.ReplaceSelected(tmpVect);
SetInsertPosition(SelectionStart+tmpVect.Size(), true);
} else {
if (true == ewol::IsSetShift() ) {
m_cursorPos = m_EdnBuf.UnIndent(SELECTION_PRIMARY);
m_cursorPos = m_EdnBuf.UnIndent();
} else {
m_cursorPos = m_EdnBuf.Indent(SELECTION_PRIMARY);
m_cursorPos = m_EdnBuf.Indent();
}
}
}
@ -963,7 +963,7 @@ void BufferText::AddChar(uniChar_t unicodeData)
m_EdnBuf.Insert(m_cursorPos, tmpVect);
SetInsertPosition(m_cursorPos+tmpVect.Size(), true);
} else {
m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect);
m_EdnBuf.ReplaceSelected(tmpVect);
SetInsertPosition(SelectionStart+tmpVect.Size(), true);
}
} else if (unicodeData == 0x7F ) {
@ -971,7 +971,7 @@ void BufferText::AddChar(uniChar_t unicodeData)
if (false == haveSelectionActive) {
m_EdnBuf.Remove(m_cursorPos, m_cursorPos+1);
} else {
m_EdnBuf.RemoveSelected(SELECTION_PRIMARY);
m_EdnBuf.RemoveSelected();
SetInsertPosition(SelectionStart, true);
}
} else if (unicodeData == 0x08) {
@ -980,7 +980,7 @@ void BufferText::AddChar(uniChar_t unicodeData)
m_EdnBuf.Remove(m_cursorPos-1, m_cursorPos);
SetInsertPosition(m_cursorPos-1, true);
} else {
m_EdnBuf.RemoveSelected(SELECTION_PRIMARY);
m_EdnBuf.RemoveSelected();
SetInsertPosition(SelectionStart, true);
}
} else {
@ -995,7 +995,7 @@ void BufferText::AddChar(uniChar_t unicodeData)
m_EdnBuf.Insert(m_cursorPos, tmpVect);
SetInsertPosition(m_cursorPos+localOfset, true);
} else {
m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect);
m_EdnBuf.ReplaceSelected(tmpVect);
SetInsertPosition(SelectionStart+localOfset, true);
}
} else {
@ -1009,7 +1009,7 @@ void BufferText::AddChar(uniChar_t unicodeData)
m_EdnBuf.Insert(m_cursorPos, tmpVect);
SetInsertPosition(m_cursorPos+1, true);
} else {
m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect);
m_EdnBuf.ReplaceSelected(tmpVect);
SetInsertPosition(SelectionStart+1, true);
}
}
@ -1047,7 +1047,7 @@ int32_t BufferText::FindLine(etk::UString &data)
void BufferText::JumpAtLine(int32_t newLine)
{
int32_t positionLine = m_EdnBuf.CountForwardNLines(0, newLine);
m_EdnBuf.Unselect(SELECTION_PRIMARY);
m_EdnBuf.Unselect();
APPL_DEBUG("jump at the line : " << newLine );
SetInsertPosition(positionLine);
m_centerRequested = true;
@ -1075,7 +1075,7 @@ void BufferText::Search(etk::UString &data, bool back, bool caseSensitive, bool
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
int32_t startSearchPos = m_cursorPos;
if (true == haveSelectionActive) {
@ -1105,7 +1105,7 @@ void BufferText::Search(etk::UString &data, bool back, bool caseSensitive, bool
if (true == findSomething) {
// select new position
SetInsertPosition(foundPosEnd);
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, foundPosEnd);
m_EdnBuf.Select(foundPos, foundPosEnd);
}
} else {
//APPL_INFO("search data Backward : " << data.GetDirectPointer() );
@ -1122,7 +1122,7 @@ void BufferText::Search(etk::UString &data, bool back, bool caseSensitive, bool
if (true == findSomething) {
// select new position
SetInsertPosition(foundPos);
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, foundPosEnd);
m_EdnBuf.Select(foundPos, foundPosEnd);
}
}
m_centerRequested = true;
@ -1134,10 +1134,10 @@ void BufferText::Replace(etk::UString &data)
{
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (true == haveSelectionActive) {
// Replace Data :
int32_t size = m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, data);
int32_t size = m_EdnBuf.ReplaceSelected(data);
SetInsertPosition(SelectionStart + size);
}
SetModify(true);
@ -1156,8 +1156,8 @@ void BufferText::Copy(int8_t clipboardID)
{
etk::UString mVect;
// get the curent selected data
if (true == m_EdnBuf.SelectHasSelection(SELECTION_PRIMARY) ) {
m_EdnBuf.GetSelectionText(SELECTION_PRIMARY, mVect);
if (true == m_EdnBuf.SelectHasSelection() ) {
m_EdnBuf.GetSelectionText(mVect);
}
// copy data in the click board :
ewol::clipBoard::Set(clipboardID, mVect);
@ -1177,14 +1177,14 @@ void BufferText::Cut(int8_t clipboardID)
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
// copy data
Copy(clipboardID);
// remove data :
if (true == haveSelectionActive ) {
APPL_INFO("REMOVE SELECTION");
m_EdnBuf.RemoveSelected(SELECTION_PRIMARY);
m_EdnBuf.RemoveSelected();
m_cursorPos = SelectionStart;
}
RequestUpdateOfThePosition();
@ -1208,11 +1208,11 @@ void BufferText::Paste(int8_t clipboardID)
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (true == haveSelectionActive ) {
// replace data
int32_t size = m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, mVect );
int32_t size = m_EdnBuf.ReplaceSelected(mVect );
m_cursorPos = SelectionStart + size;
} else {
// insert data

View File

@ -56,18 +56,10 @@ EdnBuf::EdnBuf(void)
m_useTabs = true;
// Current selection
m_selectionList[SELECTION_PRIMARY].selected = false;
m_selectionList[SELECTION_PRIMARY].zeroWidth = false;
m_selectionList[SELECTION_PRIMARY].rectangular = false;
m_selectionList[SELECTION_PRIMARY].start = m_selectionList[SELECTION_PRIMARY].end = 0;
m_selectionList[SELECTION_SECONDARY].selected = false;
m_selectionList[SELECTION_SECONDARY].zeroWidth = false;
m_selectionList[SELECTION_SECONDARY].rectangular = false;
m_selectionList[SELECTION_SECONDARY].start = m_selectionList[SELECTION_SECONDARY].end = 0;
m_selectionList[SELECTION_HIGHTLIGHT].selected = false;
m_selectionList[SELECTION_HIGHTLIGHT].zeroWidth = false;
m_selectionList[SELECTION_HIGHTLIGHT].rectangular = false;
m_selectionList[SELECTION_HIGHTLIGHT].start = m_selectionList[SELECTION_HIGHTLIGHT].end = 0;
m_selectionList.selected = false;
m_selectionList.zeroWidth = false;
m_selectionList.rectangular = false;
m_selectionList.start = m_selectionList.end = 0;
// charset :
m_isUtf8 = false;
@ -116,7 +108,7 @@ bool EdnBuf::DumpFrom(FILE *myFile)
{
if (true == m_data.DumpFrom(myFile) ) {
// set no selection
UpdateSelections(0, 0, m_data.Size() );
UpdateSelection(0, 0, m_data.Size() );
// generate HighLight
CleanHighLight();
GenerateHighLightAt(0, m_data.Size());
@ -150,7 +142,7 @@ void EdnBuf::SetAll(etk::VectorType<int8_t> &text)
m_data.Insert(0, text);
// Zero all of the existing selections
UpdateSelections(0, deletedText.Size(), 0);
UpdateSelection(0, deletedText.Size(), 0);
// Call the modification Event Manager
eventModification(0, m_data.Size(), deletedText);
@ -247,6 +239,9 @@ int32_t EdnBuf::Insert(int32_t pos, etk::UString &insertText)
*/
int32_t EdnBuf::Replace(int32_t start, int32_t end, etk::VectorType<int8_t> &insertText)
{
if (end-start == 0) {
return 0;
}
etk::VectorType<int8_t> deletedText;
GetRange(start, end, deletedText);
m_data.Replace(start, end-start, insertText);
@ -254,8 +249,12 @@ int32_t EdnBuf::Replace(int32_t start, int32_t end, etk::VectorType<int8_t> &ins
eventModification(start, insertText.Size(), deletedText);
return insertText.Size();
}
int32_t EdnBuf::Replace(int32_t start, int32_t end, etk::UString &insertText)
{
if (end-start == 0) {
return 0;
}
etk::VectorType<int8_t> deletedText;
GetRange(start, end, deletedText);
etk::VectorType<int8_t> tmpInsertText;
@ -314,17 +313,17 @@ void EdnBuf::Remove(int32_t start, int32_t end)
}
int32_t EdnBuf::Indent(selectionType_te select)
int32_t EdnBuf::Indent(void)
{
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = GetSelectionPos(select, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (false == haveSelectionActive) {
return SelectionEnd;
}
// Disable selection:
Unselect(select);
Unselect();
// Get Range :
int32_t l_start = StartOfLine(SelectionStart);
int32_t l_end = EndOfLine(SelectionEnd);
@ -348,22 +347,22 @@ int32_t EdnBuf::Indent(selectionType_te select)
Replace(l_start, l_end, l_tmpData);
// Set the new selection :
l_end = l_start + l_tmpData.Size();
Select(select, l_start, l_end);
Select(l_start, l_end);
// Return the position of the cursor
return l_end;
}
int32_t EdnBuf::UnIndent(selectionType_te select)
int32_t EdnBuf::UnIndent(void)
{
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = GetSelectionPos(select, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (false == haveSelectionActive) {
return SelectionEnd;
}
// Disable selection:
Unselect(select);
Unselect();
// Get Range :
int32_t l_start = StartOfLine(SelectionStart);
int32_t l_end = EndOfLine(SelectionEnd);
@ -394,7 +393,7 @@ int32_t EdnBuf::UnIndent(selectionType_te select)
Replace(l_start, l_end, l_tmpData);
// Set the new selection :
l_end = l_start + l_tmpData.Size();
Select(select, l_start, l_end);
Select(l_start, l_end);
// Return the position of the cursor
return l_end;
}
@ -1187,7 +1186,7 @@ int32_t EdnBuf::LocalInsert(int32_t pos, etk::VectorType<int8_t> &insertText)
// Insert data in buffer
m_data.Insert(pos, insertText);
// update the current selected area
UpdateSelections(pos, 0, insertText.Size() );
UpdateSelection(pos, 0, insertText.Size() );
// return the number of element inserted ...
return insertText.Size();
}

View File

@ -58,14 +58,6 @@ typedef struct {
int32_t rectEnd; //!< Indent of right edge of rect. selection
} selection;
typedef enum{
SELECTION_PRIMARY,
SELECTION_SECONDARY,
SELECTION_HIGHTLIGHT,
SELECTION_SIZE
}selectionType_te;
typedef struct {
etk::VectorType<colorInformation_ts> HLData;
int32_t posHLPass1;
@ -95,8 +87,8 @@ class EdnBuf {
int32_t Replace( int32_t start, int32_t end, etk::VectorType<int8_t> &insertText);
int32_t Replace( int32_t start, int32_t end, etk::UString &insertText);
void Remove( int32_t start, int32_t end);
int32_t Indent( selectionType_te select);
int32_t UnIndent( selectionType_te select);
int32_t Indent( void);
int32_t UnIndent( void);
void GetLineText( int32_t pos, etk::VectorType<int8_t> &text);
@ -123,27 +115,26 @@ class EdnBuf {
// Buffer Size system :
int32_t Size(void) { return m_data.Size(); };
int32_t NumberOfLines(void) {return m_nbLine;};
int32_t NumberOfLines(void) { return m_nbLine; };
// -----------------------------------------
// selection remember...
// -----------------------------------------
public:
bool SelectHasSelection( selectionType_te select);
void Select( selectionType_te select, int32_t start, int32_t end);
void Unselect( selectionType_te select);
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);
void GetSelectionText( selectionType_te select, etk::VectorType<int8_t> &text);
void GetSelectionText( selectionType_te select, etk::UString &text);
void RemoveSelected( selectionType_te select);
int32_t ReplaceSelected( selectionType_te select, etk::VectorType<int8_t> &text);
int32_t ReplaceSelected( selectionType_te select, etk::UString &text);
bool SelectHasSelection(void);
void Select( int32_t start, int32_t end);
void Unselect( void);
void RectSelect( int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd);
bool GetSelectionPos( int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd);
void GetSelectionText( etk::VectorType<int8_t> &text);
void GetSelectionText( etk::UString &text);
void RemoveSelected( void);
int32_t ReplaceSelected( etk::VectorType<int8_t> &text);
int32_t ReplaceSelected( etk::UString &text);
private:
// current selection of the buffer
selection m_selectionList[SELECTION_SIZE]; //!< Selection area of the buffer
void UpdateSelection( selectionType_te select, int32_t pos, int32_t nDeleted, int32_t nInserted);
void UpdateSelections( int32_t pos, int32_t nDeleted, int32_t nInserted);
selection m_selectionList; //!< Selection area of the buffer
void UpdateSelection( int32_t pos, int32_t nDeleted, int32_t nInserted);
// -----------------------------------------
// History section :

View File

@ -41,9 +41,9 @@
* @return ---
*
*/
bool EdnBuf::SelectHasSelection(selectionType_te select)
bool EdnBuf::SelectHasSelection(void)
{
return m_selectionList[select].selected;
return m_selectionList.selected;
}
@ -56,14 +56,14 @@ bool EdnBuf::SelectHasSelection(selectionType_te select)
* @return ---
*
*/
void EdnBuf::Select(selectionType_te select, int32_t start, int32_t end)
void EdnBuf::Select(int32_t start, int32_t end)
{
//selection oldSelection = m_selectionList[select];
m_selectionList[select].selected = start != end;
m_selectionList[select].zeroWidth = (start == end) ? true : false;
m_selectionList[select].rectangular = false;
m_selectionList[select].start = etk_min(start, end);
m_selectionList[select].end = etk_max(start, end);
m_selectionList.selected = start != end;
m_selectionList.zeroWidth = (start == end) ? true : false;
m_selectionList.rectangular = false;
m_selectionList.start = etk_min(start, end);
m_selectionList.end = etk_max(start, end);
}
@ -75,11 +75,11 @@ void EdnBuf::Select(selectionType_te select, int32_t start, int32_t end)
* @return ---
*
*/
void EdnBuf::Unselect(selectionType_te select)
void EdnBuf::Unselect(void)
{
//selection oldSelection = m_selectionList[select];
m_selectionList[select].selected = false;
m_selectionList[select].zeroWidth = false;
m_selectionList.selected = false;
m_selectionList.zeroWidth = false;
}
@ -94,15 +94,15 @@ void EdnBuf::Unselect(selectionType_te select)
* @return ---
*
*/
void EdnBuf::RectSelect(selectionType_te select, int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd)
void EdnBuf::RectSelect(int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd)
{
m_selectionList[select].selected = rectStart < rectEnd;
m_selectionList[select].zeroWidth = (rectStart == rectEnd) ? false : true;
m_selectionList[select].rectangular = true;
m_selectionList[select].start = start;
m_selectionList[select].end = end;
m_selectionList[select].rectStart = rectStart;
m_selectionList[select].rectEnd = rectEnd;
m_selectionList.selected = rectStart < rectEnd;
m_selectionList.zeroWidth = (rectStart == rectEnd) ? false : true;
m_selectionList.rectangular = true;
m_selectionList.start = start;
m_selectionList.end = end;
m_selectionList.rectStart = rectStart;
m_selectionList.rectEnd = rectEnd;
}
@ -114,17 +114,17 @@ void EdnBuf::RectSelect(selectionType_te select, int32_t start, int32_t end, int
* @return ---
*
*/
bool EdnBuf::GetSelectionPos(selectionType_te select, int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd)
bool EdnBuf::GetSelectionPos(int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd)
{
/* Always fill in the parameters (zero-width can be requested too). */
isRect = m_selectionList[select].rectangular;
start = m_selectionList[select].start;
end = m_selectionList[select].end;
if (m_selectionList[select].rectangular) {
rectStart = m_selectionList[select].rectStart;
rectEnd = m_selectionList[select].rectEnd;
isRect = m_selectionList.rectangular;
start = m_selectionList.start;
end = m_selectionList.end;
if (m_selectionList.rectangular) {
rectStart = m_selectionList.rectStart;
rectEnd = m_selectionList.rectEnd;
}
return m_selectionList[select].selected;
return m_selectionList.selected;
}
@ -136,14 +136,14 @@ bool EdnBuf::GetSelectionPos(selectionType_te select, int32_t &start, int32_t &e
* @return ---
*
*/
void EdnBuf::GetSelectionText(selectionType_te select, etk::VectorType<int8_t> &text)
void EdnBuf::GetSelectionText(etk::VectorType<int8_t> &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
// remove output data
text.Clear();
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
@ -158,14 +158,14 @@ void EdnBuf::GetSelectionText(selectionType_te select, etk::VectorType<int8_t> &
GetRange(start, end, text);
}
}
void EdnBuf::GetSelectionText(selectionType_te select, etk::UString &text)
void EdnBuf::GetSelectionText(etk::UString &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
// remove output data
text = "";
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
@ -190,12 +190,12 @@ void EdnBuf::GetSelectionText(selectionType_te select, etk::UString &text)
* @return ---
*
*/
void EdnBuf::RemoveSelected(selectionType_te select)
void EdnBuf::RemoveSelected(void)
{
int32_t start, end;
int32_t rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
@ -208,7 +208,7 @@ void EdnBuf::RemoveSelected(selectionType_te select)
} else {
Remove(start, end);
}
Unselect(select);
Unselect();
}
@ -220,11 +220,11 @@ void EdnBuf::RemoveSelected(selectionType_te select)
* @return ---
*
*/
int32_t EdnBuf::ReplaceSelected(selectionType_te select, etk::VectorType<int8_t> &text)
int32_t EdnBuf::ReplaceSelected(etk::VectorType<int8_t> &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
@ -239,14 +239,14 @@ int32_t EdnBuf::ReplaceSelected(selectionType_te select, etk::VectorType<int8_t>
returnSize = Replace(start, end, text);
}
// Clean selection
m_selectionList[select].selected = false;
m_selectionList.selected = false;
return returnSize;
}
int32_t EdnBuf::ReplaceSelected(selectionType_te select, etk::UString &text)
int32_t EdnBuf::ReplaceSelected(etk::UString &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
@ -261,31 +261,11 @@ int32_t EdnBuf::ReplaceSelected(selectionType_te select, etk::UString &text)
returnSize = Replace(start, end, text);
}
// Clean selection
m_selectionList[select].selected = false;
m_selectionList.selected = false;
return returnSize;
}
/*
** Update all of the selections in "buf" for changes in the buffer's text
*/
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::UpdateSelections(int32_t pos, int32_t nDeleted, int32_t nInserted)
{
UpdateSelection(SELECTION_PRIMARY , pos, nDeleted, nInserted);
UpdateSelection(SELECTION_SECONDARY , pos, nDeleted, nInserted);
UpdateSelection(SELECTION_HIGHTLIGHT, pos, nDeleted, nInserted);
}
/*
** Update an individual selection for changes in the corresponding text
*/
@ -297,33 +277,33 @@ void EdnBuf::UpdateSelections(int32_t pos, int32_t nDeleted, int32_t nInserted)
* @return ---
*
*/
void EdnBuf::UpdateSelection(selectionType_te select, int32_t pos, int32_t nDeleted, int32_t nInserted)
void EdnBuf::UpdateSelection(int32_t pos, int32_t nDeleted, int32_t nInserted)
{
if( ( false == m_selectionList[select].selected
&& false == m_selectionList[select].zeroWidth)
|| pos > m_selectionList[select].end )
if( ( false == m_selectionList.selected
&& false == m_selectionList.zeroWidth)
|| pos > m_selectionList.end )
{
return;
}
if (pos+nDeleted <= m_selectionList[select].start) {
m_selectionList[select].start += nInserted - nDeleted;
m_selectionList[select].end += nInserted - nDeleted;
} else if( pos <= m_selectionList[select].start
&& pos+nDeleted >= m_selectionList[select].end)
if (pos+nDeleted <= m_selectionList.start) {
m_selectionList.start += nInserted - nDeleted;
m_selectionList.end += nInserted - nDeleted;
} else if( pos <= m_selectionList.start
&& pos+nDeleted >= m_selectionList.end)
{
m_selectionList[select].start = pos;
m_selectionList[select].end = pos;
m_selectionList[select].selected = false;
m_selectionList[select].zeroWidth = false;
} else if( pos <= m_selectionList[select].start
&& pos+nDeleted < m_selectionList[select].end)
m_selectionList.start = pos;
m_selectionList.end = pos;
m_selectionList.selected = false;
m_selectionList.zeroWidth = false;
} else if( pos <= m_selectionList.start
&& pos+nDeleted < m_selectionList.end)
{
m_selectionList[select].start = pos;
m_selectionList[select].end = nInserted + m_selectionList[select].end - nDeleted;
} else if(pos < m_selectionList[select].end) {
m_selectionList[select].end += nInserted - nDeleted;
if (m_selectionList[select].end <= m_selectionList[select].start) {
m_selectionList[select].selected = false;
m_selectionList.start = pos;
m_selectionList.end = nInserted + m_selectionList.end - nDeleted;
} else if(pos < m_selectionList.end) {
m_selectionList.end += nInserted - nDeleted;
if (m_selectionList.end <= m_selectionList.start) {
m_selectionList.selected = false;
}
}
}