SYS : next step of the new display methode ...

This commit is contained in:
Edouard Dupin 2011-09-12 16:43:13 +02:00
parent 2712d4f67d
commit 745ca76a74
12 changed files with 464 additions and 259 deletions

View File

@ -178,7 +178,6 @@ CXXFILES+= CustumWidget/BufferView/BufferView.cpp \
# Basic Interface :
CXXFILES+= Buffer/Buffer.cpp \
Buffer/BufferAnchor.cpp \
Buffer/BufferText.cpp \
Buffer/BufferEmpty.cpp \
Buffer/BufferManager.cpp \

View File

@ -48,6 +48,12 @@ Buffer::Buffer()
mString += fileBasicID++;
SetFileName(mString);
m_haveName = false;
// Set basic anchor
bufferAnchorReference_ts tmpAnchor;
tmpAnchor.m_idAnchor = -1;
tmpAnchor.m_lineId = 0;
tmpAnchor.m_bufferPos = 0;
m_AnchorList .PushBack(tmpAnchor);
}
/**
@ -62,6 +68,12 @@ Buffer::Buffer(Edn::File &newName)
{
m_fileModify = false;
SetFileName(newName);
// Set basic anchor
bufferAnchorReference_ts tmpAnchor;
tmpAnchor.m_idAnchor = -1;
tmpAnchor.m_lineId = 0;
tmpAnchor.m_bufferPos = 0;
m_AnchorList .PushBack(tmpAnchor);
}
/**
@ -146,11 +158,12 @@ void Buffer::SetLineDisplay(uint32_t lineNumber)
* @return ---
*
*/
int32_t Buffer::Display(DrawerManager &drawer)
void Buffer::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize)
{
return ERR_NONE;
return;
}
/**
* @brief
*
@ -161,9 +174,10 @@ int32_t Buffer::Display(DrawerManager &drawer)
* @todo : Set the move up and DOWN...
*
*/
void Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height)
position_ts Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
@ -176,9 +190,10 @@ void Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height)
* @return ---
*
*/
void Buffer::MouseEvent(int32_t width, int32_t height)
position_ts Buffer::MouseEvent(int32_t width, int32_t height)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
/**
@ -189,9 +204,10 @@ void Buffer::MouseEvent(int32_t width, int32_t height)
* @return ---
*
*/
void Buffer::MouseEventDouble(void)
position_ts Buffer::MouseEventDouble(void)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
/**
@ -202,9 +218,10 @@ void Buffer::MouseEventDouble(void)
* @return ---
*
*/
void Buffer::MouseEventTriple(void)
position_ts Buffer::MouseEventTriple(void)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
@ -243,9 +260,10 @@ void Buffer::ScrollUp(void)
* @return ---
*
*/
void Buffer::cursorMove(int32_t gtkKey)
position_ts Buffer::cursorMove(int32_t gtkKey)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
/**
@ -256,19 +274,22 @@ void Buffer::cursorMove(int32_t gtkKey)
* @return ---
*
*/
void Buffer::AddChar(char * UTF8data)
position_ts Buffer::AddChar(char * UTF8data)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
void Buffer::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp)
position_ts Buffer::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
void Buffer::Replace(Edn::String &data)
position_ts Buffer::Replace(Edn::String &data)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
int32_t Buffer::FindLine(Edn::String &data)
@ -277,9 +298,10 @@ int32_t Buffer::FindLine(Edn::String &data)
return 0;
}
void Buffer::JumpAtLine(int32_t newLine)
position_ts Buffer::JumpAtLine(int32_t newLine)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
@ -319,9 +341,10 @@ void Buffer::Copy(int8_t clipboardID)
* @return ---
*
*/
void Buffer::Cut(int8_t clipboardID)
position_ts Buffer::Cut(int8_t clipboardID)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
@ -333,33 +356,98 @@ void Buffer::Cut(int8_t clipboardID)
* @return ---
*
*/
void Buffer::Paste(int8_t clipboardID)
position_ts Buffer::Paste(int8_t clipboardID)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
void Buffer::RemoveLine(void)
position_ts Buffer::RemoveLine(void)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
void Buffer::SelectAll(void)
position_ts Buffer::SelectAll(void)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
void Buffer::SelectNone(void)
position_ts Buffer::SelectNone(void)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
void Buffer::Undo(void)
position_ts Buffer::Undo(void)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
void Buffer::Redo(void)
position_ts Buffer::Redo(void)
{
// nothing to do
position_ts tmp = {0,0};
return tmp;
}
void Buffer::AnchorAdd(int32_t anchorID)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
EDN_ERROR("AnchorID="<< anchorID << " already exist !!!");
} else {
bufferAnchorReference_ts tmpAnchor = m_AnchorList[0];
tmpAnchor.m_idAnchor = anchorID;
m_AnchorList.PushBack(tmpAnchor);
EDN_DEBUG("AnchorID="<< anchorID << " ==> Added");
}
}
void Buffer::AnchorRm(int32_t anchorID)
{
if (anchorID == -1) {
EDN_ERROR("AnchorID="<< anchorID << " Can not remove this one !!!");
return;
}
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
if (m_AnchorList.Size() == 2) {
m_AnchorList[0] = m_AnchorList[1];
}
m_AnchorList.Erase(localID);
EDN_DEBUG("AnchorID="<< anchorID << " ==> Remove");
} else {
EDN_ERROR("AnchorID="<< anchorID << " does not exist !!!");
}
}
bool Buffer::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY)
{
EDN_ERROR("AnchorID="<< anchorID << " Main buffer ==> can not manage Anchor (type buffer specific)");
return false;
}
bool Buffer::AnchorNext(bufferAnchor_ts & anchor)
{
EDN_ERROR("AnchorID=?? Main buffer ==> can not manage Anchor (type buffer specific)");
return false;
}
int32_t Buffer::AnchorRealId(int32_t anchorID)
{
//EDN_DEBUG("Get real ID : " << anchorID << " in the anchor list size()=" << m_AnchorList.Size());
for(int32_t iii=0; iii < m_AnchorList.Size(); iii++) {
//EDN_DEBUG("check if equal : " << m_AnchorList[iii].m_idAnchor << " id=" << iii);
if (m_AnchorList[iii].m_idAnchor == anchorID) {
return iii;
}
}
return -1;
}

View File

@ -30,16 +30,34 @@
#include "Display.h"
#include "charset.h"
#include "Edn.h"
#include "BufferAnchor.h"
//#include "BufferAnchor.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;
extern "C"
{
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;
typedef struct {
int32_t m_idAnchor;
int32_t m_lineId;
int32_t m_bufferPos;
} bufferAnchorReference_ts;
typedef struct {
int32_t m_lineNumber;
int32_t m_nbIterationMax;
int32_t m_posStart;
int32_t m_posStop;
int32_t m_selectionPosStart;
int32_t m_selectionPosStop;
} bufferAnchor_ts;
}
class Buffer {
@ -81,30 +99,33 @@ class Buffer {
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate);
virtual void SetLineDisplay(uint32_t lineNumber);
virtual int32_t Display(DrawerManager &drawer);
virtual void AddChar(char * UTF8data);
virtual void cursorMove(int32_t gtkKey);
virtual void MouseSelectFromCursorTo(int32_t width, int32_t height);
virtual void MouseEvent(int32_t width, int32_t height);
virtual void MouseEventDouble(void);
virtual void MouseEventTriple(void);
virtual void ScrollDown(void);
virtual void ScrollUp(void);
virtual void RemoveLine(void);
virtual void SelectAll(void);
virtual void SelectNone(void);
virtual void Undo(void);
virtual void Redo(void);
virtual void SetCharset(charset_te newCharset) {};
virtual void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize);
// return the new cursor position ...
virtual position_ts AddChar(char * UTF8data);
virtual position_ts cursorMove(int32_t gtkKey);
virtual position_ts MouseSelectFromCursorTo(int32_t width, int32_t height);
virtual position_ts MouseEvent(int32_t width, int32_t height);
virtual position_ts MouseEventDouble(void);
virtual position_ts MouseEventTriple(void);
virtual position_ts RemoveLine(void);
virtual position_ts SelectAll(void);
virtual position_ts SelectNone(void);
virtual position_ts Undo(void);
virtual position_ts Redo(void);
virtual void SetCharset(charset_te newCharset) {};
virtual void ScrollDown(void); // must be deprecated
virtual void ScrollUp(void); // must be deprecated
//virtual void SelectAll(void);
virtual void Copy(int8_t clipboardID);
virtual void Cut(int8_t clipboardID);
virtual void Paste(int8_t clipboardID);
virtual void Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp);
virtual void Replace(Edn::String &data);
virtual void Copy(int8_t clipboardID);
virtual position_ts Cut(int8_t clipboardID);
virtual position_ts Paste(int8_t clipboardID);
virtual position_ts Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp);
virtual position_ts Replace(Edn::String &data);
virtual int32_t FindLine(Edn::String &data);
virtual void JumpAtLine(int32_t newLine);
virtual position_ts JumpAtLine(int32_t newLine);
virtual int32_t GetCurrentLine(void);
protected:
@ -112,6 +133,18 @@ class Buffer {
// naming
Edn::File m_fileName; //!< filename of the curent buffer
bool m_haveName; //!< to know if the file have a name or NOT
// anchor section
public:
void AnchorAdd(int32_t anchorID);
void AnchorRm(int32_t anchorID);
virtual bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY);
virtual bool AnchorNext(bufferAnchor_ts & anchor);
protected:
int32_t AnchorRealId(int32_t anchorID);
Edn::VectorType<bufferAnchorReference_ts> m_AnchorList; //!< list of all line anchor in the current buffer
};

View File

@ -38,8 +38,8 @@ class BufferAnchor
~BufferAnchor(void);
MoveAnchor(int32_t offsetLine);
//BufModification(...);
DisplayUpdateFirstLine(void);
DisplayUpdateNextLine(void);
bool DisplayUpdateFirstLine(void);
bool DisplayUpdateNextLine(void);
private :
int32_t m_lineId;
int32_t m_bufferPos;

View File

@ -67,32 +67,56 @@ BufferEmpty::~BufferEmpty(void)
* @return ---
*
*/
int32_t BufferEmpty::Display(DrawerManager &drawer)
void BufferEmpty::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize)
{
EDN_DEBUG("Request draw : " << anchor.m_lineNumber);
ColorizeManager * myColorManager = ColorizeManager::getInstance();
// Get color :
Colorize *myColor = NULL;
// Clean Buffer
drawer.Clean(myColorManager->Get(COLOR_CODE_BASIC_BG) );
myColor = myColorManager->Get("normal");
// Draw the 2 comments Lines :
drawer.Text(myColor, 20,20, "edn - Editeur De N'ours, l'Editeur Desoxyribo-Nucleique");
//drawer.Flush();
myColor = myColorManager->Get("commentDoxygen");
drawer.Text(myColor, 20,25 + Display::GetFontHeight(), "No Buffer Availlable to display");
drawer.Flush();
/*
myColor = myColorManager->Get(("SelectedText"));
drawer.Cursor(20, 50);
drawer.EndOfLine(20, 70);
drawer.Tabulation(myColor, 20, 90, 5);
drawer.UTF8UnknownElement(myColor, 20, 120, 3, false);
drawer.Flush();
*/
return ERR_NONE;
if (anchor.m_lineNumber == 0) {
// Clean Buffer
drawer.Clean(myColorManager->Get(COLOR_CODE_BASIC_BG) );
myColor = myColorManager->Get("normal");
drawer.Text(myColor, 20,20, "edn - Editeur De N'ours, l'Editeur Desoxyribo-Nucleique");
}
if (anchor.m_lineNumber == 1) {
myColor = myColorManager->Get("commentDoxygen");
drawer.Text(myColor, 20,25 + Display::GetFontHeight(), "No Buffer Availlable to display");
}
return;
}
bool BufferEmpty::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
EDN_DEBUG("Request anchor");
size.x = sizePixelX / Display::GetFontWidth();
size.y = sizePixelY / Display::GetFontHeight();
anchor.m_nbIterationMax = 2;
anchor.m_lineNumber = m_AnchorList[localID].m_lineId;
anchor.m_posStart = -1;
anchor.m_posStop = -1;
anchor.m_selectionPosStart = -1;
anchor.m_selectionPosStop = -1;
return true;
} else {
return false;
}
}
bool BufferEmpty::AnchorNext(bufferAnchor_ts & anchor)
{
anchor.m_lineNumber++;
EDN_DEBUG("Anchor Next : " << anchor.m_lineNumber);
anchor.m_nbIterationMax--;
if (anchor.m_nbIterationMax<=0) {
return false;
}
return true;
}

View File

@ -32,8 +32,10 @@ class BufferEmpty : public Buffer {
public:
BufferEmpty(void);
virtual ~BufferEmpty(void);
virtual int32_t Display(DrawerManager &drawer);
void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize);
bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY);
bool AnchorNext(bufferAnchor_ts & anchor);
};

View File

@ -141,7 +141,6 @@ BufferText::BufferText(Edn::File &fileName) : Buffer(fileName)
SetModify(true);
}
UpdateWindowsPosition();
ForceReDraw(true);
}
@ -268,19 +267,11 @@ void BufferText::UpdatePointerNumber(void)
}
/**
* @brief Display a single line
*
* @param[in,out] ---
*
* @return ---
*
*/
void BufferText::DrawLine(DrawerManager &drawer, int32_t lineNumber, int32_t startPos, int32_t endPos, int32_t selStartPos, int32_t selEndPos)
void BufferText::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize)
{
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
int32_t positionY = letterHeight * (lineNumber - m_displayStart.y - 1);
int32_t positionY = letterHeight * (anchor.m_lineNumber - displayStart.y - 1);
int32_t idX = 0;
int32_t pixelX = m_nbColoneForLineNumber*letterWidth + 3;
@ -292,18 +283,18 @@ void BufferText::DrawLine(DrawerManager &drawer, int32_t lineNumber, int32_t sta
// Regenerate the colorizing if necessary ...
displayHLData_ts myDisplayLocalSyntax;
m_EdnBuf.HightlightGenerateLines(myDisplayLocalSyntax, startPos, 1);
m_EdnBuf.HightlightOneLine(myDisplayLocalSyntax, anchor.m_posStart, anchor.m_posStop);
// clean the current Line
drawer.Rectangle(myColorManager->Get(COLOR_CODE_BASIC_BG), 0, positionY, drawer.GetWidth(), letterHeight);
DrawLineNumber(drawer, lineNumber);
DrawLineNumber(drawer, anchor.m_lineNumber);
bool selHave = selStartPos == -1 ? false : true;
bool selHave = anchor.m_selectionPosStart == -1 ? false : true;
char displayChar[MAX_EXP_CHAR_LEN];
memset(displayChar, 0, sizeof(char)*MAX_EXP_CHAR_LEN);
int32_t iii;
for (iii=startPos; iii<endPos; ) {
for (iii=anchor.m_posStart; iii<anchor.m_posStop; ) {
uint32_t currentChar;
int32_t savePositionForCursor = iii;
int32_t displaywidth = m_EdnBuf.GetExpandedChar(iii, idX, displayChar, currentChar);
@ -312,13 +303,13 @@ void BufferText::DrawLine(DrawerManager &drawer, int32_t lineNumber, int32_t sta
int32_t widthToDisplay;
char * tmpDisplayOfset;
bool inTheScreen = true;
if (m_displayStart.x <= idX) {
if (displayStart.x <= idX) {
// Normal display
tmpDisplayOfset = displayChar;
widthToDisplay = displaywidth;
} else if (m_displayStart.x < idX + displaywidth) {
} else if (displayStart.x < idX + displaywidth) {
// special case of partial display :
widthToDisplay = idX + displaywidth - m_displayStart.x;
widthToDisplay = idX + displaywidth - displayStart.x;
tmpDisplayOfset = displayChar + (displaywidth-widthToDisplay);
} else {
// Out of range ...
@ -340,8 +331,8 @@ void BufferText::DrawLine(DrawerManager &drawer, int32_t lineNumber, int32_t sta
//selectColor = myColorSelected;
//SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar)
if( true == selHave
&& selStartPos <= iii
&& selEndPos > iii)
&& anchor.m_selectionPosStart <= iii
&& anchor.m_selectionPosStop > iii)
{
drawer.SpaceText(myColorSelected->GetBG(), pixelX ,positionY , 1);
} else if (true == selectColor->HaveBg()) {
@ -353,8 +344,8 @@ void BufferText::DrawLine(DrawerManager &drawer, int32_t lineNumber, int32_t sta
&& true == globals::IsSetDisplaySpaceChar() )
{
if( true == selHave
&& selStartPos <= iii
&& selEndPos > iii)
&& anchor.m_selectionPosStart <= iii
&& anchor.m_selectionPosStop > iii)
{
drawer.SpaceText(myColorSelected->GetBG(), pixelX ,positionY , strlen(tmpDisplayOfset));
} else if (true == selectColor->HaveBg()) {
@ -364,8 +355,8 @@ void BufferText::DrawLine(DrawerManager &drawer, int32_t lineNumber, int32_t sta
}
} else {
if( true == selHave
&& selStartPos <= iii
&& selEndPos > iii)
&& anchor.m_selectionPosStart <= iii
&& anchor.m_selectionPosStop > iii)
{
selectColor = myColorSelected;
}
@ -404,67 +395,6 @@ void BufferText::DrawLine(DrawerManager &drawer, int32_t lineNumber, int32_t sta
}
/**
* @brief Display the curent buffer with all the probematic imposed by the xharset and the user contraint.
*
* @param[in,out] drawer the basic user drawer of EDN.
*
* @return
*
*/
int32_t BufferText::Display(DrawerManager &drawer)
{
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
// Update the total of line to display in the buffer
UpdatePointerNumber();
// update the number of element that can be displayed
m_displaySize.x = (drawer.GetWidth()/letterWidth) + 1 - m_nbColoneForLineNumber;
m_displaySize.y = (drawer.GetHeight()/letterHeight) + 1;
EDN_INFO("main DIPLAY " << m_displaySize.x << " char * " << m_displaySize.y << " char");
int32_t selStart, selEnd, selRectStart, selRectEnd;
bool selIsRect;
bool selHave = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, selStart, selEnd, selIsRect, selRectStart, selRectEnd);
if (false == selHave){
selStart = -1;
selEnd = -1;
}
//drawer.Clean(myColorManager->Get(COLOR_CODE_BASIC_BG));
GTimeVal timeStart;
g_get_current_time(&timeStart);
int32_t lineStartPos=m_displayStartBufferPos;
int32_t lineEndPos=-1;
int32_t lineIdStart = m_displayStart.y + 1;
int32_t lineIdEnd = m_displayStart.y + m_displaySize.y;
EDN_DEBUG("lineIdStart=" << lineIdStart << " lineIdEnd=" << lineIdEnd );
int32_t iii;
for (iii=lineIdStart; iii<lineIdEnd+1 ; iii++) {
lineEndPos = m_EdnBuf.EndOfLine(lineStartPos);
DrawLine(drawer, iii, lineStartPos, lineEndPos, selStart+1, selEnd+1);
lineStartPos = lineEndPos+1;
if (lineStartPos >= m_EdnBuf.Size()+1) {
iii++;
break;
}
}
drawer.Flush();
// Need to clean the end of windows (sometimes)...
if (iii<lineIdEnd+1) {
int32_t positionY = letterHeight * (iii - m_displayStart.y - 1);
drawer.Rectangle(myColorManager->Get(COLOR_CODE_BASIC_BG), 0, positionY, drawer.GetWidth(), letterHeight*(lineIdEnd+1-iii) );
}
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("Display Generation = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
return ERR_NONE;
}
void BufferText::GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y)
{
x = (width - 3) / Display::GetFontWidth() - m_nbColoneForLineNumber;
@ -508,7 +438,6 @@ void BufferText::MouseEvent(int32_t width, int32_t height)
}
m_EdnBuf.Unselect(SELECTION_PRIMARY);
ForceReDraw(true);
UpdateWindowsPosition();
}
}
@ -558,7 +487,6 @@ void BufferText::MouseSelectFromCursorTo(int32_t width, int32_t height)
m_EdnBuf.Select(SELECTION_PRIMARY, selStart, m_cursorPos);
}
}
ForceReDraw(true);
UpdateWindowsPosition();
}
@ -578,7 +506,6 @@ void BufferText::MouseEventDouble(void)
if (true == m_EdnBuf.SelectAround(m_cursorPos, beginPos, endPos)) {
m_EdnBuf.Select(SELECTION_PRIMARY, beginPos, endPos);
m_cursorPos = endPos;
ForceReDraw(true);
}
// no else
}
@ -595,7 +522,6 @@ void BufferText::MouseEventTriple(void)
{
m_EdnBuf.Select(SELECTION_PRIMARY, m_EdnBuf.StartOfLine(m_cursorPos), m_EdnBuf.EndOfLine(m_cursorPos));
m_cursorPos = m_EdnBuf.EndOfLine(m_cursorPos);
ForceReDraw(true);
}
void BufferText::RemoveLine(void)
@ -611,13 +537,11 @@ void BufferText::SelectAll(void)
{
m_EdnBuf.Select(SELECTION_PRIMARY, 0, m_EdnBuf.Size());
m_cursorPos = m_EdnBuf.Size();
ForceReDraw(true);
}
void BufferText::SelectNone(void)
{
m_EdnBuf.Unselect(SELECTION_PRIMARY);
ForceReDraw(true);
}
/**
@ -922,11 +846,9 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
m_displayStart.y = cursorPosition.y - globals::getNbLineBorder();
if (m_displayStart.y < 0) {
m_displayStart.y = 0;
ForceReDraw(true);
}
} else if (m_displayStart.y + m_displaySize.y <= (int32_t)cursorPosition.y + globals::getNbLineBorder() ) {
m_displayStart.y = cursorPosition.y - m_displaySize.y + globals::getNbLineBorder() + 1;
ForceReDraw(true);
}
// Display position (X mode):
//EDN_INFO("cursorPosition X : " << cursorPosition.y << " windows " << m_displayStart.y << "=>" << m_displayStart.x + m_displaySize.x);
@ -934,11 +856,9 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
m_displayStart.x = cursorPosition.x - globals::getNbColoneBorder();
if (m_displayStart.x < 0) {
m_displayStart.x = 0;
ForceReDraw(true);
}
} else if (m_displayStart.x + m_displaySize.x <= cursorPosition.x + globals::getNbColoneBorder() ) {
m_displayStart.x = cursorPosition.x - m_displaySize.x + globals::getNbColoneBorder() + 1;
ForceReDraw(true);
}
//update the buffer position ID :
@ -957,7 +877,6 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
m_displayStart.y = edn_max(m_displayStart.y, 0);
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStart.y);
ForceReDraw(true);
//EDN_DEBUG(" display start : " << m_displayStart.x << "x" << m_displayStart.y);
//EDN_DEBUG(" -------------------------------------------------");
}
@ -972,8 +891,9 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
* @return ---
*
*/
void BufferText::AddChar(char * UTF8data)
position_ts BufferText::AddChar(char * UTF8data)
{
position_ts tmp = {0,0};
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
@ -1117,8 +1037,9 @@ int32_t BufferText::FindLine(Edn::String &data)
}
}
void BufferText::JumpAtLine(int32_t newLine)
position_ts BufferText::JumpAtLine(int32_t newLine)
{
position_ts tmp = {0,0};
int32_t positionLine = m_EdnBuf.CountForwardNLines(0, newLine);
m_EdnBuf.Unselect(SELECTION_PRIMARY);
EDN_DEBUG("jump at the line : " << newLine );
@ -1141,8 +1062,9 @@ int32_t BufferText::GetCurrentLine(void)
void BufferText::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp)
position_ts BufferText::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp)
{
position_ts tmp = {0,0};
EDN_INFO("Search data : \"" << data << "\"");
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
@ -1229,8 +1151,9 @@ void BufferText::Search(Edn::String &data, bool back, bool caseSensitive, bool w
}
void BufferText::Replace(Edn::String &data)
position_ts BufferText::Replace(Edn::String &data)
{
position_ts tmp = {0,0};
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
@ -1272,8 +1195,9 @@ void BufferText::Copy(int8_t clipboardID)
* @return ---
*
*/
void BufferText::Cut(int8_t clipboardID)
position_ts BufferText::Cut(int8_t clipboardID)
{
position_ts tmp = {0,0};
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
@ -1288,7 +1212,6 @@ void BufferText::Cut(int8_t clipboardID)
m_cursorPos = SelectionStart;
}
UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true);
}
@ -1301,8 +1224,9 @@ void BufferText::Cut(int8_t clipboardID)
* @return ---
*
*/
void BufferText::Paste(int8_t clipboardID)
position_ts BufferText::Paste(int8_t clipboardID)
{
position_ts tmp = {0,0};
Edn::VectorType<int8_t> mVect;
// copy data from the click board :
ClipBoard::Get(clipboardID, mVect);
@ -1322,29 +1246,28 @@ void BufferText::Paste(int8_t clipboardID)
}
UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true);
}
void BufferText::Undo(void)
position_ts BufferText::Undo(void)
{
position_ts tmp = {0,0};
int32_t newPos = m_EdnBuf.Undo();
if (newPos >= 0) {
SetInsertPosition(newPos, true);
UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true);
}
}
void BufferText::Redo(void)
position_ts BufferText::Redo(void)
{
position_ts tmp = {0,0};
int32_t newPos = m_EdnBuf.Redo();
if (newPos >= 0) {
SetInsertPosition(newPos, true);
UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true);
}
}
@ -1353,6 +1276,51 @@ void BufferText::Redo(void)
void BufferText::SetCharset(charset_te newCharset)
{
m_EdnBuf.SetCharsetType(newCharset);
ForceReDraw(true);
}
bool BufferText::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
// update internal sise of the width of lineID
UpdatePointerNumber();
// Updata uper size of display
size.x = sizePixelX / Display::GetFontWidth();
size.y = sizePixelY / Display::GetFontHeight();
anchor.m_nbIterationMax = size.y;
// update to buffer position
anchor.m_lineNumber = m_AnchorList[localID].m_lineId;
anchor.m_posStart = m_AnchorList[localID].m_bufferPos;
if (anchor.m_posStart >= m_EdnBuf.Size()+1) {
return false;
}
anchor.m_posStop = m_EdnBuf.EndOfLine(anchor.m_posStart);
// Update selection current
int32_t selStart, selEnd, selRectStart, selRectEnd;
bool selIsRect;
bool selHave = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, selStart, selEnd, selIsRect, selRectStart, selRectEnd);
if (false == selHave){
anchor.m_selectionPosStart = -1;
anchor.m_selectionPosStop = -1;
} else {
anchor.m_selectionPosStart = selStart;
anchor.m_selectionPosStop = selEnd;
}
return true;
} else {
return false;
}
}
bool BufferText::AnchorNext(bufferAnchor_ts & anchor)
{
anchor.m_lineNumber++;
anchor.m_posStart = anchor.m_posStop+1;
if (anchor.m_posStart >= m_EdnBuf.Size()+1) {
return false;
}
anchor.m_posStop = m_EdnBuf.EndOfLine(anchor.m_posStart);
return true;
}

View File

@ -39,50 +39,45 @@ typedef enum {
class BufferText : public Buffer {
public:
BufferText(void);
BufferText(Edn::File &fileName);
virtual ~BufferText(void);
void Save(void);
BufferText(void);
BufferText(Edn::File &fileName);
virtual ~BufferText(void);
void Save(void);
void GetInfo(infoStatBuffer_ts &infoToUpdate);
void SetLineDisplay(uint32_t lineNumber);
void GetInfo(infoStatBuffer_ts &infoToUpdate);
void SetLineDisplay(uint32_t lineNumber);
int32_t Display(DrawerManager &drawer);
void AddChar(char * UTF8data);
void cursorMove(int32_t gtkKey);
void MouseSelectFromCursorTo(int32_t width, int32_t height);
void MouseEvent(int32_t width, int32_t height);
void MouseEventDouble(void);
void MouseEventTriple(void);
void ScrollDown(void);
void ScrollUp(void);
void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize);
position_ts AddChar(char * UTF8data);
position_ts cursorMove(int32_t gtkKey);
position_ts MouseSelectFromCursorTo(int32_t width, int32_t height);
position_ts MouseEvent(int32_t width, int32_t height);
position_ts MouseEventDouble(void);
position_ts MouseEventTriple(void);
void ScrollDown(void);
void ScrollUp(void);
void Copy(int8_t clipboardID);
void Cut(int8_t clipboardID);
void Paste(int8_t clipboardID);
void Copy(int8_t clipboardID);
position_ts Cut(int8_t clipboardID);
position_ts Paste(int8_t clipboardID);
void Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp);
void Replace(Edn::String &data);
int32_t FindLine(Edn::String &data);
void JumpAtLine(int32_t newLine);
int32_t GetCurrentLine(void);
position_ts Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp);
position_ts Replace(Edn::String &data);
int32_t FindLine(Edn::String &data);
position_ts JumpAtLine(int32_t newLine);
int32_t GetCurrentLine(void);
void RemoveLine(void);
void SelectAll(void);
void SelectNone(void);
void Undo(void);
void Redo(void);
void SetCharset(charset_te newCharset);
position_ts RemoveLine(void);
position_ts SelectAll(void);
position_ts SelectNone(void);
position_ts Undo(void);
position_ts Redo(void);
void SetCharset(charset_te newCharset);
bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY);
bool AnchorNext(bufferAnchor_ts & anchor);
protected:
void NameChange(void);
// anchor section
public:
void AnchorAdd(int32_t anchorID);
void AnchorRm(int32_t anchorID);
private:
Edn::VectorType<BufferAnchor *> m_AnchorList; //!< list of all line anchor in the current buffer
void NameChange(void);
private:
// Display
@ -92,9 +87,9 @@ class BufferText : public Buffer {
// Direct buffer IO
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
position_ts m_displayStart; //!< position where the display is starting
position_ts m_displaySize; //!< number of char displayable in the screan
int32_t m_displayStartBufferPos; //!< position where the buffer start
//position_ts m_displayStart; //!< position where the display is starting
//position_ts m_displaySize; //!< number of char displayable in the screan
//int32_t m_displayStartBufferPos; //!< position where the buffer start
// Cursor :
int32_t m_cursorPos; //!< position in the buffer of the cursor
@ -122,8 +117,7 @@ class BufferText : public Buffer {
void MoveUpDown(int32_t ofset);
void DrawLineNumber(DrawerManager &drawer, int32_t lineNumber);
void UpdatePointerNumber(void);
void DrawLine(DrawerManager &drawer, int32_t lineNumber, int32_t startPos, int32_t endPos, int32_t selStartPos, int32_t selEndPos);
//void DrawLine(DrawerManager &drawer, int32_t lineNumber, int32_t startPos, int32_t endPos, int32_t selStartPos, int32_t selEndPos);
};

View File

@ -38,15 +38,19 @@
CodeView::CodeView(void) : MsgBroadcast("Code View", EDN_CAT_WORK_AREA)
{
m_bufferID = -1;
m_buttunOneSelected = false;
m_shawableAreaX = 0;
m_shawableAreaY = 0;
// Init link with the buffer Manager
m_bufferManager = BufferManager::getInstance();
m_colorManager = ColorizeManager::getInstance();
static int32_t staticIntLocal = 100;
m_displayUniqueId = staticIntLocal++;
m_bufferID = -1;
m_bufferManager->Get(m_bufferID)->AnchorAdd(m_displayUniqueId);
m_buttunOneSelected = false;
m_shawableAreaX = 0;
m_shawableAreaY = 0;
m_widget = gtk_drawing_area_new();
gtk_widget_set_size_request( m_widget, 200, 100);
@ -98,7 +102,9 @@ void CodeView::OnMessage(int32_t id, int32_t dataID)
{
case EDN_MSG__CURRENT_CHANGE_BUFFER_ID:
//EDN_INFO("Select a new Buffer ... " << dataID);
m_bufferManager->Get(m_bufferID)->AnchorRm(m_displayUniqueId);
m_bufferID = dataID;
m_bufferManager->Get(m_bufferID)->AnchorAdd(m_displayUniqueId);
// request the dispplay of the curent Editor
SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID);
break;
@ -187,6 +193,7 @@ void CodeView::OnMessage(int32_t id, int32_t dataID)
}
//#define COUNT_TIME plop
gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
@ -225,14 +232,36 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo
myColorManager = ColorizeManager::getInstance();
DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY);
//EDN_INFO("Display buffer ID = " << m_bufferID);
(void)self->m_bufferManager->Get(self->m_bufferID)->Display(monDrawer);
Buffer * tmpBuf = self->m_bufferManager->Get(self->m_bufferID);
#ifdef COUNT_TIME
GTimeVal timeStart;
g_get_current_time(&timeStart);
#endif
bufferAnchor_ts anchor;
bool enableToWrite = tmpBuf->AnchorGet(self->m_displayUniqueId, anchor, self->m_displaySize, self->m_shawableAreaX, self->m_shawableAreaY);
while (true == enableToWrite) {
tmpBuf->DrawLine(monDrawer, anchor, self->m_displayStart, self->m_displaySize);
enableToWrite = tmpBuf->AnchorNext(anchor);
}
monDrawer.Flush();
// Need to clean the end of windows (sometimes)...
/*
if (iii<lineIdEnd+1) {
int32_t positionY = letterHeight * (iii - m_displayStart.y - 1);
drawer.Rectangle(myColorManager->Get(COLOR_CODE_BASIC_BG), 0, positionY, drawer.GetWidth(), letterHeight*(lineIdEnd+1-iii) );
}
*/
#ifdef COUNT_TIME
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("Display Generation = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
#endif
return TRUE;
}
// sur : émis lors du premier affichage de la GtkDrawingArea
gboolean CodeView::CB_displayInit( GtkWidget *widget, gpointer data)
{

View File

@ -54,6 +54,9 @@ class CodeView : public MsgBroadcast
private:
// main windows widget :
GtkWidget * m_widget;
int32_t m_displayUniqueId;
position_ts m_displayStart; //!< position where the display is starting
position_ts m_displaySize; //!< number of char displayable in the screan
// récupération des proprieter général...
BufferManager * m_bufferManager;
ColorizeManager * m_colorManager;

View File

@ -164,7 +164,8 @@ class EdnBuf {
void FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded);
public:
void SetHLSystem( Highlight * newHLSystem);
void HightlightGenerateLines(displayHLData_ts & MData, int32_t startPos, int32_t nbLines);
void HightlightOneLine(displayHLData_ts & MData, int32_t HLStart, int32_t HLStop);
void HightlightGenerateLines(displayHLData_ts & MData, int32_t startPos, int32_t nbLines); // TODO : deprecated ...
colorInformation_ts * GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos);
private:
colorInformation_ts * GetElementColorAtPosition(int32_t pos, int32_t &starPos);

View File

@ -286,6 +286,71 @@ colorInformation_ts *EdnBuf::GetElementColorAtPosition(int32_t pos, int32_t &sta
return NULL;
}
//#define COUNT_TIME plop
void EdnBuf::HightlightOneLine(displayHLData_ts & MData, int32_t HLStart, int32_t HLStop)
{
MData.posHLPass1 = 0;
MData.posHLPass2 = 0;
if (NULL == m_Highlight) {
return;
}
#ifdef COUNT_TIME
GTimeVal timeStart;
g_get_current_time(&timeStart);
#endif
int32_t startId, stopId;
// find element previous
FindMainHighLightPosition(HLStart, HLStop, startId, stopId, true);
int32_t k;
//EDN_DEBUG("List of section between : "<< startId << " & " << stopId);
int32_t endSearch = stopId+1;
if (-1 == stopId) {
endSearch = m_HLDataPass1.Size();
}
for (k=edn_max(startId, 0); k<endSearch; k++) {
// empty section :
if (0==k) {
if (HLStart < m_HLDataPass1[k].beginStart) {
//EDN_DEBUG(" ==> (empty section 1 ) k="<<k<<" start="<<HLStart<<" stop="<<m_HLDataPass1[k].beginStart );
m_Highlight->Parse2(HLStart,
m_HLDataPass1[k].beginStart,
MData.HLData,
m_data);
} // else : nothing to do ...
} else {
//EDN_DEBUG(" ==> (empty section 2 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<m_HLDataPass1[k].beginStart );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
m_HLDataPass1[k].beginStart,
MData.HLData,
m_data);
}
// under section :
//EDN_DEBUG(" ==> (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999);
// TODO : ...
}
if (endSearch == (int32_t)m_HLDataPass1.Size() ){
if (m_HLDataPass1.Size() != 0) {
//EDN_DEBUG(" ==> (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
HLStop,
MData.HLData,
m_data);
} else {
//EDN_DEBUG(" ==> (empty section 4 ) k="<<k<<" start=0 stop="<<HLStop );
m_Highlight->Parse2(0,
HLStop,
MData.HLData,
m_data);
}
}
#ifdef COUNT_TIME
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
#endif
}
void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, int32_t nbLines)
@ -296,8 +361,8 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
return;
}
if (MData.idSequence != m_HLDataSequence) {
//GTimeVal timeStart;
//g_get_current_time(&timeStart);
GTimeVal timeStart;
g_get_current_time(&timeStart);
MData.idSequence = m_HLDataSequence;
HLStart = StartOfLine(HLStart);
MData.HLData.Clear();
@ -350,11 +415,10 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
}
}
//GTimeVal timeStop;
//g_get_current_time(&timeStop);
//EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
}
}