[DEV] Try to simplify the text editor with the buffer system ==> step 1 : remove the multiple type of buffer (text & empty)
This commit is contained in:
@@ -1,140 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Buffer.c
|
||||
* @brief Editeur De N'ours : Text Buffer
|
||||
* @author Edouard DUPIN
|
||||
* @date 08/12/2010
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <Buffer.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Buffer"
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Buffer::Buffer()
|
||||
{
|
||||
static int32_t fileBasicID = 0;
|
||||
m_updatePositionRequested = false;
|
||||
m_fileModify = true;
|
||||
m_haveName = false;
|
||||
etk::UString mString = "Untitle - ";
|
||||
mString += fileBasicID++;
|
||||
EWOL_DEBUG("Create buffer try name : \"" << mString << "\"");
|
||||
SetFileName(mString);
|
||||
m_haveName = false;
|
||||
EWOL_DEBUG("Create buffer with name : " << m_fileName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Buffer::Buffer(etk::FSNode &newName)
|
||||
{
|
||||
m_fileModify = false;
|
||||
EWOL_DEBUG("Create buffer try name : \"" << newName << "\"");
|
||||
SetFileName(newName);
|
||||
EWOL_DEBUG("Create buffer with name : " << m_fileName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Buffer::~Buffer(void)
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool Buffer::IsModify(void)
|
||||
{
|
||||
return m_fileModify;
|
||||
}
|
||||
|
||||
void Buffer::SetModify(bool status)
|
||||
{
|
||||
if (status != m_fileModify) {
|
||||
m_fileModify = status;
|
||||
// TODO : Remove from here
|
||||
etk::UString data = "Modify";
|
||||
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgBufferState, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool Buffer::NeedToUpdateDisplayPosition(void)
|
||||
{
|
||||
bool tmpVal = m_updatePositionRequested;
|
||||
m_updatePositionRequested = false;
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
etk::Vector2D<float> Buffer::GetBorderSize(void)
|
||||
{
|
||||
etk::Vector2D<float> tmpVal;
|
||||
tmpVal.x = 30;
|
||||
tmpVal.y = 30;
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
|
||||
etk::Vector2D<float> Buffer::GetPosition(int32_t fontId,bool& centerRequested)
|
||||
{
|
||||
centerRequested = false;
|
||||
etk::Vector2D<float> tmpVal;
|
||||
tmpVal.x = 0;
|
||||
tmpVal.y = 0;
|
||||
return tmpVal;
|
||||
}
|
@@ -1,136 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Buffer.h
|
||||
* @brief Editeur De N'ours : Text Buffer (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 08/12/2010
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __BUFFER_H__
|
||||
#define __BUFFER_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <etk/unicode.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/compositing/Drawing.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
|
||||
|
||||
typedef struct{
|
||||
uint32_t nbTotalLine; //!< Number of line in the buffer
|
||||
uint32_t nbTotalColomn; //!< Number of line in the buffer
|
||||
uint32_t startLineDisplay; //!< First line display.
|
||||
uint32_t startColomnDisplay; //!< First Colomn displayed
|
||||
uint32_t diplayableColomn; //!< NB colomn that can be displayed
|
||||
uint32_t diplayableLine; //!< NB Line that can be displayed
|
||||
}infoStatBuffer_ts;
|
||||
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer(void);
|
||||
Buffer(etk::FSNode &newName);
|
||||
virtual ~Buffer(void);
|
||||
|
||||
etk::FSNode GetFileName(void)
|
||||
{
|
||||
return m_fileName;
|
||||
};
|
||||
|
||||
void SetFileName(etk::FSNode &newName)
|
||||
{
|
||||
m_fileName = newName;
|
||||
m_haveName = true;
|
||||
NameChange();
|
||||
};
|
||||
|
||||
void SetFileName(etk::UString &newName)
|
||||
{
|
||||
m_fileName.SetName(newName);
|
||||
m_haveName = true;
|
||||
NameChange();
|
||||
};
|
||||
|
||||
bool HaveName(void)
|
||||
{
|
||||
return m_haveName;
|
||||
}
|
||||
|
||||
virtual void Save(void) {};
|
||||
bool IsModify(void);
|
||||
protected:
|
||||
void SetModify(bool status);
|
||||
virtual void NameChange(void) { /*APPL_DEBUG("check name change ==> no HL change possible");*/};
|
||||
public:
|
||||
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate) {};
|
||||
virtual void SetLineDisplay(uint32_t lineNumber) {};
|
||||
virtual int32_t Display(ewol::Text& OOText,
|
||||
ewol::Drawing& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
|
||||
{
|
||||
return ERR_NONE;
|
||||
}
|
||||
virtual void AddChar(uniChar_t unicodeData) {};
|
||||
virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent) {};
|
||||
virtual void MouseSelectFromCursorTo(etk::Vector2D<float> pos) {};
|
||||
virtual void MouseEvent(etk::Vector2D<float> pos) {};
|
||||
virtual void MouseEventDouble(void) {};
|
||||
virtual void MouseEventTriple(void) {};
|
||||
virtual void RemoveLine(void) {};
|
||||
virtual void SelectAll(void) {};
|
||||
virtual void SelectNone(void) {};
|
||||
virtual void Undo(void) {};
|
||||
virtual void Redo(void) {};
|
||||
virtual void SetCharset(unicode::charset_te newCharset) {};
|
||||
|
||||
//virtual void SelectAll(void);
|
||||
virtual void Copy(ewol::clipBoard::clipboardListe_te clipboardID) {};
|
||||
virtual void Cut(ewol::clipBoard::clipboardListe_te clipboardID) {};
|
||||
virtual void Paste(ewol::clipBoard::clipboardListe_te clipboardID) {};
|
||||
virtual void Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp) {};
|
||||
virtual void Replace(etk::UString &data) {};
|
||||
virtual int32_t FindLine(etk::UString &data) { return 0; };
|
||||
virtual void JumpAtLine(int32_t newLine) {};
|
||||
virtual int32_t GetCurrentLine(void) { return 0; };
|
||||
|
||||
virtual int32_t GetNumberOfLine(void) { return 1; };
|
||||
|
||||
// moving with cursor change position:
|
||||
private:
|
||||
bool m_updatePositionRequested; //!< if a position xhange in the windows ...
|
||||
etk::Vector2D<float> m_maximumSize; //!< current maxSize of the buffer
|
||||
protected:
|
||||
void RequestUpdateOfThePosition(void) { m_updatePositionRequested = true; };
|
||||
void SetMaximumSize(etk::Vector2D<float> maxSize) { m_maximumSize = maxSize; };
|
||||
public:
|
||||
bool NeedToUpdateDisplayPosition(void);
|
||||
virtual etk::Vector2D<float> GetBorderSize(void); // this is to requested the minimum size for the buffer that is not consider as visible ...
|
||||
virtual etk::Vector2D<float> GetPosition(int32_t fontId, bool& centerRequested);
|
||||
etk::Vector2D<float> GetMaxSize(void) { return m_maximumSize; };
|
||||
protected:
|
||||
bool m_fileModify; //!<
|
||||
// naming
|
||||
etk::FSNode m_fileName; //!< filename of the curent buffer
|
||||
bool m_haveName; //!< to know if the file have a name or NOT
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -1,109 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferEmpty.cpp
|
||||
* @brief Editeur De N'ours : Text Buffer (edit For No buffer Display)
|
||||
* @author Edouard DUPIN
|
||||
* @date 19/01/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <BufferEmpty.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <MainWindows.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "BufferEmpty"
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
BufferEmpty::BufferEmpty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
BufferEmpty::~BufferEmpty(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
int32_t BufferEmpty::Display(ewol::Text& OOText,
|
||||
ewol::Drawing& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
|
||||
{
|
||||
// Get color :
|
||||
Colorize *myColor = NULL;
|
||||
|
||||
etk::Vector3D<float> tmpLetterSize = OOText.CalculateSize((uniChar_t)'A');
|
||||
int32_t letterHeight = tmpLetterSize.y;
|
||||
|
||||
etk::Vector2D<float> textPos;
|
||||
textPos.x = 20;
|
||||
textPos.y = sizeY - 20 - letterHeight;
|
||||
etk::UString tmpDisplay ;
|
||||
|
||||
myColor = ColorizeManager::Get("normal");
|
||||
tmpDisplay = "edn - Editeur De N'ours";
|
||||
|
||||
OOText.SetColor(myColor->GetFG());
|
||||
OOText.SetPos(etk::Vector3D<float>(textPos.x, textPos.y, 0.0f) );
|
||||
OOText.SetFontMode(ewol::font::Bold);
|
||||
OOText.Print(tmpDisplay);
|
||||
|
||||
myColor = ColorizeManager::Get("commentDoxygen");
|
||||
textPos.y = (int32_t)(textPos.y - letterHeight*1.30);
|
||||
tmpDisplay = "No Buffer Availlable to display";
|
||||
|
||||
OOText.SetColor(myColor->GetFG());
|
||||
OOText.SetPos(etk::Vector3D<float>(textPos.x, textPos.y, 0.0f) );
|
||||
OOText.SetFontMode(ewol::font::Regular);
|
||||
OOText.Print(tmpDisplay);
|
||||
|
||||
OOColored.SetColor(draw::color::white);
|
||||
OOText.SetPos(etk::Vector3D<float>(0.0f, 0.0f, 0.0f) );
|
||||
OOColored.RectangleWidth(etk::Vector3D<float>((float)sizeX, (float)sizeY, 0.0f) );
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferEmpty.h
|
||||
* @brief Editeur De N'ours : Text Buffer (edit For No buffer Display) (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 19/01/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __BUFFER_EMPTY_H__
|
||||
#define __BUFFER_EMPTY_H__
|
||||
|
||||
#include <Buffer.h>
|
||||
|
||||
class BufferEmpty : public Buffer {
|
||||
public:
|
||||
BufferEmpty(void);
|
||||
virtual ~BufferEmpty(void);
|
||||
int32_t Display(ewol::Text& OOText,
|
||||
ewol::Drawing& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -68,7 +68,7 @@ class classBufferManager: public ewol::EObject
|
||||
public:
|
||||
int32_t GetSelected(void) { return m_idSelected;};
|
||||
//void SetSelected(int32_t id) {m_idSelected = id;};
|
||||
Buffer * Get(int32_t BufferID);
|
||||
BufferText* Get(int32_t BufferID);
|
||||
bool Exist(int32_t BufferID);
|
||||
bool Exist(etk::FSNode &myFile);
|
||||
int32_t GetId(etk::FSNode &myFile);
|
||||
@@ -80,11 +80,10 @@ class classBufferManager: public ewol::EObject
|
||||
|
||||
private:
|
||||
|
||||
etk::Vector<Buffer*> listBuffer; //!< element List of the char Elements
|
||||
etk::Vector<BufferText*> listBuffer; //!< element List of the char Elements
|
||||
|
||||
void RemoveAll(void); //!< remove all buffer
|
||||
int32_t m_idSelected;
|
||||
Buffer * BufferNotExiste; //!< When an error arrive in get buffer we return the Error buffer (not writable)
|
||||
};
|
||||
|
||||
|
||||
@@ -99,8 +98,6 @@ class classBufferManager: public ewol::EObject
|
||||
*/
|
||||
classBufferManager::classBufferManager(void)
|
||||
{
|
||||
// nothing to do ...
|
||||
BufferNotExiste = new BufferEmpty();
|
||||
m_idSelected = -1;
|
||||
RegisterMultiCast(ednMsgGuiNew);
|
||||
RegisterMultiCast(ednMsgOpenFile);
|
||||
@@ -126,8 +123,6 @@ classBufferManager::~classBufferManager(void)
|
||||
// clear The list of Buffer
|
||||
APPL_INFO("~classBufferManager::listBuffer.Clear();");
|
||||
listBuffer.Clear();
|
||||
APPL_INFO("~classBufferManager::delete(BufferNotExiste);");
|
||||
delete(BufferNotExiste);
|
||||
}
|
||||
|
||||
|
||||
@@ -325,7 +320,7 @@ void classBufferManager::RemoveAll(void)
|
||||
int32_t classBufferManager::Create(void)
|
||||
{
|
||||
// allocate a new Buffer
|
||||
Buffer *myBuffer = new BufferText();
|
||||
BufferText *myBuffer = new BufferText();
|
||||
// Add at the list of element
|
||||
listBuffer.PushBack(myBuffer);
|
||||
int32_t basicID = listBuffer.Size() - 1;
|
||||
@@ -347,7 +342,7 @@ int32_t classBufferManager::Open(etk::FSNode &myFile)
|
||||
{
|
||||
if (false == Exist(myFile)) {
|
||||
// allocate a new Buffer
|
||||
Buffer *myBuffer = new BufferText(myFile);
|
||||
BufferText *myBuffer = new BufferText(myFile);
|
||||
// Add at the list of element
|
||||
listBuffer.PushBack(myBuffer);
|
||||
return listBuffer.Size() - 1;
|
||||
@@ -359,11 +354,11 @@ int32_t classBufferManager::Open(etk::FSNode &myFile)
|
||||
|
||||
|
||||
|
||||
Buffer * classBufferManager::Get(int32_t BufferID)
|
||||
BufferText * classBufferManager::Get(int32_t BufferID)
|
||||
{
|
||||
// possible special case : -1;
|
||||
if (-1 >= BufferID) {
|
||||
return BufferNotExiste;
|
||||
return NULL;
|
||||
}
|
||||
// check if the Buffer existed
|
||||
if (BufferID < listBuffer.Size()) {
|
||||
@@ -376,7 +371,7 @@ Buffer * classBufferManager::Get(int32_t BufferID)
|
||||
} else {
|
||||
APPL_ERROR("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
|
||||
}
|
||||
return BufferNotExiste;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -543,7 +538,7 @@ int32_t BufferManager::GetSelected(void)
|
||||
return localManager->GetSelected();
|
||||
}
|
||||
|
||||
Buffer * BufferManager::Get(int32_t BufferID)
|
||||
BufferText * BufferManager::Get(int32_t BufferID)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
|
@@ -26,9 +26,7 @@
|
||||
#ifndef __BUFFER_MANAGER_H__
|
||||
#define __BUFFER_MANAGER_H__
|
||||
|
||||
#include <Buffer.h>
|
||||
#include <BufferText.h>
|
||||
#include <BufferEmpty.h>
|
||||
#include <appl/globalMsg.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
|
||||
@@ -37,7 +35,7 @@ namespace BufferManager
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
int32_t GetSelected(void);
|
||||
Buffer * Get(int32_t BufferID);
|
||||
BufferText* Get(int32_t BufferID);
|
||||
bool Exist(int32_t BufferID);
|
||||
bool Exist(etk::FSNode &myFile);
|
||||
int32_t GetId(etk::FSNode &myFile);
|
||||
|
@@ -93,6 +93,56 @@ void BufferText::NameChange(void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool BufferText::IsModify(void)
|
||||
{
|
||||
return m_fileModify;
|
||||
}
|
||||
|
||||
void BufferText::SetModify(bool status)
|
||||
{
|
||||
if (status != m_fileModify) {
|
||||
m_fileModify = status;
|
||||
// TODO : Remove from here
|
||||
etk::UString data = "Modify";
|
||||
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgBufferState, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool BufferText::NeedToUpdateDisplayPosition(void)
|
||||
{
|
||||
bool tmpVal = m_updatePositionRequested;
|
||||
m_updatePositionRequested = false;
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
etk::Vector2D<float> BufferText::GetBorderSize(void)
|
||||
{
|
||||
etk::Vector2D<float> tmpVal;
|
||||
tmpVal.x = 30;
|
||||
tmpVal.y = 30;
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
@@ -103,6 +153,18 @@ void BufferText::NameChange(void)
|
||||
*/
|
||||
BufferText::BufferText()
|
||||
{
|
||||
|
||||
static int32_t fileBasicID = 0;
|
||||
m_updatePositionRequested = false;
|
||||
m_fileModify = true;
|
||||
m_haveName = false;
|
||||
etk::UString mString = "Untitle - ";
|
||||
mString += fileBasicID++;
|
||||
EWOL_DEBUG("Create buffer try name : \"" << mString << "\"");
|
||||
SetFileName(mString);
|
||||
m_haveName = false;
|
||||
EWOL_DEBUG("Create buffer with name : " << m_fileName );
|
||||
|
||||
BasicInit();
|
||||
SetModify(true);
|
||||
APPL_INFO("New(Empty-Buffer)");
|
||||
@@ -117,8 +179,13 @@ BufferText::BufferText()
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
BufferText::BufferText(etk::FSNode &fileName) : Buffer(fileName)
|
||||
BufferText::BufferText(etk::FSNode &fileName)
|
||||
{
|
||||
m_fileModify = false;
|
||||
EWOL_DEBUG("Create buffer try name : \"" << fileName << "\"");
|
||||
SetFileName(fileName);
|
||||
EWOL_DEBUG("Create buffer with name : " << m_fileName );
|
||||
|
||||
BasicInit();
|
||||
NameChange();
|
||||
APPL_INFO("Add Data from file(" << GetFileName() << ")");
|
||||
@@ -206,7 +273,7 @@ void BufferText::SetLineDisplay(uint32_t lineNumber)
|
||||
|
||||
#define SEPARATION_SIZE_LINE_NUMBER (3)
|
||||
|
||||
void BufferText::DrawLineNumber(ewol::Text* OOText, ewol::Drawing* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY)
|
||||
void BufferText::DrawLineNumber(ewol::Text* OOText, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY)
|
||||
{
|
||||
char tmpLineNumber[50];
|
||||
sprintf(tmpLineNumber, "%*d", nbColomn, lineNumber);
|
||||
@@ -216,23 +283,6 @@ void BufferText::DrawLineNumber(ewol::Text* OOText, ewol::Drawing* OOColored, in
|
||||
OOText->Print(tmpLineNumber);
|
||||
}
|
||||
|
||||
#define CURSOR_WIDTH (5)
|
||||
#define CURSOR_THICKNESS (1.2)
|
||||
void BufferText::DrawCursor(ewol::Drawing* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth)//, clipping_ts &clip)
|
||||
{
|
||||
/*
|
||||
draw::Color & tmpppppp = ColorizeManager::Get(COLOR_CODE_CURSOR);
|
||||
OOColored->SetColor(tmpppppp);
|
||||
if (true == ewol::IsSetInsert()) {
|
||||
OOColored->Rectangle( x, y, letterWidth, letterHeight);
|
||||
} else {
|
||||
OOColored->Line( (int32_t)(x-CURSOR_WIDTH), (int32_t)(y) , (int32_t)(x+CURSOR_WIDTH), (int32_t)(y) , CURSOR_THICKNESS);
|
||||
OOColored->Line( (int32_t)(x-CURSOR_WIDTH), (int32_t)(y+letterHeight-CURSOR_THICKNESS), (int32_t)(x+CURSOR_WIDTH), (int32_t)(y+letterHeight-CURSOR_THICKNESS), CURSOR_THICKNESS);
|
||||
OOColored->Line( (int32_t)(x) , (int32_t)(y) , (int32_t)(x) , (int32_t)(y+letterHeight-CURSOR_THICKNESS), CURSOR_THICKNESS);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief get the number of colomn neede to display lineNumber
|
||||
@@ -275,69 +325,10 @@ int32_t BufferText::GetNumberOfLine(void)
|
||||
*
|
||||
*/
|
||||
int32_t BufferText::Display(ewol::Text& OOText,
|
||||
ewol::Drawing& OOColored,
|
||||
int32_t offsetX, int32_t offsetY,
|
||||
int32_t sizeX, int32_t sizeY)
|
||||
{
|
||||
OOColored.SetPos(etk::Vector3D<float>(-2048, -2048, 0));
|
||||
OOColored.SetColor(ColorizeManager::Get(COLOR_CODE_BASIC_BG));
|
||||
OOColored.RectangleWidth(etk::Vector3D<float>(4096, 4096, 0) );
|
||||
|
||||
# if 0
|
||||
|
||||
|
||||
OOText.SetColor(0x000000FF);
|
||||
OOText.SetColorBg(0x00000000);
|
||||
OOText.Translate(etk::Vector3D<float>(0,sizeY,0) );
|
||||
OOText.SetPos(etk::Vector3D<float>(0,0,0));
|
||||
// the text is all the time writtent upper (due top the openGL system ==> the the first line must be written under ...
|
||||
OOText.ForceLineReturn();
|
||||
// This is use to generate an automatic return when \n is done ... ==> this permit to not know the line height ...
|
||||
OOText.SetTextAlignement(0, sizeX, ewol::Text::alignDisable);
|
||||
|
||||
// Generate MawSize
|
||||
/*
|
||||
maxSize.x = 0.0;
|
||||
maxSize.y = m_EdnBuf.NumberOfLines() * OOText.CalculateSize((uniChar_t)'A').y;
|
||||
*/
|
||||
|
||||
// Clear the line intexation :
|
||||
m_elmentList.Clear();
|
||||
// every char element is register to find the diplay pos when mouse event arrive
|
||||
CharElement tmpElementProperty;
|
||||
// set the first char :
|
||||
//tmpElementProperty.m_LineOffset = OOText.GetPos().y;
|
||||
//tmpElementProperty.m_bufferPos = displayStartBufferPos;
|
||||
//m_elmentList.PushBack(tmpElementProperty);
|
||||
|
||||
|
||||
int32_t displayStartLineId = (float)offsetY / OOText.CalculateSize((uniChar_t)'A').y;
|
||||
// the ofsset is all time negative ...
|
||||
displayStartLineId = etk_max(0, displayStartLineId);
|
||||
APPL_DEBUG(" request offset : " << offsetY << " ==> " << displayStartLineId);
|
||||
// update the display position with the scroll ofset :
|
||||
int32_t currentLineStartPos = m_EdnBuf.CountForwardNLines(0, displayStartLineId);
|
||||
int32_t findPos;
|
||||
etk::UString lineText;
|
||||
while (true == m_EdnBuf.SearchForward(currentLineStartPos, '\n', &findPos) ) {
|
||||
// remember the start line display position in the buffer
|
||||
tmpElementProperty.m_bufferPos = currentLineStartPos;
|
||||
// we did not copy the \n
|
||||
m_EdnBuf.GetRange(currentLineStartPos, findPos-1, lineText);
|
||||
// update the next extract position with the \n removed
|
||||
currentLineStartPos = findPos+1;
|
||||
OOText.Print(lineText);
|
||||
// Remember the last position of the current Line :
|
||||
tmpElementProperty.m_LineOffset = OOText.GetPos().y;
|
||||
// element list is used to manage the current line position
|
||||
m_elmentList.PushBack(tmpElementProperty);
|
||||
|
||||
// go to the start of the line ...
|
||||
OOText.ForceLineReturn();
|
||||
}
|
||||
// TODO : Missing the last line ...
|
||||
|
||||
#else
|
||||
|
||||
int32_t selStart, selEnd, selRectStart, selRectEnd;
|
||||
bool selIsRect;
|
||||
@@ -400,9 +391,8 @@ int32_t BufferText::Display(ewol::Text& OOText,
|
||||
y = sizeY - y;
|
||||
y -= letterHeight;
|
||||
|
||||
OOColored.SetClippingMode(false);
|
||||
OOText.SetClippingMode(false);
|
||||
DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
|
||||
DrawLineNumber(&OOText, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
|
||||
int32_t pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
|
||||
|
||||
clipping_ts drawClipping;
|
||||
@@ -413,8 +403,6 @@ int32_t BufferText::Display(ewol::Text& OOText,
|
||||
|
||||
OOText.SetClippingWidth(etk::Vector3D<float>((float)pixelX, 0.0f, -0.5f),
|
||||
etk::Vector3D<float>((float)(sizeX - drawClipping.x), (float)sizeY, 0.5f) );
|
||||
OOColored.SetClippingWidth(etk::Vector3D<float>(0.0f, 0.0f, -0.5f),
|
||||
etk::Vector3D<float>((float)sizeX, (float)sizeY, 0.5f) );
|
||||
|
||||
// Clear the line intexation :
|
||||
m_elmentList.Clear();
|
||||
@@ -426,6 +414,8 @@ int32_t BufferText::Display(ewol::Text& OOText,
|
||||
tmpElementProperty.m_bufferPos = displayStartBufferPos;
|
||||
m_elmentList.PushBack(tmpElementProperty);
|
||||
|
||||
etk::Vector3D<float> tmpCursorPosition(0, 0, -1); //Cursor is display only at the end to be all time over the background ... (-1 in z no cursor)
|
||||
|
||||
float lineMaxSize = 0.0;
|
||||
for (iii=displayStartBufferPos; iii<mylen && displayLines >=0 && y >= -2*letterHeight; iii = new_i) {
|
||||
//APPL_DEBUG("display pos =" << y);
|
||||
@@ -455,21 +445,23 @@ int32_t BufferText::Display(ewol::Text& OOText,
|
||||
}
|
||||
}
|
||||
OOText.SetColorBg(draw::color::none);
|
||||
if( true == selHave
|
||||
&& selStart <= iii
|
||||
&& selEnd > iii)
|
||||
if( true == selHave
|
||||
&& selStart <= iii
|
||||
&& selEnd > iii)
|
||||
{
|
||||
selectColor = myColorSel;
|
||||
OOText.SetColorBg(selectColor->GetBG() );
|
||||
} else {
|
||||
if( ' ' == currentChar
|
||||
&& true == globals::IsSetDisplaySpaceChar() )
|
||||
{
|
||||
OOText.SetColorBg(myColorSpace);
|
||||
} else if( '\t' == currentChar
|
||||
&& true == globals::IsSetDisplaySpaceChar() )
|
||||
{
|
||||
OOText.SetColorBg(myColorTab);
|
||||
if(false == selectColor->HaveBg()) {
|
||||
if( (uniChar_t)' ' == currentChar
|
||||
&& true == globals::IsSetDisplaySpaceChar() )
|
||||
{
|
||||
OOText.SetColorBg(myColorSpace);
|
||||
} else if( '\t' == currentChar
|
||||
&& true == globals::IsSetDisplayTabChar() )
|
||||
{
|
||||
OOText.SetColorBg(myColorTab);
|
||||
}
|
||||
} else {
|
||||
OOText.SetColorBg(selectColor->GetBG());
|
||||
}
|
||||
@@ -491,8 +483,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
|
||||
idX += displaywidth;
|
||||
// display cursor :
|
||||
if (m_cursorPos == iii) {
|
||||
// display the cursor:
|
||||
DrawCursor(&OOColored, pixelX - offsetX, y, letterHeight, letterWidth);
|
||||
tmpCursorPosition = etk::Vector3D<float>(pixelX - offsetX, y, 0);
|
||||
}
|
||||
lineMaxSize += drawSize;
|
||||
pixelX += drawSize;
|
||||
@@ -506,36 +497,32 @@ int32_t BufferText::Display(ewol::Text& OOText,
|
||||
//APPL_DEBUG("display pos =" << y);
|
||||
displayLines++;
|
||||
currentLineID++;
|
||||
OOColored.SetClippingMode(false);
|
||||
OOText.SetClippingMode(false);
|
||||
OOText.SetFontBold(false);
|
||||
OOText.SetFontItalic(false);
|
||||
DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
|
||||
DrawLineNumber(&OOText, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
|
||||
OOText.SetClippingMode(true);
|
||||
OOColored.SetClippingMode(true);
|
||||
// add elements :
|
||||
// add elements :
|
||||
m_elmentList.PushBack(tmpElementProperty);
|
||||
}
|
||||
}
|
||||
//APPL_DEBUG("end at pos buf =" << iii << " / " << m_EdnBuf.Size());
|
||||
// special case : the cursor is at the end of the buffer...
|
||||
if (m_cursorPos == iii) {
|
||||
DrawCursor(&OOColored, pixelX - offsetX, y, letterHeight, letterWidth);//, drawClippingTextArea);
|
||||
tmpCursorPosition = etk::Vector3D<float>(pixelX - offsetX, y, 0);
|
||||
}
|
||||
if (tmpCursorPosition.z!=-1) {
|
||||
// display the cursor:
|
||||
OOText.SetPos(tmpCursorPosition);
|
||||
OOText.SetColor(ColorizeManager::Get(COLOR_CODE_CURSOR));
|
||||
OOText.SetColorBg(ColorizeManager::Get(COLOR_CODE_CURSOR));
|
||||
OOText.PrintCursor(ewol::IsSetInsert());
|
||||
}
|
||||
// set the maximum size for the display ...
|
||||
SetMaximumSize(maxSize);
|
||||
int64_t stopTime2 = ewol::GetTime();
|
||||
APPL_DEBUG("DRAW text (brut) = " << stopTime2 - stopTime << " micro-s");
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef QSDFQSDFSDFQS_QSDFQSDf_QSDFQSDF___QSDFQSDFQ
|
||||
@@ -777,7 +764,6 @@ int32_t BufferText::GetMousePosition(etk::Vector2D<float> pos)
|
||||
bool inLineDone=false;
|
||||
//APPL_DEBUG("try to find in : " << width << "," << height);
|
||||
for(int32_t iii=0; iii<m_elmentList.Size()-1; iii++) {
|
||||
/*
|
||||
//APPL_DEBUG("check element : " << m_elmentList[iii].m_yOffset << "<= " << pos.y << " <" << (m_elmentList[iii].m_yOffset + m_elmentList[iii].m_ySize));
|
||||
if(false == inLineDone) {
|
||||
if( pos.y>=m_elmentList[iii].m_yOffset
|
||||
@@ -799,10 +785,8 @@ int32_t BufferText::GetMousePosition(etk::Vector2D<float> pos)
|
||||
return m_elmentList[iii].m_bufferPos;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
if (m_elmentList.Size()>0) {
|
||||
/*
|
||||
if(pos.y<m_elmentList[m_elmentList.Size()/2].m_yOffset) {
|
||||
//APPL_DEBUG("Error to get position (return Last)");
|
||||
return m_elmentList[m_elmentList.Size()-1].m_bufferPos;
|
||||
@@ -810,7 +794,6 @@ int32_t BufferText::GetMousePosition(etk::Vector2D<float> pos)
|
||||
//APPL_DEBUG("Error to get position (return begin)");
|
||||
return m_elmentList[0].m_bufferPos;
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
APPL_CRITICAL("Error to get position (very bad)");
|
||||
return 0;
|
||||
|
@@ -26,8 +26,14 @@
|
||||
#ifndef __BUFFER_TEXT_H__
|
||||
#define __BUFFER_TEXT_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <etk/unicode.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/compositing/Drawing.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
|
||||
#include "ColorizeManager.h"
|
||||
#include "Buffer.h"
|
||||
#include "EdnBuf.h"
|
||||
|
||||
typedef enum {
|
||||
@@ -46,7 +52,58 @@ class CharElement
|
||||
int32_t m_bufferPos;
|
||||
};
|
||||
|
||||
class BufferText : public Buffer {
|
||||
|
||||
typedef struct{
|
||||
uint32_t nbTotalLine; //!< Number of line in the buffer
|
||||
uint32_t nbTotalColomn; //!< Number of line in the buffer
|
||||
uint32_t startLineDisplay; //!< First line display.
|
||||
uint32_t startColomnDisplay; //!< First Colomn displayed
|
||||
uint32_t diplayableColomn; //!< NB colomn that can be displayed
|
||||
uint32_t diplayableLine; //!< NB Line that can be displayed
|
||||
}infoStatBuffer_ts;
|
||||
|
||||
|
||||
class BufferText
|
||||
{
|
||||
private:
|
||||
bool m_fileModify; //!<
|
||||
// naming
|
||||
etk::FSNode m_fileName; //!< filename of the curent buffer
|
||||
bool m_haveName; //!< to know if the file have a name or NOT
|
||||
bool m_updatePositionRequested; //!< if a position xhange in the windows ...
|
||||
etk::Vector2D<float> m_maximumSize; //!< current maxSize of the buffer
|
||||
public:
|
||||
void SetModify(bool status);
|
||||
virtual etk::Vector2D<float> GetBorderSize(void);
|
||||
void RequestUpdateOfThePosition(void) { m_updatePositionRequested = true; };
|
||||
void SetMaximumSize(etk::Vector2D<float> maxSize) { m_maximumSize = maxSize; };
|
||||
bool NeedToUpdateDisplayPosition(void);
|
||||
etk::Vector2D<float> GetMaxSize(void) { return m_maximumSize; };
|
||||
bool IsModify(void);
|
||||
public:
|
||||
etk::FSNode GetFileName(void)
|
||||
{
|
||||
return m_fileName;
|
||||
};
|
||||
|
||||
void SetFileName(etk::FSNode &newName)
|
||||
{
|
||||
m_fileName = newName;
|
||||
m_haveName = true;
|
||||
NameChange();
|
||||
};
|
||||
|
||||
void SetFileName(etk::UString &newName)
|
||||
{
|
||||
m_fileName.SetName(newName);
|
||||
m_haveName = true;
|
||||
NameChange();
|
||||
};
|
||||
|
||||
bool HaveName(void)
|
||||
{
|
||||
return m_haveName;
|
||||
}
|
||||
public:
|
||||
BufferText(void);
|
||||
BufferText(etk::FSNode &fileName);
|
||||
@@ -56,7 +113,6 @@ class BufferText : public Buffer {
|
||||
void GetInfo(infoStatBuffer_ts &infoToUpdate);
|
||||
void SetLineDisplay(uint32_t lineNumber);
|
||||
int32_t Display(ewol::Text& OOText,
|
||||
ewol::Drawing& OOColored,
|
||||
int32_t offsetX, int32_t offsetY,
|
||||
int32_t sizeX, int32_t sizeY);
|
||||
void AddChar(uniChar_t unicodeData);
|
||||
@@ -111,8 +167,7 @@ class BufferText : public Buffer {
|
||||
|
||||
int32_t GetMousePosition(etk::Vector2D<float> pos);
|
||||
|
||||
void DrawLineNumber(ewol::Text* OOText, ewol::Drawing* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);
|
||||
void DrawCursor(ewol::Drawing* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth);//, clipping_ts &clip);
|
||||
void DrawLineNumber(ewol::Text* OOText, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user