Compare commits

...

12 Commits

18 changed files with 759 additions and 396 deletions

View File

@ -41,6 +41,8 @@
*/
Buffer::Buffer()
{
static int32_t bufID = 0;
m_uniqueID = bufID++;
static int32_t fileBasicID = 0;
m_fileModify = true;
m_haveName = false;
@ -48,6 +50,19 @@ Buffer::Buffer()
mString += fileBasicID++;
SetFileName(mString);
m_haveName = false;
// Set basic anchor
bufferAnchorReference_ts tmpAnchor;
tmpAnchor.m_displaySize.x = 0;
tmpAnchor.m_displaySize.y = 0;
tmpAnchor.m_displayStart.x = 0;
tmpAnchor.m_curent = true;
tmpAnchor.m_idAnchor = -1;
tmpAnchor.m_lineId = 0;
tmpAnchor.m_bufferPos = 0;
m_AnchorList.PushBack(tmpAnchor);
m_lineWidth = 10;
m_lineHeight = 10;
}
/**
@ -62,6 +77,16 @@ Buffer::Buffer(Edn::File &newName)
{
m_fileModify = false;
SetFileName(newName);
// Set basic anchor
bufferAnchorReference_ts tmpAnchor;
tmpAnchor.m_displaySize.x = 0;
tmpAnchor.m_displaySize.y = 0;
tmpAnchor.m_displayStart.x = 0;
tmpAnchor.m_curent = true;
tmpAnchor.m_idAnchor = -1;
tmpAnchor.m_lineId = 0;
tmpAnchor.m_bufferPos = 0;
m_AnchorList .PushBack(tmpAnchor);
}
/**
@ -146,11 +171,12 @@ void Buffer::SetLineDisplay(uint32_t lineNumber)
* @return ---
*
*/
int32_t Buffer::Display(DrawerManager &drawer)
void Buffer::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor)
{
return ERR_NONE;
return;
}
/**
* @brief
*
@ -235,7 +261,6 @@ void Buffer::ScrollUp(void)
// nothing to do
}
/**
* @brief
*
@ -244,13 +269,6 @@ void Buffer::ScrollUp(void)
* @return ---
*
*/
void Buffer::ForceReDraw(bool allElement)
{
// nothing to do
}
void Buffer::cursorMove(int32_t gtkKey)
{
// nothing to do
@ -348,7 +366,7 @@ void Buffer::Paste(int8_t clipboardID)
void Buffer::RemoveLine(void)
{
// nothing to do
// nothing to do;
}
void Buffer::SelectAll(void)
@ -371,3 +389,99 @@ void Buffer::Redo(void)
// nothing to do
}
void Buffer::AnchorAdd(int32_t anchorID)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " already exist !!!");
} else {
bufferAnchorReference_ts tmpAnchor = m_AnchorList[0];
m_AnchorList[0].m_curent = false;
tmpAnchor.m_idAnchor = anchorID;
m_AnchorList.PushBack(tmpAnchor);
EDN_DEBUG("[" << m_uniqueID << "] AnchorID="<< anchorID << " ==> Added");
}
}
void Buffer::AnchorRm(int32_t anchorID)
{
if (anchorID == -1) {
EDN_ERROR("[" << m_uniqueID << "] 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("[" << m_uniqueID << "] AnchorID="<< anchorID << " ==> Remove");
} else {
EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " does not exist !!!");
}
}
bool Buffer::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor)
{
EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " Main buffer ==> can not manage Anchor (type buffer specific)");
return false;
}
bool Buffer::AnchorNext(bufferAnchor_ts & anchor)
{
EDN_ERROR("[" << m_uniqueID << "] AnchorID=?? Main buffer ==> can not manage Anchor (type buffer specific)");
return false;
}
void Buffer::AnchorSetSize(int32_t anchorID, int32_t sizePixelX, int32_t sizePixelY)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
m_AnchorList[localID].m_displaySize.x = sizePixelX / m_lineWidth;
m_AnchorList[localID].m_displaySize.y = sizePixelY / m_lineHeight;
}
}
void Buffer::AnchorSetStartOffset(int32_t anchorID, int32_t offsetX, int32_t offsetY)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
m_AnchorList[localID].m_displayStart.x += offsetX;
if (0<m_AnchorList[localID].m_displayStart.x) {
m_AnchorList[localID].m_displayStart.x = 0;
}
m_AnchorList[localID].m_displayStart.y += offsetY;
if (0<m_AnchorList[localID].m_displayStart.y) {
m_AnchorList[localID].m_displayStart.y = 0;
}
}
}
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;
}
int32_t Buffer::AnchorCurrentId(void)
{
for(int32_t iii=0; iii < m_AnchorList.Size(); iii++) {
if (m_AnchorList[iii].m_curent == true) {
return iii;
}
}
return 0;
}

View File

@ -31,15 +31,37 @@
#include "charset.h"
#include "Edn.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; //!< reference id of the anchor (real id of the upper displayer of CodeView)
bool m_curent; //!< set at true if the anchor is a reference with the curent display
int32_t m_lineId; //!< first line ID to display
int32_t m_bufferPos; //!< position of the first lineId
position_ts m_displayStart; //!< start display position
position_ts m_displaySize; //!< size of the curent display
} bufferAnchorReference_ts;
typedef struct {
position_ts m_displayStart; //!< start display position
position_ts m_displaySize; //!< size of the curent display
int32_t m_lineNumber; //!< current line-number id
int32_t m_nbIterationMax; //!< number of cycle needed to end the dispalay
int32_t m_posStart; //!< position of the start of the line
int32_t m_posStop; //!< position of the end of the line
int32_t m_selectionPosStart; //!< position of the selection start
int32_t m_selectionPosStop; //!< position of the selection stop
} bufferAnchor_ts;
}
class Buffer {
@ -81,22 +103,24 @@ class Buffer {
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate);
virtual void SetLineDisplay(uint32_t lineNumber);
virtual int32_t Display(DrawerManager &drawer);
virtual void ForceReDraw(bool allElement);
virtual void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor);
// return the new cursor position ...
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 ScrollDown(void); // must be deprecated
virtual void ScrollUp(void); // must be deprecated
//virtual void SelectAll(void);
virtual void Copy(int8_t clipboardID);
@ -113,6 +137,24 @@ 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);
virtual bool AnchorNext(bufferAnchor_ts & anchor);
void AnchorSetSize(int32_t anchorID, int32_t sizePixelX, int32_t sizePixelY);
void AnchorSetStartOffset(int32_t anchorID, int32_t offsetX, int32_t offsetY);
protected:
int32_t m_lineWidth;
int32_t m_lineHeight;
int32_t AnchorRealId(int32_t anchorID);
int32_t AnchorCurrentId(void);
Edn::VectorType<bufferAnchorReference_ts> m_AnchorList; //!< list of all line anchor in the current buffer
int32_t m_uniqueID;
};

View File

@ -0,0 +1,38 @@
/**
*******************************************************************************
* @file BufferAnchor.cpp
* @brief Editeur De N'ours : anchor on a secific buffer (Sources)
* @author Edouard DUPIN
* @date 11/09/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 "BufferAnchor.h"
BufferAnchor::BufferAnchor(void)
{
}
BufferAnchor::~BufferAnchor(void)
{
}

View File

@ -0,0 +1,56 @@
/**
*******************************************************************************
* @file BufferAnchor.h
* @brief Editeur De N'ours : anchor on a secific buffer (header)
* @author Edouard DUPIN
* @date 11/09/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_ANCHOR_H__
#define __BUFFER_ANCHOR_H__
#include "Display.h"
#include "charset.h"
#include "Edn.h"
class BufferAnchor
{
public :
BufferAnchor(void);
~BufferAnchor(void);
MoveAnchor(int32_t offsetLine);
//BufModification(...);
bool DisplayUpdateFirstLine(void);
bool DisplayUpdateNextLine(void);
private :
int32_t m_lineId;
int32_t m_bufferPos;
public:
int32_t m_lineNumber;
int32_t m_posStart;
int32_t m_posStop;
int32_t m_selectionPosStart;
int32_t m_selectionPosStop;
};
#endif

View File

@ -42,7 +42,8 @@
*/
BufferEmpty::BufferEmpty()
{
m_lineWidth = Display::GetFontWidth();
m_lineHeight = Display::GetFontHeight();
}
/**
@ -67,32 +68,58 @@ BufferEmpty::~BufferEmpty(void)
* @return ---
*
*/
int32_t BufferEmpty::Display(DrawerManager &drawer)
void BufferEmpty::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor)
{
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)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
EDN_DEBUG("Request anchor");
anchor.m_displaySize.x = m_AnchorList[localID].m_displaySize.x;
anchor.m_displaySize.y = m_AnchorList[localID].m_displaySize.y;
anchor.m_displayStart.x = m_AnchorList[localID].m_displayStart.x;
anchor.m_displayStart.y = m_AnchorList[localID].m_displayStart.y;
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);
bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor);
bool AnchorNext(bufferAnchor_ts & anchor);
};

View File

@ -37,8 +37,10 @@
const uint32_t nbLineAllocatedInBase = 300;
extern "C"
{
const char * g_pointerForTheDisplayLine[] = {"%1d", "%2d","%3d","%4d","%5d","%6d","%7d","%8d","%9d","%d"};
}
/**
* @brief
@ -50,12 +52,8 @@ const uint32_t nbLineAllocatedInBase = 300;
*/
void BufferText::BasicInit(void)
{
NeedToCleanEndPage = true;
// set the first element that is displayed
m_displayStartBufferPos = 0;
// set the number of the lineNumber;
nbColoneForLineNumber = 1;
m_nbColoneForLineNumber = 1;
// init the link with the buffer manager
myColorManager = ColorizeManager::getInstance();
// Init Selection mode :
@ -65,12 +63,9 @@ void BufferText::BasicInit(void)
m_cursorPos = 0;
m_cursorPreferredCol = -1;
m_cursorOn = true;
//m_cursorMode = CURSOR_DISPLAY_MODE_NORMAL;
m_displayStart.x = 0;
m_displayStart.y = 0;
m_displaySize.x = 200;
m_displaySize.y = 20;
m_displayLocalSyntax.idSequence = -1;
m_lineWidth = Display::GetFontWidth();
m_lineHeight = Display::GetFontHeight();
}
@ -141,7 +136,6 @@ BufferText::BufferText(Edn::File &fileName) : Buffer(fileName)
SetModify(true);
}
UpdateWindowsPosition();
ForceReDraw(true);
}
@ -229,215 +223,182 @@ void BufferText::SetLineDisplay(uint32_t lineNumber)
}
void BufferText::DrawLineNumber(DrawerManager &drawer,char *myPrint, int32_t lineNumber, int32_t positionY)
void BufferText::DrawLineNumber(DrawerManager &drawer, int32_t lineNumber, int32_t positionY)
{
int32_t letterHeight = Display::GetFontHeight();
char tmpLineNumber[50];
sprintf(tmpLineNumber, myPrint, lineNumber);
sprintf(tmpLineNumber, g_pointerForTheDisplayLine[m_nbColoneForLineNumber-1], lineNumber);
drawer.Text(myColorManager->Get(COLOR_CODE_LINE_NUMBER), 1, positionY, tmpLineNumber);
}
/**
* @brief Display the curent buffer with all the probematic imposed by the xharset and the user contraint.
* @brief Update internal data of the pointer to display
*
* @param[in,out] drawer the basic user drawer of EDN.
* @param[in,out] ---
*
* @return
* @return ---
*
*/
int32_t BufferText::Display(DrawerManager &drawer)
void BufferText::UpdatePointerNumber(void)
{
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
// update the number of element that can be displayed
m_displaySize.x = (drawer.GetWidth()/letterWidth) + 1 - 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;
int32_t selHave = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, selStart, selEnd, selIsRect, selRectStart, selRectEnd);
colorInformation_ts * HLColor = NULL;
//displayLineNumber(drawer);
// get the number of line in the buffer
int32_t maxNumberLine = m_EdnBuf.NumberOfLines();
//int32_t maxNumberLine = 2096;
char *myPrint = NULL;
if (10 > maxNumberLine) { nbColoneForLineNumber = 1; myPrint = (char *)"%1d";
} else if (100 > maxNumberLine) { nbColoneForLineNumber = 2; myPrint = (char *)"%2d";
} else if (1000 > maxNumberLine) { nbColoneForLineNumber = 3; myPrint = (char *)"%3d";
} else if (10000 > maxNumberLine) { nbColoneForLineNumber = 4; myPrint = (char *)"%4d";
} else if (100000 > maxNumberLine) { nbColoneForLineNumber = 5; myPrint = (char *)"%5d";
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 6; myPrint = (char *)"%6d";
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 7; myPrint = (char *)"%7d";
} else if (10000000 > maxNumberLine) { nbColoneForLineNumber = 8; myPrint = (char *)"%8d";
} else if (100000000 > maxNumberLine) { nbColoneForLineNumber = 9; myPrint = (char *)"%9d";
} else { nbColoneForLineNumber = 10; myPrint = (char *)"%d";
if (10 > maxNumberLine) { m_nbColoneForLineNumber = 1;
} else if (100 > maxNumberLine) { m_nbColoneForLineNumber = 2;
} else if (1000 > maxNumberLine) { m_nbColoneForLineNumber = 3;
} else if (10000 > maxNumberLine) { m_nbColoneForLineNumber = 4;
} else if (100000 > maxNumberLine) { m_nbColoneForLineNumber = 5;
} else if (1000000 > maxNumberLine) { m_nbColoneForLineNumber = 6;
} else if (1000000 > maxNumberLine) { m_nbColoneForLineNumber = 7;
} else if (10000000 > maxNumberLine) { m_nbColoneForLineNumber = 8;
} else if (100000000 > maxNumberLine) { m_nbColoneForLineNumber = 9;
} else { m_nbColoneForLineNumber = 10;
}
}
void BufferText::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor)
{
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
int32_t positionY = letterHeight * (anchor.m_lineNumber - anchor.m_displayStart.y - 1);
int32_t idX = 0;
int32_t pixelX = m_nbColoneForLineNumber*letterWidth + 3;
Colorize * myColorNormal = myColorManager->Get("normal");
Colorize * myColorSelected = myColorManager->Get("SelectedText");
Colorize * selectColor = NULL;
colorInformation_ts * HLColor = NULL;
uint32_t y = 0;
int32_t iii, new_i;
// Get color :
Colorize * myColor = myColorManager->Get("normal");
Colorize * myColorSel = myColorManager->Get("SelectedText");
color_ts & myColorSpace = myColorManager->Get(COLOR_CODE_SPACE);
color_ts & myColorTab = myColorManager->Get(COLOR_CODE_TAB);
Colorize * selectColor = NULL;
// Regenerate the colorizing if necessary ...
displayHLData_ts myDisplayLocalSyntax;
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, anchor.m_lineNumber, positionY);
bool selHave = anchor.m_selectionPosStart == -1 ? false : true;
char displayChar[MAX_EXP_CHAR_LEN];
memset(displayChar, 0, sizeof(char)*MAX_EXP_CHAR_LEN);
int mylen = m_EdnBuf.Size();
int32_t x_base=nbColoneForLineNumber*letterWidth + 3;
uint32_t xx = 0;
int32_t idX = 0;
drawer.Clean(myColorManager->Get(COLOR_CODE_BASIC_BG));
int displayLines = 0;
// Regenerate the colorizing if necessary ...
m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, m_displayStartBufferPos, m_displaySize.y);
GTimeVal timeStart;
g_get_current_time(&timeStart);
// draw the lineNumber :
int32_t currentLineID = m_displayStart.y+1;
DrawLineNumber(drawer, myPrint, currentLineID, y);
for (iii=m_displayStartBufferPos; iii<mylen && displayLines < m_displaySize.y ; iii = new_i) {
//EDN_INFO("diplay element=" << iii);
int32_t pixelX = xx*letterWidth + x_base;
int displaywidth;
uint32_t currentChar = '\0';
new_i = iii;
displaywidth = m_EdnBuf.GetExpandedChar(new_i, idX, displayChar, currentChar);
//EDN_INFO("diplay element=" << new_i);
if (currentChar!='\n') {
selectColor = myColor;
//kwow size to display
int32_t widthToDisplay;
char * tmpDisplayOfset;
bool inTheScreen = true;
if (m_displayStart.x <= idX) {
// Normal display
tmpDisplayOfset = displayChar;
widthToDisplay = displaywidth;
} else if (m_displayStart.x < idX + displaywidth) {
// special case of partial display :
widthToDisplay = idX + displaywidth - m_displayStart.x;
tmpDisplayOfset = displayChar + (displaywidth-widthToDisplay);
} else {
// Out of range ...
widthToDisplay = displaywidth;
tmpDisplayOfset = displayChar;
inTheScreen = false;
}
if (true==inTheScreen) {
HLColor = m_EdnBuf.GetElementColorAtPosition(m_displayLocalSyntax, iii);
if (NULL != HLColor) {
if (NULL != HLColor->patern) {
selectColor = HLColor->patern->GetColor();
}
int32_t iii;
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);
selectColor = myColorNormal;
//kwow size to display
int32_t widthToDisplay;
char * tmpDisplayOfset;
bool inTheScreen = true;
if (anchor.m_displayStart.x <= idX) {
// Normal display
tmpDisplayOfset = displayChar;
widthToDisplay = displaywidth;
} else if (anchor.m_displayStart.x < idX + displaywidth) {
// special case of partial display :
widthToDisplay = idX + displaywidth - anchor.m_displayStart.x;
tmpDisplayOfset = displayChar + (displaywidth-widthToDisplay);
} else {
// Out of range ...
widthToDisplay = displaywidth;
tmpDisplayOfset = displayChar;
inTheScreen = false;
}
if (true==inTheScreen) {
HLColor = m_EdnBuf.GetElementColorAtPosition(myDisplayLocalSyntax, savePositionForCursor);
if (NULL != HLColor) {
if (NULL != HLColor->patern) {
selectColor = HLColor->patern->GetColor();
}
// If user want to display space char : overwrite curent color
if( ' ' == currentChar
&& true == globals::IsSetDisplaySpaceChar() )
}
// If user want to display space char : overwrite curent color
if( ' ' == currentChar
&& true == globals::IsSetDisplaySpaceChar() )
{
//selectColor = myColorSelected;
//SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar)
if( true == selHave
&& anchor.m_selectionPosStart <= iii
&& anchor.m_selectionPosStop > iii)
{
//selectColor = myColorSel;
//SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar)
if( true == selHave
&& selStart <= iii
&& selEnd > iii)
{
drawer.SpaceText(myColorSel->GetBG(), pixelX ,y , 1);
} else if (true == selectColor->HaveBg()) {
drawer.SpaceText(selectColor->GetBG(), pixelX ,y , 1);
} else {
drawer.SpaceText(myColorSpace, pixelX ,y , 1);
}
} else if( '\t' == currentChar
&& true == globals::IsSetDisplaySpaceChar() )
{
if( true == selHave
&& selStart <= iii
&& selEnd > iii)
{
drawer.SpaceText(myColorSel->GetBG(), pixelX ,y , strlen(tmpDisplayOfset));
} else if (true == selectColor->HaveBg()) {
drawer.SpaceText(selectColor->GetBG(), pixelX ,y , strlen(tmpDisplayOfset));
} else {
drawer.SpaceText(myColorTab, pixelX ,y , strlen(tmpDisplayOfset));
}
drawer.SpaceText(myColorSelected->GetBG(), pixelX ,positionY , 1);
} else if (true == selectColor->HaveBg()) {
drawer.SpaceText(selectColor->GetBG(), pixelX ,positionY , 1);
} else {
if( true == selHave
&& selStart <= iii
&& selEnd > iii)
{
selectColor = myColorSel;
}
if (currentChar <= 0x7F) {
drawer.Text(selectColor, pixelX ,y, tmpDisplayOfset);
} else {
drawer.Text(selectColor, pixelX ,y, displayChar);
}
drawer.SpaceText(myColorManager->Get(COLOR_CODE_SPACE), pixelX ,positionY , 1);
}
} else if( '\t' == currentChar
&& true == globals::IsSetDisplaySpaceChar() )
{
if( true == selHave
&& anchor.m_selectionPosStart <= iii
&& anchor.m_selectionPosStop > iii)
{
drawer.SpaceText(myColorSelected->GetBG(), pixelX ,positionY , strlen(tmpDisplayOfset));
} else if (true == selectColor->HaveBg()) {
drawer.SpaceText(selectColor->GetBG(), pixelX ,positionY , strlen(tmpDisplayOfset));
} else {
drawer.SpaceText(myColorManager->Get(COLOR_CODE_TAB), pixelX ,positionY , strlen(tmpDisplayOfset));
}
} else {
if( true == selHave
&& anchor.m_selectionPosStart <= iii
&& anchor.m_selectionPosStop > iii)
{
selectColor = myColorSelected;
}
if (currentChar <= 0x7F) {
drawer.Text(selectColor, pixelX ,positionY, tmpDisplayOfset);
} else {
drawer.Text(selectColor, pixelX ,positionY, displayChar);
}
xx+=widthToDisplay;
}
idX += displaywidth;
}
// display cursor :
if (m_cursorPos == iii) {
if (m_cursorPos == savePositionForCursor) {
// display the cursor:
if (true == m_cursorOn) {
drawer.Cursor(pixelX, y+letterHeight);
drawer.Cursor(pixelX, positionY+letterHeight);
//m_cursorOn = false;
} else {
m_cursorOn = true;
}
}
// move to next line ...
if (currentChar=='\n') {
drawer.EndOfLine(pixelX, y+letterHeight);
drawer.Flush();
xx = 0;
idX =0;
y += letterHeight;
displayLines++;
currentLineID++;
DrawLineNumber(drawer, myPrint, currentLineID, y);
if (true==inTheScreen) {
pixelX += widthToDisplay*letterWidth;
}
idX += displaywidth;
}
// special case : the cursor is at the end of the buffer...
if (m_cursorPos == iii) {
// display the cursor:
if (true == m_cursorOn) {
drawer.Cursor(xx*letterWidth + x_base, y+letterHeight);
m_cursorOn = false;
drawer.Cursor(pixelX, positionY+letterHeight);
//m_cursorOn = false;
} else {
m_cursorOn = true;
}
}
drawer.Flush();
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("Display Generation = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
return ERR_NONE;
}
void BufferText::GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y)
{
x = (width - 3) / Display::GetFontWidth() - nbColoneForLineNumber;
x = (width - 3) / Display::GetFontWidth() - m_nbColoneForLineNumber;
y = height / Display::GetFontHeight();
if (x < 0) {
x = 0;
}
x += m_displayStart.x;
y += m_displayStart.y;
x += m_AnchorList[AnchorCurrentId()].m_displayStart.x;
y += m_AnchorList[AnchorCurrentId()].m_displayStart.y;
//EDN_DEBUG("BufferText::GetMousePosition(" << width << "," << height << "); ==> (" << x << "," << y << ")" );
}
@ -472,7 +433,6 @@ void BufferText::MouseEvent(int32_t width, int32_t height)
}
m_EdnBuf.Unselect(SELECTION_PRIMARY);
ForceReDraw(true);
UpdateWindowsPosition();
}
}
@ -522,7 +482,6 @@ void BufferText::MouseSelectFromCursorTo(int32_t width, int32_t height)
m_EdnBuf.Select(SELECTION_PRIMARY, selStart, m_cursorPos);
}
}
ForceReDraw(true);
UpdateWindowsPosition();
}
@ -542,7 +501,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
}
@ -559,7 +517,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)
@ -575,13 +532,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);
}
/**
@ -622,44 +577,31 @@ void BufferText::ScrollUp(void)
*/
void BufferText::MoveUpDown(int32_t ofset)
{
m_displayLocalSyntax.idSequence = -1;
int32_t iii=AnchorCurrentId();
if (ofset >= 0) {
int32_t nbLine = m_EdnBuf.NumberOfLines();
if (m_displayStart.y+ofset+3 > nbLine) {
m_displayStart.y = nbLine-3;
if (m_AnchorList[iii].m_displayStart.y+ofset+3 > nbLine) {
m_AnchorList[iii].m_displayStart.y = nbLine-3;
} else {
m_displayStart.y += ofset;
m_AnchorList[iii].m_displayStart.y += ofset;
}
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStart.y);
m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y);
m_AnchorList[iii].m_lineId = m_AnchorList[iii].m_displayStart.y;
} else {
ofset *= -1;
if (m_displayStart.y < ofset) {
m_displayStart.y = 0;
m_displayStartBufferPos = 0;
if (m_AnchorList[iii].m_displayStart.y < ofset) {
m_AnchorList[iii].m_displayStart.y = 0;
m_AnchorList[iii].m_bufferPos = 0;
m_AnchorList[iii].m_lineId = 0;
} else {
m_displayStart.y -= ofset;
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStart.y);
m_AnchorList[iii].m_displayStart.y -= ofset;
m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y);
m_AnchorList[iii].m_lineId = m_AnchorList[iii].m_displayStart.y;
}
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void BufferText::ForceReDraw(bool allElement)
{
NeedToCleanEndPage = true;
//m_displayLocalSyntax.idSequence = -1;
}
void BufferText::SetInsertPosition(int32_t newPos, bool insertChar)
{
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
@ -842,7 +784,7 @@ void BufferText::cursorMove(int32_t gtkKey)
case GDK_Page_Up:
# endif
//EDN_INFO("keyEvent : <PAGE-UP>");
TextDMoveUp(m_displaySize.x);
TextDMoveUp(m_AnchorList[AnchorCurrentId()].m_displaySize.x);
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Page_Down:
@ -850,7 +792,7 @@ void BufferText::cursorMove(int32_t gtkKey)
case GDK_Page_Down:
# endif
//EDN_INFO("keyEvent : <PAGE-DOWN>");
TextDMoveDown(m_displaySize.x);
TextDMoveDown(m_AnchorList[AnchorCurrentId()].m_displaySize.x);
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Begin:
@ -889,57 +831,55 @@ void BufferText::cursorMove(int32_t gtkKey)
*/
void BufferText::UpdateWindowsPosition(bool centerPage)
{
if (centerPage == false) {
// Display position (Y mode):
//EDN_INFO("BufferText::UpdateWindowsPosition() m_displayStart(" << m_displayStart.x << "," << m_displayStart.y << ") m_displaySize(" << m_displaySize.x << "," <<m_displaySize.y << ")");
position_ts cursorPosition;
cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
int32_t lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
cursorPosition.x = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos);
//EDN_INFO("BufferText::UpdateWindowsPosition() curent cursor position : (" << cursorPosition.x << "," << cursorPosition.y << ")");
if (m_displayStart.y > (int32_t)cursorPosition.y - globals::getNbLineBorder() ) {
m_displayStart.y = cursorPosition.y - globals::getNbLineBorder();
if (m_displayStart.y < 0) {
m_displayStart.y = 0;
ForceReDraw(true);
for (int32_t iii=0; iii < m_AnchorList.Size() ; iii++) {
if (centerPage == false) {
// Display position (Y mode):
//EDN_INFO(" m_displayStart(" << m_displayStart.x << "," << m_displayStart.y << ") m_displaySize(" << m_displaySize.x << "," <<m_displaySize.y << ")");
position_ts cursorPosition;
cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
int32_t lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
cursorPosition.x = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos);
//EDN_INFO(" curent cursor position : (" << cursorPosition.x << "," << cursorPosition.y << ")");
if (m_AnchorList[iii].m_displayStart.y > (int32_t)cursorPosition.y - globals::getNbLineBorder() ) {
m_AnchorList[iii].m_displayStart.y = cursorPosition.y - globals::getNbLineBorder();
if (m_AnchorList[iii].m_displayStart.y < 0) {
m_AnchorList[iii].m_displayStart.y = 0;
}
} else if (m_AnchorList[iii].m_displayStart.y + m_AnchorList[iii].m_displaySize.y <= (int32_t)cursorPosition.y + globals::getNbLineBorder() ) {
m_AnchorList[iii].m_displayStart.y = cursorPosition.y - m_AnchorList[iii].m_displaySize.y + globals::getNbLineBorder() + 1;
}
} 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);
if (m_displayStart.x > cursorPosition.x - globals::getNbColoneBorder() ) {
m_displayStart.x = cursorPosition.x - globals::getNbColoneBorder();
if (m_displayStart.x < 0) {
m_displayStart.x = 0;
ForceReDraw(true);
// Display position (X mode):
//EDN_INFO("cursorPosition X : " << cursorPosition.y << " windows " << m_displayStart.y << "=>" << m_displayStart.x + m_displaySize.x);
if (m_AnchorList[iii].m_displayStart.x > cursorPosition.x - globals::getNbColoneBorder() ) {
m_AnchorList[iii].m_displayStart.x = cursorPosition.x - globals::getNbColoneBorder();
if (m_AnchorList[iii].m_displayStart.x < 0) {
m_AnchorList[iii].m_displayStart.x = 0;
}
} else if (m_AnchorList[iii].m_displayStart.x + m_AnchorList[iii].m_displaySize.x <= cursorPosition.x + globals::getNbColoneBorder() ) {
m_AnchorList[iii].m_displayStart.x = cursorPosition.x - m_AnchorList[iii].m_displaySize.x + globals::getNbColoneBorder() + 1;
}
} 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 :
m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y);
m_AnchorList[iii].m_lineId = m_AnchorList[iii].m_displayStart.y;
} else {
// center the line at the middle of the screen :
position_ts cursorPosition;
//EDN_DEBUG(" -------------------------------------------------");
cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
//EDN_DEBUG(" cursor position : " << m_cursorPos << " ==> ligne=" << cursorPosition.y);
cursorPosition.x = 0;
m_AnchorList[iii].m_displayStart.x = 0;
//EDN_DEBUG(" display size : " << m_displaySize.y);
m_AnchorList[iii].m_displayStart.y = cursorPosition.y - m_AnchorList[iii].m_displaySize.y/2;
m_AnchorList[iii].m_displayStart.y = edn_max(m_AnchorList[iii].m_displayStart.y, 0);
m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y);
m_AnchorList[iii].m_lineId = m_AnchorList[iii].m_displayStart.y;
//EDN_DEBUG(" display start : " << m_displayStart.x << "x" << m_displayStart.y);
//EDN_DEBUG(" -------------------------------------------------");
}
//update the buffer position ID :
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStart.y);
} else {
// center the line at the middle of the screen :
position_ts cursorPosition;
//EDN_DEBUG(" -------------------------------------------------");
cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
//EDN_DEBUG(" cursor position : " << m_cursorPos << " ==> ligne=" << cursorPosition.y);
cursorPosition.x = 0;
m_displayStart.x = 0;
//EDN_DEBUG(" display size : " << m_displaySize.y);
m_displayStart.y = cursorPosition.y - m_displaySize.y/2;
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(" -------------------------------------------------");
}
}
@ -1254,7 +1194,6 @@ void BufferText::Copy(int8_t clipboardID)
*/
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);
@ -1268,7 +1207,6 @@ void BufferText::Cut(int8_t clipboardID)
m_cursorPos = SelectionStart;
}
UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true);
}
@ -1302,7 +1240,6 @@ void BufferText::Paste(int8_t clipboardID)
}
UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true);
}
@ -1313,7 +1250,6 @@ void BufferText::Undo(void)
if (newPos >= 0) {
SetInsertPosition(newPos, true);
UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true);
}
}
@ -1324,7 +1260,6 @@ void BufferText::Redo(void)
if (newPos >= 0) {
SetInsertPosition(newPos, true);
UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true);
}
}
@ -1333,6 +1268,59 @@ 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)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
// update internal sise of the width of lineID
UpdatePointerNumber();
// Updata uper size of display
anchor.m_displaySize.x = m_AnchorList[localID].m_displaySize.x;
anchor.m_displaySize.y = m_AnchorList[localID].m_displaySize.y;
anchor.m_displayStart.x = m_AnchorList[localID].m_displayStart.x;
anchor.m_displayStart.y = m_AnchorList[localID].m_displayStart.y;
anchor.m_nbIterationMax = anchor.m_displaySize.y;
// update to buffer position
anchor.m_lineNumber = m_AnchorList[localID].m_lineId +1;
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+1;
anchor.m_selectionPosStop = selEnd+1;
}
EDN_DEBUG("Request display : line=" << anchor.m_lineNumber << " (" << anchor.m_posStart << "," << anchor.m_posStop << ")");
EDN_DEBUG(" ==> select : (" << anchor.m_selectionPosStart << "," << anchor.m_selectionPosStop << ")");
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);
anchor.m_nbIterationMax--;
if (anchor.m_nbIterationMax<0) {
return false;
}
return true;
}

View File

@ -36,65 +36,66 @@ typedef enum {
CURSOR_DISPLAY_MODE_NOT_FOCUS,
} cursorDisplayMode_te;
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 ForceReDraw(bool allElement);
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);
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 Copy(int8_t clipboardID);
void Cut(int8_t clipboardID);
void Paste(int8_t clipboardID);
void Copy(int8_t clipboardID);
void Cut(int8_t clipboardID);
void 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);
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);
void RemoveLine(void);
void SelectAll(void);
void SelectNone(void);
void Undo(void);
void Redo(void);
void SetCharset(charset_te newCharset);
void RemoveLine(void);
void SelectAll(void);
void SelectNone(void);
void Undo(void);
void Redo(void);
void SetCharset(charset_te newCharset);
bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor);
bool AnchorNext(bufferAnchor_ts & anchor);
protected:
void NameChange(void);
void NameChange(void);
private:
// Display
bool NeedToCleanEndPage; //!< if true, the end of the page need to be clean (arrive after a remove line)
uint32_t nbColoneForLineNumber; //!< number of colome used to display the line Number
ColorizeManager * myColorManager; //!< for the background color :
ColorizeManager * myColorManager; //!< for the background color :
int32_t m_nbColoneForLineNumber; //!< number of colomn use for linenumber display
// 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
// Cursor :
int32_t m_cursorPos; //!< position in the buffer of the cursor
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
bool m_cursorOn; //!< the blink of the cursor ...
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
displayHLData_ts m_displayLocalSyntax; //!< for the display of the local elements (display HL mode)
//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
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
bool m_cursorOn; //!< the blink of the cursor ...
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
// internal function
void BasicInit(void);
@ -114,7 +115,9 @@ class BufferText : public Buffer {
void GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y);
void MoveUpDown(int32_t ofset);
void DrawLineNumber(DrawerManager &drawer,char *myPrint, int32_t lineNumber, int32_t positionY);
void DrawLineNumber(DrawerManager &drawer, int32_t lineNumber, int32_t positionY);
void UpdatePointerNumber(void);
};

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,8 +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)->ForceReDraw(true);
m_bufferManager->Get(m_bufferID)->AnchorAdd(m_displayUniqueId);
// request the dispplay of the curent Editor
SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID);
break;
@ -188,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)
{
@ -197,6 +203,7 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo
# ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
EDN_INFO("GTK+ request a diplay of : "<< allocation.width <<"px * "<< allocation.height <<"px");
bool needRedrawAll = false;
if (self->m_shawableAreaX != allocation.width) {
needRedrawAll = true;
@ -207,6 +214,7 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo
self->m_shawableAreaY = allocation.height;
}
# elif defined( USE_GTK_VERSION_2_0)
EDN_INFO("GTK+ request a diplay of : "<< widget->allocation.width <<"px * "<< widget->allocation.height <<"px");
bool needRedrawAll = false;
if (self->m_shawableAreaX != widget->allocation.width) {
needRedrawAll = true;
@ -217,32 +225,44 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo
self->m_shawableAreaY = widget->allocation.height;
}
# endif
if (true == needRedrawAll) {
//updateScrollElement();
self->m_bufferManager->Get(self->m_bufferID)->ForceReDraw(true);
}
EDN_INFO("Request a display of : " << self->m_shawableAreaX << "px * "<< self->m_shawableAreaY<<"px");
/*
EDN_INFO("widget width=%d", widget->allocation.width);
EDN_INFO("widget height=%d", widget->allocation.height);
*/
EDN_INFO("Edn request a display of : " << self->m_shawableAreaX << "px * "<< self->m_shawableAreaY<<"px");
//EDN_INFO("BufferView Display");
// Get the color Manager :
ColorizeManager *myColorManager = NULL;
myColorManager = ColorizeManager::getInstance();
//(void)m_bufferManager->Get(m_bufferID)->Display(m_displayParameters, m_shawableAreaX, m_shawableAreaY);
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);
// EDN_WARNING("Must display here ... ");
Buffer * tmpBuf = self->m_bufferManager->Get(self->m_bufferID);
#ifdef COUNT_TIME
GTimeVal timeStart;
g_get_current_time(&timeStart);
#endif
bufferAnchor_ts anchor;
tmpBuf->AnchorSetSize(self->m_displayUniqueId, self->m_shawableAreaX, self->m_shawableAreaY);
bool enableToWrite = tmpBuf->AnchorGet(self->m_displayUniqueId, anchor);
while (true == enableToWrite) {
tmpBuf->DrawLine(monDrawer, anchor);
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)
{
@ -250,22 +270,15 @@ gboolean CodeView::CB_displayInit( GtkWidget *widget, gpointer data)
# ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int32_t size_x = allocation.width;
int32_t size_y = allocation.height;
EDN_INFO("GTK+ request a diplay of : "<< allocation.width <<"px * "<< allocation.height <<"px");
self->m_shawableAreaX = allocation.width;
self->m_shawableAreaY = allocation.height;
# elif defined( USE_GTK_VERSION_2_0)
int32_t size_x = widget->allocation.width;
int32_t size_y = widget->allocation.height;
EDN_INFO("GTK+ request a diplay of : "<< widget->allocation.width <<"px * "<< widget->allocation.height <<"px");
self->m_shawableAreaX = widget->allocation.width;
self->m_shawableAreaY = widget->allocation.height;
# endif
EDN_INFO("Request a diplay of : "<< size_x <<"px * "<< size_y <<"px");
gtk_widget_queue_draw( widget );
return TRUE;
}

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

@ -165,8 +165,11 @@ void MainWindows::SetTitle(Edn::File &fileName, bool isModify)
}
tmp += "Edn";
gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
tmp = " ";
if (fileName.GetShortFilename() != "") {
tmp = fileName.GetFolder();
tmp += "/";
tmp += fileName.GetShortFilename();
} else {
tmp = "Edn";
}

View File

@ -159,6 +159,8 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y)
cairo_scale(m_cairo, 1.0, 1.0);
m_nbElement = 0;
// http://cairographics.org/FAQ/#clear_a_surface
// http://gtk.developpez.com/faq/?page=gtkwidget#GTK_WIDGET_transparent
//cairo_set_source_rgba(m_cairo, 1, 1, 1, 0);
@ -289,9 +291,8 @@ void DrawerManager::Flush(void)
int32_t letterHeight = Display::GetFontHeight();
if (true == m_selectColor->HaveBg() ) {
int32_t letterWidth = Display::GetFontWidth();
int32_t stringLen = m_nbElement;
// generate Clean BG:
DirectRectangle(m_selectColor, m_pos.x, m_pos.y, letterWidth*stringLen, letterHeight);
DirectRectangle(m_selectColor, m_pos.x, m_pos.y, letterWidth*m_nbElement, letterHeight);
}
cairo_move_to(m_cairo, m_pos.x, m_pos.y+letterHeight-4);
m_selectColor->ApplyFG(m_cairo);
@ -350,9 +351,10 @@ void DrawerManager::DirectRectangle(Colorize *SelectColor, int32_t x, int32_t y,
// flush
cairo_fill(m_cairo);
}
void DrawerManager::DirectRectangle(color_ts &SelectColor, int32_t x, int32_t y, int32_t width, int32_t height)
{
cairo_set_source_rgb(m_cairo, SelectColor.red, SelectColor.green, SelectColor.blue);
// set postion
cairo_rectangle(m_cairo, x, y, width, height);

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)
@ -354,7 +419,6 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
g_get_current_time(&timeStop);
EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
}
}

View File

@ -422,7 +422,11 @@ static uint32_t Utf8_GetValue(UTF8Element_ts &Element)
int32_t strUtf8Len(const char *input_UTF8)
{
int32_t count = 0;
int32_t size = strlen(input_UTF8);
int32_t sizeInput = strlen(input_UTF8);
int32_t size = sizeInput;
if (size>20) {
EDN_DEBUG("check SIZE...");
}
uint8_t tmpSize;
bool baseValid;
while (size > 0) {
@ -1139,7 +1143,11 @@ void ConvertInput(GdkEventKey *event, char* Utf8Out, bool &controlKey, bool &mov
# endif
key = '?';
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Caps_Lock:
# elif USE_GTK_VERSION_2_0
case GDK_Caps_Lock:
# endif
controlKey = true;
break;
default:

View File

@ -1,7 +1,7 @@
# action a faire (ordonner par révision) :
* 0.2.X :
- gui : Amelioration du full-screen et du display de base (sans l'entete de la fenetre)
- gui : Mise en place d'un display ligne par ligne
- gui : display partielle de la fenetre
- gui : ascenceur quand nécessaire
- gui : Demander la création de nouveaux fichier quand il n'existe pas (a l'ouverture en ligne de commande)
- sys : Mise en place des colorisation de base pour le
@ -10,7 +10,6 @@
- sys : replace TAB with space when Tab is pressed
- sys : Catch F[1-12] ==> for user personal event
- BUG : Correction du bug des entré bizard tel que les chapot et les guillemets
- BUG : de sélection quand la ligne est pleine et la première ligne séctionnée. ==> regarder après avoir fait le display ligne par ligne...
- BUG : de copier coller sur les éàè ...
- BUG : les caractère multiples type chapot ...
- BUG : italique non généré

View File

@ -28,7 +28,7 @@
</rule>
<rule name="global inclusion">
<color>preprocesseur</color>
<start>global </start>
<start>global( |\t)+</start>
<end>\n</end>
<EscapeChar>\</EscapeChar>
</rule>

View File

@ -20,7 +20,7 @@ static gboolean expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_d
static void clicked(GtkWindow *win, GdkEventButton *event, gpointer user_data);
# if USE_GTK_VERSION_3_0
#if USE_GTK_VERSION_3_0
const GdkRGBA color = { 1.0, 1.0, 0.0, 0.0};
#endif